Gabriel Mongeon

Official blog, et sûrement le seul...

Lecture de 2 Minutes

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

Type Guideline Examples
Class Start with a word like “Represents” “Represents a user’s photo album.”
Methods and functions Start with a verb “Returns the number of contacts for the specified area.”“Pauses the video.”
Properties Use 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.”
Events Start with a phrase such as “Raised when” or “Occurs when” “Raised when the response from server is received.”
XML elements Use a noun-based phrase “The city’s postal code.”
Boolean values For 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 Member Type Description
Class description Class Represents a Windows button control.
Button constructor Constructor Initializes a new instance of the <a style=“margin: 0px; cursor: pointer” id=“ctl00_MTContentSelector1_mainContentContainer_ctl05” onclick=“javascript:Track('ctl00_MTContentSelector1_mainContentContainer_ctl00
Focus Method Sets input focus to the control.
Visible Property Gets or sets a value indicating whether the control and all its child controls are displayed.
Click Event Occurs when the control is clicked.

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

Posts Récents