CodeSmith Community
Your Code. Your Way. Faster!

Database HTML Documentation Template

Latest post 02-13-2007 2:44 AM by KMax. 30 replies.
  • 12-05-2003 6:57 PM

    • jalexander
    • Not Ranked
    • Joined on 08-11-2003
    • Dallas, TX
    • Posts 6
    • Points 675

    Database HTML Documentation Template

    Hey all,
     
     
    I recently whipped up a CodeSmith template to generate database documentation in HTML. The current version just handles tables, columns, extended properties, etc... but, I'm currently working on expanding it out to include full documentation, and easy one-click generation.
     
    You can see a demo of the output at:
     
     
    You can download the template and supporting collateral at:
     
     
    or:
     
     
    And, of course, any comments, suggestions, etc... are much appreciated.
     
    1/5/2004 - Updated to point to new link, demo and site.
     
    Thanks,
    -Jason

    Post Edited (Jason Alexander) : 1/5/2004 8:40:15 PM GMT

    • Post Points: 650
  • 12-08-2003 1:15 AM In reply to

    RE: Database HTML Documentation Template

    Jason - thanks! I was going to do something similar but now I don't have to...

    One thing I've been thinking about is how to provide documentation for stored procedures. I'd like to come up with some sort of standardized approach to commenting these and then have those comments transferred to my DAL procedure wrapper methods. Of course the problem here is that there's no extended property support for stored procedures - at least not an easy way as far as I am aware of. I'd be delighted if I was wrong about this point.

    My current thought is to use a standardized commenting format as follows:

    --My procedure commnet goes here
    --Can be multi-lined
    CREATE PROC FooBar
    @Foo int -- Comment for @Foo
    @Bar varchar(30) --Comment for @Bar
    AS
    SELECT Foo FROM Bar
    RETURN
    -Oskar

    Post Edited (Oskar Austegard) : 12/8/2003 1:13:37 AM GMT

    Thanks,
    • Post Points: 5
  • 12-08-2003 1:49 AM In reply to

    • ejsmith
    • Top 10 Contributor
    • Joined on 12-27-2002
    • Dallas, TX USA
    • Posts 2,204
    • Points 922,455

    RE: Database HTML Documentation Template

    Oskar,

    There is absolutely support for extended properties on stored procedures and every other SQL Server object as well. Jason and I are actually working to really build out his db documentation templates to include just about everything that SchemaExplorer provides access to. This includes going through Northwind and documenting everything with the MS_Description (this extended property is automatically mapped to the Description property of every schema object by the SqlSchemaProvider) extended property including sprocs, sproc parameters, tables, table columns, views, view columns, etc.

    Thanks,
    Eric J. Smith

    Eric J. Smith
    CodeSmith Tools, LLC
    Chief Software Architect

    • Post Points: 5
  • 12-08-2003 4:18 PM In reply to

    RE: Database HTML Documentation Template

    OK - yeah I guess the syspproperties allows entries for any object with an id (including stored procedures) and "sub- objects" with a smallid/colid (including stored procedure parameters). But is there any easy way to add/edit these properties? I'm primarily looking for a way to add comments, but I can imagine there are many other useful properties (like flags, attributes, etc). Again, I don't know of an easy way to do this using SQL Enterprise manager at least...

    I'm looking forward to whatever you and Jason are coming up with...

    -Oskar
    Thanks,
    • Post Points: 5
  • 12-08-2003 6:31 PM In reply to

    • ejsmith
    • Top 10 Contributor
    • Joined on 12-27-2002
    • Dallas, TX USA
    • Posts 2,204
    • Points 922,455

    RE: Database HTML Documentation Template

    Oskar,

    Enterprise Manager does not allow access to editing these. Query Analyzer will allow you to manage extended properties on pretty much any database object though. Also, I hope to have the ability to manage these extended properties from the Schema Explorer tool window in CodeSmith Studio soon.

    Thanks,
    Eric J. Smith

    Eric J. Smith
    CodeSmith Tools, LLC
    Chief Software Architect

    • Post Points: 5
  • 12-08-2003 7:11 PM In reply to

    • JoeF
    • Top 25 Contributor
    • Joined on 09-28-2003
    • Syracuse, NY
    • Posts 158
    • Points 1,315

    RE: Database HTML Documentation Template

    Jason,
    I just ran it on my DB.
    Very nice!

    Suggestion: can you put the tables in alphabetical order?
    My list came out all jumbled.
     
    Also, can you add the DB name on the header with the Server name?

    Joe
     
    • Post Points: 5
  • 12-08-2003 7:52 PM In reply to

    • jalexander
    • Not Ranked
    • Joined on 08-11-2003
    • Dallas, TX
    • Posts 6
    • Points 675

    RE: Database HTML Documentation Template

    Hey, thanks Joe!
     
     
    Yeah, I'm going to work with Eric on putting in the alpha sort. It's not real easy to do, but Eric's going to help me out with a good solution.
     
    Also, I've done quite a bit of work since the one that's out there. I hope to post an update this week sometime. I'll definitely include the DB name, as well.
     
     
    Thanks for the feedback! I love it!
     
    -Jason
    • Post Points: 5
  • 12-22-2003 8:07 PM In reply to

    • jprice
    • Top 75 Contributor
    • Joined on 05-28-2003
    • Texas
    • Posts 57
    • Points 930

    RE: Database HTML Documentation Template

    Jason,
     
    Such an obvious, but somehow overlooked, use of CodeSmith. Very nice job!
     
    One of our databases has over 200 tables and I wanted to produce documentation for selected tables. So, I made a few modifications (attached):
     
    • Changed the methods to accept TableSchemaCollection rather than DatabaseSchema.
    • Modified the property definitions by adding Optional parameters and cleaned them up for easier readability in design-mode.
    • Made desired # columns a property rather than a const.
    • Wanted to show the owner information of the tables. I didn't make this change as it's probably not as helpful to most people.
    I ended up producing two versions of the template. One for selecting databases, and the other for specific tables of a database.
     
    However, this is a perfect case for the use of sub-templates (as the template methods are the same in both templates). I ultimately wanted to use them, but it currenlty seems to want a full path to a sub-template (Eric, correct me if I'm wrong on that or if there's a way to get the path of the current template to use in calling the sub-template). Anyway, I hesitated doing that because I didn't want to hard-code a path or make a nasty path property on the template (which I've done for several of my own master/sub-templates).
     
    Another option would be to use a include file for all the shared methods... I didn't do that either since it's a pretty simple template as is.
     
    Hope that's helpful for other people.
     
    Once again, nice job!
    • Post Points: 5
  • 12-23-2003 6:51 PM In reply to

    • jprice
    • Top 75 Contributor
    • Joined on 05-28-2003
    • Texas
    • Posts 57
    • Points 930

    RE: Database HTML Documentation Template

    I subsequently see that the columns code doesn't quite work... so it was fruitless to move that parameter to a property.
    • Post Points: 5
  • 12-23-2003 11:53 PM In reply to

    • ejsmith
    • Top 10 Contributor
    • Joined on 12-27-2002
    • Dallas, TX USA
    • Posts 2,204
    • Points 922,455

    RE: Database HTML Documentation Template

    Jason has made a ton of improvements to these templates including fixing the column code. I will talk to him about getting the new version posted.

    Thanks,
    Eric J. Smith

    Eric J. Smith
    CodeSmith Tools, LLC
    Chief Software Architect

    • Post Points: 5
  • 12-29-2003 3:07 AM In reply to

    RE: Database HTML Documentation Template

    Hey Jason ,
    I want you to help me , when I run this template I found this error message as follows.
    System.NullReferenceException: 並未將物件參考設定為物件的執行個體
    at _CodeSmithTemplate.dbdocs_cst.PrintDatabaseDocumentation(DatabaseSchema database)
    at _CodeSmithTemplate.dbdocs_cst.__RenderMethod1(TextWriter writer, Control control)
    at CodeSmith.Engine.DelegateControl.Render(TextWriter writer)
    at CodeSmith.Engine.Control.RenderChildren(TextWriter writer)
    at CodeSmith.Engine.CodeTemplate.Render(TextWriter writer)
    at CodeSmith.Engine.CodeTemplate.RenderToString()
    at CodeSmith.Gui.CodeTemplateGenerator.GenerateCodeButton_Click(Object sender, EventArgs e)

    Had you ever meet this ? and how can I fix it?
    thanks,
    Oliver
    • Post Points: 5
  • 01-03-2004 12:31 AM In reply to

    • Quinton
    • Not Ranked
    • Joined on 01-02-2004
    • Posts 4
    • Points 75

    RE: Database HTML Documentation Template

    Hi Oliver,

    I had the same problem but it resolved when I downloaded CodeSmith 2.5 and ran the same script.

    Quinton
    • Post Points: 5
  • 01-05-2004 8:42 PM In reply to

    • jalexander
    • Not Ranked
    • Joined on 08-11-2003
    • Dallas, TX
    • Posts 6
    • Points 675

    RE: Database HTML Documentation Template

    Ok, Eric finally kicked my butt and made me finish putting the templates together and posted.
     
    Attached are the latest and greatest set of templates for the dbdocumenter templates. As you can see, they've been updated drastically. It now makes extensive use of sub-templates for generating many seperate files for everything. This was to help make sure that these set of documentation are scalable for large databases (such as what Eric and I work with here at Match.com).
     
    Also, I updated the templates so that all properties are read in through the dbdocs_properties.xml file. You simply update your config in this file, and double-click the .bat file and give it a sec to generate.
     
    Grab it! Love it! Let me know of any other ideas, enhancements, etc... that you would like to see. I've also setup a little site for it:
     
     
     
    Thanks!
    -Jason

    Post Edited (Jason Alexander) : 1/6/2004 7:19:11 PM GMT

    • Post Points: 5
  • 01-06-2004 2:22 PM In reply to

    • MAltadonna
    • Top 100 Contributor
    • Joined on 06-13-2003
    • Vermont
    • Posts 49
    • Points 5,395

    RE: Database HTML Documentation Template

    Jason,


    Awesome. Thanks!


    Matt
    • Post Points: 5
  • 01-06-2004 2:27 PM In reply to

    • jalexander
    • Not Ranked
    • Joined on 08-11-2003
    • Dallas, TX
    • Posts 6
    • Points 675

    RE: Database HTML Documentation Template

    Thanks for the good words, everyone! I really appreciate it. Luckily, I had lots of help and support. It's nice when you actually work with Eric and can pester him face-to-face. :)
     
    Some feedback I've got through various avenues:
     
    * table indexes
    * table foreign keys
    * sproc dependency list (sproc, tables)
    * table working set sample (ie, first 15 rows of the table)
     
     
    Thoughts?
     
     
    Thanks!
    -Jason
    • Post Points: 5
Page 1 of 3 (31 items) 1 2 3 Next > | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems