jeudi 4 décembre 2014

How to format documentation in MS_Description extendedproperties?


I'm using a 'MS_Description' extended property to document parameters in a stored procedure. This parameter's documentation requires more structure than just plain text. That is I would like to describe: "if value = x, then action A is taken; if value = y, then action B is taken, ...".


What is the best way to store this structure?


The following approaches occured to me:




  • Use html within the 'MS_Description', e.g.



    EXEC sp_addextendedproperty
    @name = N'MS_Description',
    @value = N'
    Selects the foobar. Can have the following values:
    <dl>
    <dt>x</dt><dd>does A</dd>
    <dt>y</dt><dd>does B</dd></dl>'
    @level0type = N'SCHEMA', @level0name = [dbo],
    @level1type = N'PROCEDURE', @level1name = N'SE_DemoProc'
    @level2type = N'PARAMETER', @level2name = N'DemoPar';



    • Would developpers DBAs automatically parse html in their heads?




  • Use visual studio xml document tags the extendedproperty, @value would become:



    @value = N'
    Selects the foobar. Can have the following values:
    <list type="bullet">
    <item><term>x</term><description>does A</description></item>
    <item><term>y</term><description>does B</description></item>
    </list>'




    • Does SSMS, visual studio, and/or other tools interpret Xml document tags in MS_Description extended properties?




    • Does extra semantics of '', '', and '' improve people's understanding more than the html?






  • Use a different extended property to document the values that a parameter excepts?



    • Which property is commonly used for this?


    • How to encode these multiple values?


      As far as I know, an extended property can only occur once for a given (schema, procedure, parameter)-combination.






  • Using newlines, tabs, and '*' to format the plain text will not work since whitespace is collapsed from sql scripts.



    • does escaping newlines and tabs work?




  • Perhaps, I should avoid the mode parameter altogether and split this stored procedure into several distinct precedures. (But that would be a different question and out of scope for this one.)







Aucun commentaire:

Enregistrer un commentaire