I previously published a couple of posts on generating Wiki documentation in dbscript, and the current release 0.93 of dbscript puts all the steps together to automatically generate MediaWiki documentation of an MS SQL Server database schema, and values of selected tables.
This is an example of how to generate documentation for the AdventureWorks sample database. You need:
- dbscript 0.93 or later installed
- AdventureWorks installed
- a MediaWiki installation with a user in the Bot group
In dbscript, create a Project AdventureWorks. Add a Database with dbo login credentials, and press Test Connection to mark the database connectable. (Alternatively, you can script the AdventureWorks database in Management Studio, and upload the generated sql file)
The Documentation Generator needs to handle tables differently from other database objects, as it needs to apply different XSL style sheets to the schema information.
Thus we create an Object Selection which selects every object except of tables: create an Object Selection “everything except tables”, and click the Objects page. Add Object Type “Table” with the option “Select included objects” selected. Add all other available object types with the “Select excluded objects” option.
Create a Documentation Generator, and select type “MediaWiki” (currently the only available option). Select the newly created Project Version. Enter the Wiki’s URL (http://mywiki.example.com), a section name (optional), the wiki bot’s username and its password.
If no section name is given, the whole page for each database object will be replaced. If you specify a section name, only this section is created or changed.
Next, go to the Parts page.
Under “New Part”, select “Project Version” and click Create. Enter a sequence number (e.g. 100), select an XSL (MediaWiki ProjectVersion overview), and a Page Title (“AdventureWorks Overview”) and save. This will create a summary page.
Go to the Parts page again, select New Part “Object”, click Create. Now we add tables to the documentation. Enter a sequence number (200), select an XSL (MediaWiki Table DocGen), and an Object Type “Table”.
Now we add all database objects other than tables: On the Parts page, select “Object”, click Create. Enter sequence number (300), select XSL (MediaWiki SourceCode DocGen), and specify Object Select “everything except tables”.
Go to the Generate page. Press the Generate button, and watch the progress log for error messages or progress updates.