SOP 001-Programmation » Historique » Version 37
Patrice Nadeau, 2018-03-24 17:19
| 1 | 17 | Patrice Nadeau | # SOP 001-Programmation |
|---|---|---|---|
| 2 | 1 | Patrice Nadeau | |
| 3 | Mes standards autant au niveau du style que de la documentation. |
||
| 4 | |||
| 5 | 11 | Patrice Nadeau | La plate-forme (logiciel et matériel) est documenté dans le [[SOP_002-Environnement_informatique]]. |
| 6 | 1 | Patrice Nadeau | |
| 7 | {{lastupdated_at}} {{lastupdated_by}} |
||
| 8 | |||
| 9 | --- |
||
| 10 | |||
| 11 | {{toc}} |
||
| 12 | |||
| 13 | 17 | Patrice Nadeau | ## Diagrammes |
| 14 | 1 | Patrice Nadeau | |
| 15 | Les représentations des différents processus d’un programme ou d’un circuit. |
||
| 16 | |||
| 17 | Les diagrammes DOIVENT être faits avec le logiciel Dia. |
||
| 18 | Ils PEUVENT être exportés en d’autre format. |
||
| 19 | |||
| 20 | 17 | Patrice Nadeau | ### LibreOffice Draw |
| 21 | 14 | Patrice Nadeau | |
| 22 | Icônes : |
||
| 23 | 17 | Patrice Nadeau | |
| 24 | 15 | Patrice Nadeau | * Cisco : http://www.cisco.com/web/about/ac50/ac47/3015_jpeg.zip |
| 25 | 16 | Patrice Nadeau | * http://www.vrt.com.au/downloads/vrt-network-equipment ou http://extensions.libreoffice.org/extension-center/vrt-network-equipment/ |
| 26 | 14 | Patrice Nadeau | |
| 27 | 17 | Patrice Nadeau | ## Système de gestion de version |
| 28 | 1 | Patrice Nadeau | |
| 29 | Le logiciel "Git":http://www.git-scm.com/ DOIT être utilisé. |
||
| 30 | |||
| 31 | La version DOIT être en format: _majeur.mineur.revision_. |
||
| 32 | Les nombres majeur, mineur NE DOIVENT PAS contenir de zéro non significatif et DEVRAIT se limiter à deux chiffres. |
||
| 33 | |||
| 34 | Ex. |
||
| 35 | > Version 1.2.06 |
||
| 36 | |||
| 37 | Les modifications DOIVENT se faire avec _git commit_, de la manière suivante : |
||
| 38 | 17 | Patrice Nadeau | |
| 39 | 1 | Patrice Nadeau | * nom du fichier modifié, |
| 40 | * 1 espace, |
||
| 41 | * nom de l’item modifié entre parenthèses, |
||
| 42 | * un deux- points (<notextile>:</notextile>) sans espace avec l’item précédent, |
||
| 43 | * 1 espace, |
||
| 44 | * le texte du changement en anglais, commençant par une majuscule, au présent, |
||
| 45 | * un point (.) |
||
| 46 | |||
| 47 | Ex. : |
||
| 48 | > Modification ajouté manuellement |
||
| 49 | <pre><code class="bash"> |
||
| 50 | git commit -m "usart.c (usart_Init): Add a new variable ctr." |
||
| 51 | </code></pre> |
||
| 52 | > Modification par un éditeur texte |
||
| 53 | <pre><code class="bash"> |
||
| 54 | git commit |
||
| 55 | </code></pre> |
||
| 56 | |||
| 57 | 17 | Patrice Nadeau | Si les commit sont fait sans l’option **-m**, chaque fichier DOIT être séparé par une ligne vide. |
| 58 | 1 | Patrice Nadeau | |
| 59 | 17 | Patrice Nadeau | ## Code source |
| 60 | 1 | Patrice Nadeau | |
| 61 | Les différents type de langage et de script décrit dans ce SOP. |
||
| 62 | |||
| 63 | 17 | Patrice Nadeau | ### Généralités |
| 64 | 1 | Patrice Nadeau | |
| 65 | 17 | Patrice Nadeau | #### Langue |
| 66 | 1 | Patrice Nadeau | |
| 67 | La langue (macros, variables, fonctions, commentaires, etc...) DOIT être l’anglais. |
||
| 68 | |||
| 69 | 17 | Patrice Nadeau | #### Commentaires |
| 70 | 1 | Patrice Nadeau | |
| 71 | Les commentaires DOIVENT être : |
||
| 72 | 17 | Patrice Nadeau | |
| 73 | 1 | Patrice Nadeau | * sur la ligne précédent l’item à documenter |
| 74 | * en minuscules et commencer par une majuscule |
||
| 75 | |||
| 76 | |||
| 77 | 17 | Patrice Nadeau | #### Nombre magique |
| 78 | 1 | Patrice Nadeau | |
| 79 | 17 | Patrice Nadeau | L’utilisation de [nombre magique](:http://en.wikipedia.org/wiki/Magic_number_%28programming%29#Unnamed_numerical_constants) |
| 80 | ne DOIT PAS être utilisé directement dans le code. |
||
| 81 | 1 | Patrice Nadeau | Il DOIVENT être définis dans une macro ou une variable globale. |
| 82 | |||
| 83 | 17 | Patrice Nadeau | ## C |
| 84 | 1 | Patrice Nadeau | |
| 85 | Le langage C, version C99 (ISO/IEC 9899:1999) utilisé avec le compilateur GCC. |
||
| 86 | |||
| 87 | 17 | Patrice Nadeau | ### Commentaires |
| 88 | 1 | Patrice Nadeau | |
| 89 | Les commentaires ne devant pas être inclus dans une documentation, DOIVENT être de style « C » : |
||
| 90 | |||
| 91 | 25 | Patrice Nadeau | |
| 92 | 17 | Patrice Nadeau | /* Une seule ligne... */ |
| 93 | 1 | Patrice Nadeau | |
| 94 | 17 | Patrice Nadeau | ... |
| 95 | 1 | Patrice Nadeau | |
| 96 | 17 | Patrice Nadeau | /* |
| 97 | * Sur |
||
| 98 | * plusieurs |
||
| 99 | * lignes |
||
| 100 | 1 | Patrice Nadeau | */ |
| 101 | |||
| 102 | 17 | Patrice Nadeau | ### Doxygen |
| 103 | 1 | Patrice Nadeau | |
| 104 | 17 | Patrice Nadeau | Chaque item DOIT être documentés de manière à générer une documentation avec le logiciel [Doxygen](http://www.stack.nl/~dimitri/doxygen/index.html). |
| 105 | 1 | Patrice Nadeau | |
| 106 | Seulement les items définis dans les fichiers d’en-tête sont documentés par défaut. |
||
| 107 | Un commentaire Doxygen commence par *<notextile> /** </notextile>* , le compilateur le comprenant comme un commentaire ordinaire. |
||
| 108 | |||
| 109 | Les règles typographiques du [[SOP_000-Documentation]] s’appliquent : |
||
| 110 | 17 | Patrice Nadeau | |
| 111 | 1 | Patrice Nadeau | * Gras (*@b*) : Items devant être inscrit tel quel. |
| 112 | * Italique & emphase (*@e*) : Items à remplacer par un choix ou nécessitant une attention particulière. |
||
| 113 | |||
| 114 | > Doxygen version ≥ 1.8.8 : Le bogue "737472":https://bugzilla.gnome.org/show_bug.cgi?id=737472 oblige de forcer le langage de la fonction dans l’exemple si on ne veut pas de numéro de ligne. |
||
| 115 | |||
| 116 | Les items DOIVENT être inscrit dans cet ordre : |
||
| 117 | 6 | Patrice Nadeau | |
| 118 | 17 | Patrice Nadeau | /** |
| 119 | * @brief Short description |
||
| 120 | * @param[in,out] var Description. @n Possible values : |
||
| 121 | * − @b value1 |
||
| 122 | * − @b value2 |
||
| 123 | * @return |
||
| 124 | * @retval @b value Description |
||
| 125 | * @par Example : |
||
| 126 | * Example Title |
||
| 127 | * @code{.c} |
||
| 128 | * ... |
||
| 129 | * @endcode |
||
| 130 | * @pre Requirements |
||
| 131 | * @post Changes after the call to this function |
||
| 132 | * @see See also ... |
||
| 133 | * @note |
||
| 134 | * @warning |
||
| 135 | * @bug |
||
| 136 | * @todo |
||
| 137 | 1 | Patrice Nadeau | */ |
| 138 | |||
| 139 | Des *@todo*, *@warning* et *@bug* supplémentaires PEUVENT être ajoutés dans le code. |
||
| 140 | L’item *@brief* DOIT toujours exister. |
||
| 141 | |||
| 142 | 17 | Patrice Nadeau | ### Code |
| 143 | 1 | Patrice Nadeau | |
| 144 | Le code est dans le style K&R, variante 1TBS |
||
| 145 | 17 | Patrice Nadeau | |
| 146 | 1 | Patrice Nadeau | * Le « tab » DOIT être équivalent à 4 espaces. |
| 147 | * Le « backslah » DOIT être utilisé pour les lignes de plus de 80 caractères. |
||
| 148 | * Une instruction par ligne. |
||
| 149 | * Un espace avant et après un opérateur sauf pour les opérateurs « "unary":http://en.wikipedia.org/wiki/Unary_operation ». |
||
| 150 | |||
| 151 | One True Brace Style |
||
| 152 | 25 | Patrice Nadeau | |
| 153 | int fonction (void) |
||
| 154 | 17 | Patrice Nadeau | { |
| 155 | 25 | Patrice Nadeau | int x; |
| 156 | /* the comment goes here, before the loop */ |
||
| 157 | if (var != 1) { |
||
| 158 | x = x + 1; |
||
| 159 | y++; |
||
| 160 | printf("This is a long\ |
||
| 161 | line that should be splitted"); |
||
| 162 | } else { |
||
| 163 | /** @warning this is a Doxygen warning */ |
||
| 164 | x--; |
||
| 165 | } |
||
| 166 | return(0); |
||
| 167 | 17 | Patrice Nadeau | } |
| 168 | |||
| 169 | 1 | Patrice Nadeau | #### Fichier entête |
| 170 | 17 | Patrice Nadeau | |
| 171 | 1 | Patrice Nadeau | Avertissement |
| 172 | >Le gabarit template.h DOIT être utilisé. |
||
| 173 | |||
| 174 | 25 | Patrice Nadeau | Les fichiers « header » DOIVENT contenir les déclarations des fonctions, macros et la partie « mainpage » de Doxygen. |
| 175 | 1 | Patrice Nadeau | |
| 176 | Le nom du fichier DOIT être composé de la manière suivante : |
||
| 177 | |||
| 178 | 17 | Patrice Nadeau | * en minuscule |
| 179 | 1 | Patrice Nadeau | * 8 caractères maximum |
| 180 | * l’extension DOIT être *.h* |
||
| 181 | |||
| 182 | Une définition macro DOIT être faite pour éviter de ré-inclure le fichier. |
||
| 183 | La macro DOIT être dans le format *_fichier_h* |
||
| 184 | 25 | Patrice Nadeau | |
| 185 | #ifndef _usart_h |
||
| 186 | #define _usart_h |
||
| 187 | 1 | Patrice Nadeau | ... |
| 188 | 25 | Patrice Nadeau | #endif /*_usart.h*/ |
| 189 | 1 | Patrice Nadeau | |
| 190 | 25 | Patrice Nadeau | |
| 191 | 1 | Patrice Nadeau | #### Fichier source |
| 192 | 17 | Patrice Nadeau | |
| 193 | 1 | Patrice Nadeau | Le nom du fichier DOIT être composé de la manière suivante : |
| 194 | 25 | Patrice Nadeau | |
| 195 | 1 | Patrice Nadeau | * en minuscule |
| 196 | * 8 caractères maximum |
||
| 197 | * l’extension DOIT être *.c* |
||
| 198 | |||
| 199 | 17 | Patrice Nadeau | #### Librairies |
| 200 | 1 | Patrice Nadeau | |
| 201 | Fichiers comprenant plusieurs déclarations et définitions reliés entre eux. |
||
| 202 | |||
| 203 | * Le nom DOIT respecter les standards ([[SOP_001-Programmation#Fichiers-Entêtes|1]] & [[SOP_001-Programmation#Fichiers-Sources|2]]) et être significatifs. |
||
| 204 | * Un fichier d’entête DOIT toujours exister. |
||
| 205 | * Les items sont précédés du nom de la librairie (minuscule) et séparés par un « underscore » (_). |
||
| 206 | |||
| 207 | L’utilisation de macros DOIT être utilisé au lieu de constates globales. |
||
| 208 | Il NE DEVRAIT PAS exister de de variables globales. |
||
| 209 | |||
| 210 | #### Déclarations locales |
||
| 211 | 17 | Patrice Nadeau | |
| 212 | 1 | Patrice Nadeau | Une déclaration n’ayant qu’une visibilité locale DOIT être précédé d’un « underscore » (_) et être de classe *static*. |
| 213 | |||
| 214 | |||
| 215 | 25 | Patrice Nadeau | /** |
| 216 | * @brief Local function |
||
| 217 | **/ |
||
| 218 | static void _LocalFunc(void) |
||
| 219 | { |
||
| 220 | ... |
||
| 221 | return; |
||
| 222 | } |
||
| 223 | |||
| 224 | 1 | Patrice Nadeau | #### Items désuets |
| 225 | 17 | Patrice Nadeau | |
| 226 | 1 | Patrice Nadeau | Les déclarations ne devant plus être utilisés, DOIVENT générer un message lors de la compilation (*-Wall*) si un appel est effectué. |
| 227 | |||
| 228 | 27 | Patrice Nadeau | L’attribut ** __attribute__((deprecated)) ** DOIT être ajouté à la déclaration. |
| 229 | 1 | Patrice Nadeau | La documentation DOIT indiquer les substituts à utiliser. |
| 230 | |||
| 231 | 25 | Patrice Nadeau | /** |
| 232 | * @brief OldFunction |
||
| 233 | * @detail will generate a warning if used |
||
| 234 | * @see @b NewFunction |
||
| 235 | */ |
||
| 236 | int OldFunction(void) __attribute__((deprecated)); |
||
| 237 | |||
| 238 | 1 | Patrice Nadeau | #### Constantes |
| 239 | 17 | Patrice Nadeau | |
| 240 | 1 | Patrice Nadeau | La déclaration DOIT inclure aussi la définition. |
| 241 | |||
| 242 | Utilisé au lieu d’une macro quand le type ou la visibilité de la variable doit être définis. |
||
| 243 | 25 | Patrice Nadeau | |
| 244 | 1 | Patrice Nadeau | * En majuscule |
| 245 | * Séparé par un «underscore» (_) si contient plusieurs mots |
||
| 246 | * De classe _static_ ou _extern_ selon le besoin |
||
| 247 | |||
| 248 | 29 | Patrice Nadeau | Ex. : |
| 249 | |||
| 250 | 26 | Patrice Nadeau | /** |
| 251 | * @name List of constants |
||
| 252 | * @{ |
||
| 253 | */ |
||
| 254 | 1 | Patrice Nadeau | |
| 255 | 26 | Patrice Nadeau | /** |
| 256 | * @brief Local const |
||
| 257 | */ |
||
| 258 | static int _PI = 3.15; |
||
| 259 | /** |
||
| 260 | * @brief The initialization string of the project |
||
| 261 | */ |
||
| 262 | static const char INIT_STR[6] = {'P', 'O', 'W', 'E', 'R'}; |
||
| 263 | /** |
||
| 264 | * @brief Global const in the random library |
||
| 265 | */ |
||
| 266 | extern int random_MAX = 25; |
||
| 267 | 1 | Patrice Nadeau | |
| 268 | 26 | Patrice Nadeau | /** |
| 269 | 1 | Patrice Nadeau | * @} |
| 270 | 28 | Patrice Nadeau | */ |
| 271 | 12 | Patrice Nadeau | |
| 272 | 17 | Patrice Nadeau | #### Typedef |
| 273 | 12 | Patrice Nadeau | |
| 274 | 30 | Patrice Nadeau | Format : |
| 275 | |||
| 276 | 12 | Patrice Nadeau | * En minuscule, suivie de *_t* |
| 277 | 1 | Patrice Nadeau | |
| 278 | 12 | Patrice Nadeau | Définition de typedef |
| 279 | 30 | Patrice Nadeau | |
| 280 | /** Unsigned integer 8 bits */ |
||
| 281 | typedef unsigned int new_t |
||
| 282 | /** Type of structure in the ds1305 library */ |
||
| 283 | typedef struct { |
||
| 284 | 31 | Patrice Nadeau | /** @brief last two digits : ≥ 00, ≤ 99 */ |
| 285 | uint8_t year; |
||
| 286 | /** @brief 01 - 12 */ |
||
| 287 | uint8_t month; |
||
| 288 | /** @brief 01 - 31 */ |
||
| 289 | uint8_t date; |
||
| 290 | /** @brief 1 - 7 */ |
||
| 291 | uint8_t day; |
||
| 292 | /** @brief 00 - 23 */ |
||
| 293 | uint8_t hours; |
||
| 294 | /** @brief 00 - 59 */ |
||
| 295 | uint8_t minutes; |
||
| 296 | /** @brief 00 - 59 */ |
||
| 297 | uint8_t seconds; |
||
| 298 | 30 | Patrice Nadeau | } ds1305_time_t; |
| 299 | 1 | Patrice Nadeau | |
| 300 | 17 | Patrice Nadeau | #### Variables |
| 301 | 1 | Patrice Nadeau | |
| 302 | Format |
||
| 303 | * En minuscule. |
||
| 304 | * Séparé par un « underscore » (_) si contient plusieurs mots. |
||
| 305 | |||
| 306 | Définition de variables |
||
| 307 | <pre><code class="c"> |
||
| 308 | /** @brief Local variable */ |
||
| 309 | int _ctr; |
||
| 310 | /** @brief Global variable from the random librairy */ |
||
| 311 | int random_ctr; |
||
| 312 | </code></pre> |
||
| 313 | |||
| 314 | 17 | Patrice Nadeau | #### Structures |
| 315 | 1 | Patrice Nadeau | |
| 316 | Format |
||
| 317 | * En minuscule, séparé par des «underscores» si nécessaire. |
||
| 318 | |||
| 319 | Définition de structures |
||
| 320 | <pre><code class="c"> |
||
| 321 | /** |
||
| 322 | * @brief Structure for a local menu |
||
| 323 | * @see MenuSelect |
||
| 324 | */ |
||
| 325 | struct menu { |
||
| 326 | /** @brief Character used for the item */ |
||
| 327 | char choice; |
||
| 328 | /** @brief Description of the item */ |
||
| 329 | char *item; |
||
| 330 | }; |
||
| 331 | </code></pre> |
||
| 332 | |||
| 333 | 17 | Patrice Nadeau | #### Fonctions |
| 334 | 1 | Patrice Nadeau | |
| 335 | Le nom est formé d’une lettre majuscule pour chacune des premières lettres des mots. |
||
| 336 | 5 | Patrice Nadeau | |
| 337 | Le nom DOIT être dans un deux formats suivants : |
||
| 338 | 32 | Patrice Nadeau | |
| 339 | 5 | Patrice Nadeau | * ActionItemAttribut, où _Action_ signifie : |
| 340 | 1 | Patrice Nadeau | ** *Get* : Lis un registre |
| 341 | 5 | Patrice Nadeau | ** *Read*, *Write* : Lis ou écris dans un fichier |
| 342 | 1 | Patrice Nadeau | ** *Set* : Écris une valeur prédéfini dans un registre |
| 343 | ** *Init* : Fonction d’initialisation |
||
| 344 | * isItemEtat |
||
| 345 | ** *is* : Verifie si _Item_ est dans l’état _Etat_ |
||
| 346 | |||
| 347 | Exception |
||
| 348 | > Les fonctions définies dans une librairie de bas niveau pour du matériel (« driver »). Dans ce cas, le nom définis dans le « datasheet » aura préséance. Ex. ReadRegister. |
||
| 349 | |||
| 350 | Une fonction DEVRAIT retourner une valeur. |
||
| 351 | |||
| 352 | Dans le cas d'un « oui/non », la valeur DOIT être : |
||
| 353 | |||
| 354 | 32 | Patrice Nadeau | * Succès : **0** |
| 355 | * Erreur : **1** |
||
| 356 | |||
| 357 | > L'utilisation d'un type booléen (*true* & *false*) est permise avec **<stbool.h>** (C99). |
||
| 358 | |||
| 359 | 1 | Patrice Nadeau | Dans le cas d'une fonction retournant un pointeur : |
| 360 | |||
| 361 | 32 | Patrice Nadeau | * Erreur : **NULL** |
| 362 | * Autre valeur : adresse du pointeur |
||
| 363 | 1 | Patrice Nadeau | |
| 364 | 32 | Patrice Nadeau | |
| 365 | 1 | Patrice Nadeau | Définition de fonctions |
| 366 | 32 | Patrice Nadeau | |
| 367 | /** |
||
| 368 | * @brief Check if a timer is set |
||
| 369 | * @param[in] nb Timer number. @n Possible values : |
||
| 370 | * − @b TIMER_1 |
||
| 371 | * − @b TIMER_2 |
||
| 372 | * @return |
||
| 373 | * @retval true Timer @e nb is set |
||
| 374 | * @retval false Timer @e nb is NOT set |
||
| 375 | * @par Example : |
||
| 376 | * Check if the timer is set |
||
| 377 | * @code{.c} |
||
| 378 | * ... |
||
| 379 | * result = isTimerSet(); |
||
| 380 | * ... |
||
| 381 | * @endcode |
||
| 382 | * @pre TimerInit |
||
| 383 | **/ |
||
| 384 | static bool isTimerSet(uint8_t nb); |
||
| 385 | /** |
||
| 386 | * @brief Set the led to green |
||
| 387 | **/ |
||
| 388 | SetLedColor(GREEN); |
||
| 389 | /** |
||
| 390 | * @brief Set register of the chip XYZ |
||
| 391 | * |
||
| 392 | * The name does not follow the standards but does match the datatsheet |
||
| 393 | * This is a local function not meant to be called outside this librairy |
||
| 394 | **/ |
||
| 395 | static void _WriteReg(void); |
||
| 396 | |||
| 397 | 1 | Patrice Nadeau | |
| 398 | ### Macros |
||
| 399 | |||
| 400 | Les directives du préprocesseur C. |
||
| 401 | |||
| 402 | * Utilisé dans le code source et les fichiers entête. |
||
| 403 | 17 | Patrice Nadeau | * DOIT toujours commencer à la colonne 0. |
| 404 | 1 | Patrice Nadeau | |
| 405 | #### include |
||
| 406 | |||
| 407 | Pour inclure d’autres fichier comme les fichiers entête. |
||
| 408 | 23 | Patrice Nadeau | >N’est pas documenté dans Doxygen. |
| 409 | 1 | Patrice Nadeau | |
| 410 | #### ifdef / ifndef |
||
| 411 | |||
| 412 | Surtout utiliser pour des options de compilation sur différentes plateforme. |
||
| 413 | 23 | Patrice Nadeau | >N’est pas documenté dans Doxygen. |
| 414 | |||
| 415 | |||
| 416 | 1 | Patrice Nadeau | |
| 417 | |||
| 418 | #ifndef usart_AVR |
||
| 419 | 24 | Patrice Nadeau | #error "usart.h is not supported on this AVR !" |
| 420 | |||
| 421 | #endif |
||
| 422 | 17 | Patrice Nadeau | |
| 423 | 1 | Patrice Nadeau | |
| 424 | #### error |
||
| 425 | |||
| 426 | Affiche une erreur et arrête la compilation |
||
| 427 | 24 | Patrice Nadeau | >N’est pas documenté dans Doxygen. |
| 428 | |||
| 429 | 34 | Patrice Nadeau | #ifndef __test__ |
| 430 | 33 | Patrice Nadeau | |
| 431 | 34 | Patrice Nadeau | #error "Error !" |
| 432 | 33 | Patrice Nadeau | |
| 433 | 37 | Patrice Nadeau | #endif |
| 434 | 1 | Patrice Nadeau | |
| 435 | #### #warning |
||
| 436 | |||
| 437 | Affiche une erreur mais n’arrête la compilation |
||
| 438 | >N’est pas documenté dans Doxygen. |
||
| 439 | |||
| 440 | 36 | Patrice Nadeau | #ifndef __test__ |
| 441 | 1 | Patrice Nadeau | |
| 442 | #warning "Warning !" |
||
| 443 | #endif |
||
| 444 | 17 | Patrice Nadeau | </code></pre> |
| 445 | 1 | Patrice Nadeau | |
| 446 | #### define |
||
| 447 | |||
| 448 | Définis une valeur au moment de la compilation. |
||
| 449 | * Format |
||
| 450 | ** En majuscule. |
||
| 451 | ** Séparé par un «underscore» si contient plusieurs mots. |
||
| 452 | * Doxygen |
||
| 453 | ** @brief |
||
| 454 | ** @name pour les listes de macros (regroupement dans la documentation) |
||
| 455 | |||
| 456 | Définition de macros |
||
| 457 | <pre><code class="c"> |
||
| 458 | /** |
||
| 459 | * @name Mathematical macros listed together |
||
| 460 | * @{ |
||
| 461 | */ |
||
| 462 | /** @brief Value for PI */ |
||
| 463 | #define _PI 3.14 |
||
| 464 | /** @brief Another number */ |
||
| 465 | #define _MAGIC_NUMBER 42 |
||
| 466 | /** |
||
| 467 | * @} |
||
| 468 | 21 | Patrice Nadeau | */ |
| 469 | 22 | Patrice Nadeau | /** @brief Even parity */ |
| 470 | 1 | Patrice Nadeau | |
| 471 | 22 | Patrice Nadeau | #define usart_PARITY_EVEN 'e' |
| 472 | 17 | Patrice Nadeau | |
| 473 | 1 | Patrice Nadeau | |
| 474 | ### Atmel AVR |
||
| 475 | |||
| 476 | 3 | Patrice Nadeau | Particularités pour les micro-contrôleurs AVR d’Atmel. |
| 477 | 1 | Patrice Nadeau | |
| 478 | * Progmem : Pour mettre une fonction en Flash au lieu de SRAM. |
||
| 479 | ** Le nom de la fonction est suivie de *_P*. |
||
| 480 | * main : Ne revient jamais à un niveau supérieur. |
||
| 481 | ** Définir la fonction main avec l’attribut *noreturn*. |
||
| 482 | ** La boucle sans fin la plus optimisé est le *for (;;)*. |
||
| 483 | * Atomic : Opérations ne devant pas être interrompus. |
||
| 484 | |||
| 485 | 22 | Patrice Nadeau | Particularités pour AVR |
| 486 | |||
| 487 | /** |
||
| 488 | * @brief Progmem function |
||
| 489 | * @return An unsigned 8 bits integer |
||
| 490 | 1 | Patrice Nadeau | */ |
| 491 | 22 | Patrice Nadeau | uint_8t PrintString_P() |
| 492 | |||
| 493 | /* main function */ |
||
| 494 | void main(void) __atribute__((noreturn)) |
||
| 495 | { |
||
| 496 | ... |
||
| 497 | /* never return */ |
||
| 498 | 1 | Patrice Nadeau | for (;;) { |
| 499 | } |
||
| 500 | 22 | Patrice Nadeau | } |
| 501 | 21 | Patrice Nadeau | |
| 502 | 1 | Patrice Nadeau | /* atomic operations */ |
| 503 | |||
| 504 | #ifndef S_SPLINT_S |
||
| 505 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
||
| 506 | /* |
||
| 507 | * operations that must not be interupted |
||
| 508 | * like loading a 16 bit register with a 8 bit register |
||
| 509 | */ |
||
| 510 | 18 | Patrice Nadeau | } |
| 511 | |||
| 512 | #endif |
||
| 513 | 1 | Patrice Nadeau | |
| 514 | 17 | Patrice Nadeau | |
| 515 | 18 | Patrice Nadeau | ### Distribution |
| 516 | |||
| 517 | 1 | Patrice Nadeau | Les fichiers suivants DOIVENT être inclus dans une distribution en format *tar.gz* : |
| 518 | |||
| 519 | * ChangeLog |
||
| 520 | * README |
||
| 521 | * Files.lst |
||
| 522 | * Makefile |
||
| 523 | * Makefile.mk |
||
| 524 | * LICENSE.txt |
||
| 525 | * *.c |
||
| 526 | * *.h |
||
| 527 | * projet.pdf (généré par Doxygen) |
||
| 528 | |||
| 529 | 18 | Patrice Nadeau | Avec mon makefile : |
| 530 | |||
| 531 | 1 | Patrice Nadeau | make dist |
| 532 | |||
| 533 | ### Modifications |
||
| 534 | |||
| 535 | Un changement à un fichier (source ou en-tête), doit se refléter dans _Git_. |
||
| 536 | |||
| 537 | 18 | Patrice Nadeau | Chaque changement est fait avec : |
| 538 | |||
| 539 | git add nom_fichier |
||
| 540 | 1 | Patrice Nadeau | git commit |
| 541 | 18 | Patrice Nadeau | |
| 542 | 1 | Patrice Nadeau | La ligne DOIT |
| 543 | |||
| 544 | * être au temps présent |
||
| 545 | * être en anglais |
||
| 546 | 18 | Patrice Nadeau | * se termine par un point |
| 547 | 1 | Patrice Nadeau | * être dans le format suivant : |
| 548 | > La partie _section_ est facultative |
||
| 549 | 18 | Patrice Nadeau | |
| 550 | |||
| 551 | fichier1 (fonction) <section>: |
||
| 552 | Ajoute une description au temps présent. |
||
| 553 | Décrire les bogues réglés si il y en avaient. |
||
| 554 | 17 | Patrice Nadeau | |
| 555 | 1 | Patrice Nadeau | |
| 556 | ### Changelog |
||
| 557 | |||
| 558 | La somme de toutes les modification doivent apparaitre dans un fichier « changelog ». |
||
| 559 | 18 | Patrice Nadeau | > Le standard seras celui GNU : http://www.gnu.org/prep/standards/html_node/Change-Logs.html#Change-Logs |
| 560 | 1 | Patrice Nadeau | |
| 561 | 18 | Patrice Nadeau | Ce fichier doit s'appeler **ChangeLog** et DOIT être généré à partir de _Git_ (les doubles espaces ne sont pas une erreur de frappe : |
| 562 | |||
| 563 | 1 | Patrice Nadeau | git log --no-merges --format="%ad %an <%aE> %n * %B" --date=short > ChangeLog |
| 564 | |||
| 565 | 17 | Patrice Nadeau | ### Validation du code |
| 566 | 18 | Patrice Nadeau | |
| 567 | 1 | Patrice Nadeau | Le logiciel _splint_ est utilisé. |
| 568 | |||
| 569 | * Un « typecast » DOIT être utilisé lorsque détecté. |
||
| 570 | * L’utilisation du typecast *void* DOIT être utilisé lorsque qu’une fonction retourne un résultat non utilisé. |
||
| 571 | |||
| 572 | 17 | Patrice Nadeau | ## Makefile |
| 573 | 1 | Patrice Nadeau | |
| 574 | 17 | Patrice Nadeau | ## Nagios |
| 575 | 1 | Patrice Nadeau | |
| 576 | 17 | Patrice Nadeau | ### Plugins |
| 577 | 1 | Patrice Nadeau | |
| 578 | https://nagios-plugins.org/doc/guidelines.html |
||
| 579 | |||
| 580 | Un message d'une ligne (< 80 caractères) DOIT être retourné via _STDOUT_ dans le format |
||
| 581 | 18 | Patrice Nadeau | > *SERVICE STATUS:* texte |
| 582 | |||
| 583 | 1 | Patrice Nadeau | Les codes de retour sont les suivants : |
| 584 | |||
| 585 | |_. Valeur |_. Service Status |_. Description | |
||
| 586 | | 0 | OK | Le service fonctionne | |
||
| 587 | | 1 | Warning | Le service fonctionne, problème avec le seuil de la valeur _Warning_ | |
||
| 588 | | 2 | Critical | Le service ne fonctionne pas ou problème avec le seuil de la valeur _Critical_ | |
||
| 589 | 18 | Patrice Nadeau | | 3 | Unknow | Arguments non valides ou erreur interne (fork, tcp socket)| |
| 590 | |||
| 591 | 1 | Patrice Nadeau | Les arguments suivants DOIVENT être fournis : |
| 592 | |||
| 593 | * *-H* (*--hostname*) : |
||
| 594 | * *-w* (*--warning*) : |
||
| 595 | * *-c* (*--critical*) : |
||
| 596 | * *-V* (*--version*) : |
||
| 597 | * *-h* (*--help*) : |
||
| 598 | |||
| 599 | L'argument _--help_ DOIT aussi appeler l'argument _--version_. |
||
| 600 | 18 | Patrice Nadeau | |
| 601 | 1 | Patrice Nadeau | En _C_, les fonctions suivantes DOIT être utilisées : |
| 602 | 17 | Patrice Nadeau | |
| 603 | 1 | Patrice Nadeau | * _print_revision_ (utils.c) |
| 604 | * _print_help_ |
||
| 605 | * _getopt_long_ (getopt.h) |
||
| 606 | |||
| 607 | ## Puppet |
||
| 608 | |||
| 609 | ### Généralités |
||
| 610 | 18 | Patrice Nadeau | |
| 611 | 1 | Patrice Nadeau | Inspiré des recommandations disponible au http://docs.puppetlabs.com/guides/style_guide.html. |
| 612 | 18 | Patrice Nadeau | |
| 613 | 1 | Patrice Nadeau | * Tabulation : 2 espaces |
| 614 | * Largeur : 80 caractères (« backslah » (\) pour séparer une longue ligne). |
||
| 615 | 18 | Patrice Nadeau | * Commentaires : Style # |
| 616 | * Guillemets |
||
| 617 | * Simple : Pour une « string » sans variables. |
||
| 618 | 1 | Patrice Nadeau | * Double : Pour une « string » avec variables ayant besoin d’être extrapolé. |
| 619 | * La variable doit être entourée des symboles *<notextile>{</notextile>* et *<notextile>}</notextile>*. |
||
| 620 | * Nom des ressources : DOIVENT être entouré du symbole *<notextile> ’ </notextile>*. |
||
| 621 | * Alignement de => : DOIT être aligné dans un même paragraphe. |
||
| 622 | * Ordre : Si l’attribut _ensure_ doit être inclus, il DOIT être le premier. |
||
| 623 | * Lien symbolique : DOIT être déclaré avec *ensure => link* |
||
| 624 | |||
| 625 | 18 | Patrice Nadeau | Ex. : |
| 626 | |||
| 627 | file { '/var/log/syslog': |
||
| 628 | ensure => link, |
||
| 629 | target => '/var/log/messages', |
||
| 630 | 1 | Patrice Nadeau | } |
| 631 | 18 | Patrice Nadeau | |
| 632 | * File mode : |
||
| 633 | 17 | Patrice Nadeau | * 4 chiffres |
| 634 | 18 | Patrice Nadeau | * simple guillemet |
| 635 | * Variables |
||
| 636 | * lettres |
||
| 637 | 1 | Patrice Nadeau | * chiffres |
| 638 | * « underscore » |
||
| 639 | |||
| 640 | ### Documentation |
||
| 641 | |||
| 642 | 18 | Patrice Nadeau | http://docs.puppetlabs.com/learning/modules2.html#module-documentation |
| 643 | |||
| 644 | 1 | Patrice Nadeau | Format Rdoc (http://rdoc.rubyforge.org/RDoc/Markup.html) : |
| 645 | |||
| 646 | * Bloc de commentaires qui commence sur la première ligne du fichier |
||
| 647 | * Titre avec le symbole *<notextile>=</notextile>* |
||
| 648 | 18 | Patrice Nadeau | * Séparation avec le symbole *<notextile>-</notextile>* |
| 649 | * Emphase (mot entouré du symbole) |
||
| 650 | * * : gras |
||
| 651 | 1 | Patrice Nadeau | * _ : souligné |
| 652 | 18 | Patrice Nadeau | * + : Police de caractères pour le code |
| 653 | * Sections |
||
| 654 | * = Class: |
||
| 655 | * == Parameters: |
||
| 656 | 1 | Patrice Nadeau | * == Requires: |
| 657 | 18 | Patrice Nadeau | * == Sample Usage: |
| 658 | 1 | Patrice Nadeau | * Classe |
| 659 | * Une classe par fichier « manifest » |
||
| 660 | |||
| 661 | ## Script |
||
| 662 | |||
| 663 | 18 | Patrice Nadeau | ### Bash |
| 664 | |||
| 665 | 1 | Patrice Nadeau | |
| 666 | |||
| 667 | #/bin/bash |
||
| 668 | 17 | Patrice Nadeau | |
| 669 | 1 | Patrice Nadeau | function print_revision { |
| 670 | } |
||
| 671 | |||
| 672 | function print_help { |
||
| 673 | print_revision |
||
| 674 | 17 | Patrice Nadeau | } |
| 675 | 1 | Patrice Nadeau | </code></pre> |
| 676 | |||
| 677 | 17 | Patrice Nadeau | ### Perl |
| 678 | 1 | Patrice Nadeau | |
| 679 | <pre><code class="perl"> |
||
| 680 | |||
| 681 | </code></pre> |
||
| 682 | |||
| 683 | ### PowerShell |
||
| 684 | 17 | Patrice Nadeau | |
| 685 | 1 | Patrice Nadeau | Version 4.0. Supporte : |
| 686 | 17 | Patrice Nadeau | |
| 687 | 1 | Patrice Nadeau | * Windows 8.1 (natif) |
| 688 | * Windows Server 2012 R2 (natif) |
||
| 689 | * Windows 7 SP1 |
||
| 690 | 17 | Patrice Nadeau | * Windows Server 2008 R2 SP1 |
| 691 | 1 | Patrice Nadeau | * Windows Server 2012 |
| 692 | |||
| 693 | #### Fichier |
||
| 694 | |||
| 695 | Le fichier DOIT être composé de la manière suivante :<F8> |
||
| 696 | * L’extension est .ps1 |
||
| 697 | * Une longue ligne peux être séparée avec un « back tick » (‘). |
||
| 698 | |||
| 699 | #### Commentaires |
||
| 700 | |||
| 701 | 20 | Patrice Nadeau | L’aide est accéder par _Get-Help_ |
| 702 | |||
| 703 | |||
| 704 | #REQUIRES -Version 2.0 |
||
| 705 | <# |
||
| 706 | .SYNOPSIS |
||
| 707 | A brief description of the function or script. |
||
| 708 | This keyword can be used only once in each topic. |
||
| 709 | .DESCRIPTION |
||
| 710 | A detailed description of the function or script. |
||
| 711 | This keyword can be used only once in each topic. |
||
| 712 | .NOTES |
||
| 713 | File Name |
||
| 714 | : xxxx.ps1 |
||
| 715 | Author |
||
| 716 | : |
||
| 717 | Prerequisite |
||
| 718 | : PowerShell V2 over Vista and upper. |
||
| 719 | Copyright 2011 - |
||
| 720 | .LINK |
||
| 721 | Script posted over: |
||
| 722 | http:// |
||
| 723 | .EXAMPLE |
||
| 724 | Example 1 |
||
| 725 | .EXAMPLE |
||
| 726 | Example 2 |
||
| 727 | #> |
||
| 728 | |||
| 729 | 1 | Patrice Nadeau | |
| 730 | |||
| 731 | ## Vim |
||
| 732 | 19 | Patrice Nadeau | |
| 733 | * Entête (en commentaires) |
||
| 734 | * Titre |
||
| 735 | * Last Change: |
||
| 736 | 1 | Patrice Nadeau | * Maintainer: |
| 737 | 19 | Patrice Nadeau | * License: This file is placed in the public domain. |
| 738 | * Autre mots reconnus |
||
| 739 | * BUG: (Error:) |
||
| 740 | * TODO: |
||
| 741 | 1 | Patrice Nadeau | * Note: |
| 742 | * FIXME |
||
| 743 | |||
| 744 | ## Références |
||
| 745 | |||
| 746 | 20 | Patrice Nadeau | Références ayant servis à ce document. |
| 747 | 19 | Patrice Nadeau | |
| 748 | 1 | Patrice Nadeau | [ChangeLog](http://www.gnu.org/prep/standards/html_node/Change-Logs.html#Change-Logs) |
| 749 | [GNU deprecated attribute](http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Type-Attributes.html) |