Documentation de référence

Dans l’édition de novembre de MSDN Magazine, Peter Gruenbaum explique comment écrire une bonne documentation de référence pour les APIs dans sont article intitulé “A Coder’s Guide to Writing API Documentation”.

Mon attention s’est particulièrement portée sur la Figure 2 et 3, qui explique comment commenter tout en gardant une homogénéité au travers de tout l’API. Je vous les ai reproduit ici:

Figure 2 Reference Documentation Style

TypeGuidelineExamples
ClassStart with a word like “Represents”“Represents a user’s photo album.”
Methods and functionsStart with a verb“Returns the number of contacts for the specified area.”

“Pauses the video.”
PropertiesUse a noun or start with verbs such as “Gets” or “Gets and sets”“The user’s tasks.”

“Gets and sets a collection of the user’s tasks.”
EventsStart with a phrase such as “Raised when” or “Occurs when”“Raised when the response from server is received.”
XML elementsUse a noun-based phrase“The city’s postal code.”
Boolean valuesFor Boolean properties, start with “Indicates whether”; for Boolean return values on methods and functions, start with “Returns whether”“Indicates whether the control is visible.”

“Returns whether two regions intersect.”

Figure 3 Reference Documentation Example

Class or MemberTypeDescription
Class descriptionClassRepresents a Windows button control.
Button constructorConstructorInitializes a new instance of the <a style=“margin: 0px; cursor: pointer” id=“ctl00_MTContentSelector1_mainContentContainer_ctl05” onclick=“javascript:Track('ctl00_MTContentSelector1_mainContentContainer_ctl00
FocusMethodSets input focus to the control.
VisiblePropertyGets or sets a value indicating whether the control and all its child controls are displayed.
ClickEventOccurs when the control is clicked.

Et cela ne s’applique pas seulement pour les API! Et vous, avez-vous des standards comme celui-ci?


Suggestions de lecture :