Projet

Général

Profil

SOP 001-Programmation » Historique » Version 56

Patrice Nadeau, 2018-03-31 15:25

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