Projet

Général

Profil

SOP 001-Programmation » Historique » Version 55

Patrice Nadeau, 2018-03-31 15:23

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
    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 46 Patrice Nadeau
>Le gabarit **template.h** DOIT être utilisé.
173 1 Patrice Nadeau
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 47 Patrice Nadeau
* l’extension DOIT être **.h**
181 1 Patrice Nadeau
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
    #endif /*_usart.h*/
189 25 Patrice Nadeau
190 1 Patrice Nadeau
#### Fichier source
191 17 Patrice Nadeau
192 1 Patrice Nadeau
Le nom du fichier DOIT être composé de la manière suivante :
193 25 Patrice Nadeau
194 1 Patrice Nadeau
* en minuscule
195
* 8 caractères maximum
196
* l’extension DOIT être *.c*
197
198 17 Patrice Nadeau
#### Librairies
199 1 Patrice Nadeau
200
Fichiers comprenant plusieurs déclarations et définitions reliés entre eux.
201
202
* Le nom DOIT respecter les standards ([[SOP_001-Programmation#Fichiers-Entêtes|1]] & [[SOP_001-Programmation#Fichiers-Sources|2]]) et être significatifs.
203
* Un fichier d’entête DOIT toujours exister.
204
* Les items sont précédés du nom de la librairie (minuscule) et séparés par un « underscore » (_).
205
206
L’utilisation de macros DOIT être utilisé au lieu de constates globales.
207
Il NE DEVRAIT PAS exister de de variables globales.
208
209
#### Déclarations locales
210 17 Patrice Nadeau
211 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*.
212
213
214 25 Patrice Nadeau
    /**
215
    * @brief Local function
216
    **/
217
    static void _LocalFunc(void)
218
    {
219
        ...
220
        return;
221
    }
222
223 1 Patrice Nadeau
#### Items désuets
224 17 Patrice Nadeau
225 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é.
226
227 48 Patrice Nadeau
L’attribut **__attribute\_\_((deprecated))** DOIT être ajouté à la déclaration.
228 1 Patrice Nadeau
La documentation DOIT indiquer les substituts à utiliser.
229
230 25 Patrice Nadeau
    /**
231
    * @brief OldFunction
232
    * @detail will generate a warning if used
233
    * @see @b NewFunction
234
    */
235
    int OldFunction(void) __attribute__((deprecated));
236
237 1 Patrice Nadeau
#### Constantes
238 17 Patrice Nadeau
239 1 Patrice Nadeau
La déclaration DOIT inclure aussi la définition.
240
241
Utilisé au lieu d’une macro quand le type ou la visibilité de la variable doit être définis.
242 25 Patrice Nadeau
243 1 Patrice Nadeau
* En majuscule
244
* Séparé par un «underscore» (_) si contient plusieurs mots
245
* De classe _static_ ou _extern_ selon le besoin
246
247 29 Patrice Nadeau
Ex. :
248
249 26 Patrice Nadeau
    /** 
250
     * @name List of constants
251
     * @{
252
     */
253 1 Patrice Nadeau
254 26 Patrice Nadeau
    /**
255
    * @brief Local const
256
    */
257
    static int _PI = 3.15;
258
    /**
259
    * @brief The initialization string of the project
260
    */
261
    static const char INIT_STR[6] = {'P', 'O', 'W', 'E', 'R'};
262
    /**
263
    * @brief Global const in the random library
264
    */
265
    extern int random_MAX = 25;
266 1 Patrice Nadeau
267 26 Patrice Nadeau
    /**
268 1 Patrice Nadeau
     * @}
269 28 Patrice Nadeau
     */
270 12 Patrice Nadeau
271 17 Patrice Nadeau
#### Typedef
272 12 Patrice Nadeau
273 30 Patrice Nadeau
Format :
274
275 12 Patrice Nadeau
* En minuscule, suivie de *_t*
276 1 Patrice Nadeau
277 12 Patrice Nadeau
Définition de typedef
278 30 Patrice Nadeau
279
    /** Unsigned integer 8 bits */
280
    typedef unsigned int new_t
281
    /** Type of structure in the ds1305 library */
282
    typedef struct {
283 31 Patrice Nadeau
        /** @brief last two digits : &ge; 00, &le; 99 */
284
        uint8_t year;
285
    	/** @brief 01 - 12 */
286
        uint8_t month;
287
        /** @brief 01 - 31 */
288
        uint8_t date;
289
        /** @brief 1 - 7 */
290
        uint8_t day;
291
    	/** @brief 00 - 23 */
292
        uint8_t hours;
293
        /** @brief 00 - 59 */
294
        uint8_t minutes;
295
        /** @brief 00 - 59 */
296
        uint8_t seconds;
297 30 Patrice Nadeau
    } ds1305_time_t;
298 1 Patrice Nadeau
299
#### Variables
300
301 49 Patrice Nadeau
Format :
302
303 1 Patrice Nadeau
* En minuscule.
304
* Séparé par un « underscore » (_) si contient plusieurs mots.
305
306
Définition de variables
307
308 40 Patrice Nadeau
    /** @brief Local variable */
309
    int _ctr;
310
    /** @brief Global variable from the random librairy */
311
    int random_ctr;
312
313 1 Patrice Nadeau
#### Structures
314
315
Format
316
* En minuscule, séparé par des «underscores» si nécessaire.
317
318
Définition de structures
319
320 40 Patrice Nadeau
    /**
321
    * @brief Structure for a local menu
322
    * @see MenuSelect
323
    */
324
    struct menu {
325
    /** @brief Character used for the item */
326
    char choice;
327
    /** @brief Description of the item */
328
    char *item;
329
    };
330
331 17 Patrice Nadeau
#### Fonctions
332 1 Patrice Nadeau
333
Le nom est formé d’une lettre majuscule pour chacune des premières lettres des mots.
334 5 Patrice Nadeau
335
Le nom DOIT être dans un deux formats suivants :
336 32 Patrice Nadeau
337 5 Patrice Nadeau
* ActionItemAttribut, où _Action_ signifie :
338 1 Patrice Nadeau
** *Get* : Lis un registre
339 5 Patrice Nadeau
** *Read*, *Write* : Lis ou écris dans un fichier
340 1 Patrice Nadeau
** *Set* : Écris une valeur prédéfini dans un registre
341
** *Init* : Fonction d’initialisation
342
* isItemEtat
343
** *is* : Verifie si _Item_ est dans l’état _Etat_
344
345
Exception
346
> 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.
347
348
Une fonction DEVRAIT retourner une valeur. 
349
350
Dans le cas d'un « oui/non », la valeur DOIT être :
351
352 32 Patrice Nadeau
* Succès : **0**
353
* Erreur : **1**
354
355 50 Patrice Nadeau
    > L'utilisation d'un type booléen (*true* & *false*) est permise avec la librairie **\<stbool.h\>** (C99).
356 32 Patrice Nadeau
357 1 Patrice Nadeau
Dans le cas d'une fonction retournant un pointeur :
358
359 32 Patrice Nadeau
* Erreur : **NULL**
360
* Autre valeur  : adresse du pointeur
361 1 Patrice Nadeau
362 32 Patrice Nadeau
363 1 Patrice Nadeau
Définition de fonctions
364 32 Patrice Nadeau
365
    /**
366
    * @brief Check if a timer is set
367
    * @param[in] nb Timer number. @n Possible values :
368
    * − @b TIMER_1
369
    * − @b TIMER_2
370
    * @return
371
    * @retval true Timer @e nb is set
372
    * @retval false Timer @e nb is NOT set
373
    * @par Example :
374
    * Check if the timer is set
375
    * @code{.c}
376
    * ...
377
    * result = isTimerSet();
378
    * ...
379
    * @endcode
380
    * @pre TimerInit
381
    **/
382
    static bool isTimerSet(uint8_t nb);
383
    /**
384
    * @brief Set the led to green
385
    **/
386
    SetLedColor(GREEN);
387 1 Patrice Nadeau
    /**
388 32 Patrice Nadeau
    * @brief Set register of the chip XYZ
389 1 Patrice Nadeau
    *
390 32 Patrice Nadeau
    * The name does not follow the standards but does match the datatsheet
391
    * This is a local function not meant to be called outside this librairy
392 1 Patrice Nadeau
    **/
393
    static void _WriteReg(void);
394
395
### Macros
396
397
Les directives du préprocesseur C.
398 17 Patrice Nadeau
399 1 Patrice Nadeau
* Utilisé dans le code source et les fichiers entête.
400
* DOIT toujours commencer à la colonne 0.
401
402 51 Patrice Nadeau
#### #include
403 23 Patrice Nadeau
404 1 Patrice Nadeau
Pour inclure d’autres fichier comme les fichiers entête.
405
>N’est pas documenté dans Doxygen.
406
407
    #### ifdef / ifndef
408 23 Patrice Nadeau
409
Surtout utiliser pour des options de compilation sur différentes plateforme.
410
>N’est pas documenté dans Doxygen.
411 1 Patrice Nadeau
412 40 Patrice Nadeau
    #ifndef usart_AVR
413 1 Patrice Nadeau
414 40 Patrice Nadeau
        #error "usart.h is not supported on this AVR !"
415 24 Patrice Nadeau
416 17 Patrice Nadeau
    #endif
417 1 Patrice Nadeau
418 52 Patrice Nadeau
#### #error
419 1 Patrice Nadeau
420
Affiche une erreur et arrête la compilation
421 24 Patrice Nadeau
>N’est pas documenté dans Doxygen.
422
423 34 Patrice Nadeau
    #ifndef __test__
424 33 Patrice Nadeau
425 34 Patrice Nadeau
        #error "Error !"
426 33 Patrice Nadeau
427 37 Patrice Nadeau
    #endif
428 1 Patrice Nadeau
429
#### #warning
430
431
Affiche une erreur mais n’arrête la compilation
432
>N’est pas documenté dans Doxygen.
433
434
    #ifndef __test__
435
436 38 Patrice Nadeau
    #warning "Warning !"
437
438 53 Patrice Nadeau
    #endif
439 17 Patrice Nadeau
440 53 Patrice Nadeau
441
#### #define 
442 1 Patrice Nadeau
443
Définis une valeur au moment de la compilation.
444 39 Patrice Nadeau
445 1 Patrice Nadeau
* Format
446 39 Patrice Nadeau
    * En majuscule.
447
    * Séparé par un «underscore» si contient plusieurs mots.
448 1 Patrice Nadeau
* Doxygen
449 39 Patrice Nadeau
    * @brief
450
    * @name pour les listes de macros (regroupement dans la documentation)
451 1 Patrice Nadeau
452
Définition de macros
453 39 Patrice Nadeau
454
    /**
455
    * @name Mathematical macros listed together
456
    * @{
457
    */
458
    /** @brief Value for PI */
459
460 40 Patrice Nadeau
    #define _PI 3.14
461
    /** @brief Another number */
462
    #define _MAGIC_NUMBER 42
463
    /**
464
    * @}
465
    */
466
    /** @brief Even parity */
467 1 Patrice Nadeau
468
    #define usart_PARITY_EVEN 'e'
469 17 Patrice Nadeau
470 1 Patrice Nadeau
### Atmel AVR
471
472 3 Patrice Nadeau
Particularités pour les micro-contrôleurs AVR d’Atmel.
473 1 Patrice Nadeau
474
* Progmem : Pour mettre une fonction en Flash au lieu de SRAM.
475
** Le nom de la fonction est suivie de *_P*.
476
* main : Ne revient jamais à un niveau supérieur.
477
** Définir la fonction main avec l’attribut *noreturn*.
478
** La boucle sans fin la plus optimisé est le *for (;;)*.
479
* Atomic : Opérations ne devant pas être interrompus.
480
481 22 Patrice Nadeau
Particularités pour AVR
482
483
    /**
484
    * @brief Progmem function
485
    * @return An unsigned 8 bits integer
486 1 Patrice Nadeau
    */
487 22 Patrice Nadeau
    uint_8t PrintString_P()
488
489
    /* main function */
490
    void main(void) __atribute__((noreturn))
491
    {
492
        ...
493
        /* never return */
494 1 Patrice Nadeau
        for (;;) {
495
        }
496 22 Patrice Nadeau
    }
497 21 Patrice Nadeau
498 1 Patrice Nadeau
    /* atomic operations */
499
500 40 Patrice Nadeau
    #ifndef S_SPLINT_S
501
    ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
502
    /* 
503
    * operations that must not be interupted
504
    * like loading a 16 bit register with a 8 bit register 
505
    */
506
    }
507 18 Patrice Nadeau
    #endif
508 17 Patrice Nadeau
509 18 Patrice Nadeau
### Distribution
510
511 1 Patrice Nadeau
Les fichiers suivants DOIVENT être inclus dans une distribution en format *tar.gz* : 
512
513
* ChangeLog
514
* README
515
* Files.lst
516
* Makefile
517
* Makefile.mk
518
* LICENSE.txt
519
* *.c
520
* *.h
521
* projet.pdf (généré par Doxygen)
522
523 18 Patrice Nadeau
Avec mon makefile :
524
525 1 Patrice Nadeau
    make dist
526
527
### Modifications
528
529
Un changement à un fichier (source ou en-tête), doit se refléter dans _Git_.
530
531 18 Patrice Nadeau
Chaque changement est fait avec :
532
533
    git add nom_fichier
534 1 Patrice Nadeau
    git commit
535 18 Patrice Nadeau
536 1 Patrice Nadeau
La ligne DOIT 
537
538
* être au temps présent
539
* être en anglais
540 18 Patrice Nadeau
* se termine par un point
541 1 Patrice Nadeau
* être dans le format suivant :
542
    > La partie _section_ est facultative
543 18 Patrice Nadeau
544
545
    fichier1 (fonction) <section>: 
546
    Ajoute une description au temps présent.
547
    Décrire les bogues réglés si il y en avaient.
548 17 Patrice Nadeau
549 1 Patrice Nadeau
550
### Changelog
551
552
La somme de toutes les modification doivent apparaitre dans un fichier « changelog ».
553 18 Patrice Nadeau
> Le standard seras celui GNU : http://www.gnu.org/prep/standards/html_node/Change-Logs.html#Change-Logs
554 1 Patrice Nadeau
555 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 :
556
557 1 Patrice Nadeau
    git log --no-merges --format="%ad  %an  <%aE> %n * %B" --date=short > ChangeLog
558
   
559 17 Patrice Nadeau
### Validation du code
560 18 Patrice Nadeau
561 1 Patrice Nadeau
Le logiciel _splint_ est utilisé.
562
563
* Un « typecast » DOIT être utilisé lorsque détecté.
564
* L’utilisation du typecast *void* DOIT être utilisé lorsque qu’une fonction retourne un résultat non utilisé.
565
566 17 Patrice Nadeau
## Makefile
567 1 Patrice Nadeau
568 17 Patrice Nadeau
## Nagios
569 1 Patrice Nadeau
570 17 Patrice Nadeau
### Plugins
571 1 Patrice Nadeau
572
https://nagios-plugins.org/doc/guidelines.html
573
574
Un message d'une ligne (< 80 caractères) DOIT être retourné via _STDOUT_ dans le format
575 18 Patrice Nadeau
> *SERVICE STATUS:* texte
576
577 1 Patrice Nadeau
Les codes de retour sont les suivants :
578
579
|_. Valeur |_. Service Status |_. Description |
580
| 0 | OK | Le service fonctionne |
581
| 1 | Warning | Le service fonctionne, problème avec le seuil de la valeur _Warning_ |
582
| 2 | Critical | Le service ne fonctionne pas ou problème avec le seuil de la valeur _Critical_  |
583 18 Patrice Nadeau
| 3 | Unknow | Arguments non valides ou erreur interne (fork, tcp socket)|
584
585 1 Patrice Nadeau
Les arguments suivants DOIVENT être fournis :
586
587
* *-H* (*--hostname*) :
588
* *-w* (*--warning*) :
589
* *-c* (*--critical*) :
590
* *-V* (*--version*) :
591
* *-h* (*--help*) :
592
593
L'argument _--help_ DOIT aussi appeler l'argument _--version_.
594 18 Patrice Nadeau
595 1 Patrice Nadeau
En _C_, les fonctions suivantes DOIT être utilisées :
596 17 Patrice Nadeau
597 1 Patrice Nadeau
* _print_revision_ (utils.c)
598
* _print_help_
599
* _getopt_long_ (getopt.h)
600
601
## Puppet
602
603
### Généralités
604 18 Patrice Nadeau
605 1 Patrice Nadeau
Inspiré des recommandations disponible au http://docs.puppetlabs.com/guides/style_guide.html.
606 18 Patrice Nadeau
607 1 Patrice Nadeau
* Tabulation : 2 espaces
608
* Largeur : 80 caractères (« backslah » (\) pour séparer une longue ligne).
609 18 Patrice Nadeau
* Commentaires : Style #
610
* Guillemets
611
    * Simple : Pour une « string » sans variables.
612 1 Patrice Nadeau
    * Double : Pour une « string » avec variables ayant besoin d’être extrapolé.
613
        * La variable doit être entourée des symboles *<notextile>{</notextile>* et *<notextile>}</notextile>*.
614
* Nom des ressources : DOIVENT être entouré du symbole *<notextile> ’ </notextile>*.
615
* Alignement de => : DOIT être aligné dans un même paragraphe.
616
* Ordre : Si l’attribut _ensure_ doit être inclus, il DOIT être le premier.
617
* Lien symbolique : DOIT être déclaré avec *ensure => link*
618
619
Ex. :
620
621
    file { '/var/log/syslog':
622 18 Patrice Nadeau
    ensure => link,
623
    target => '/var/log/messages',
624 1 Patrice Nadeau
    }
625
626
* File mode : 
627
    * 4 chiffres
628
    * simple guillemet
629 18 Patrice Nadeau
* Variables
630
    * lettres
631 1 Patrice Nadeau
    * chiffres
632
    * « underscore »
633
634
### Documentation
635 18 Patrice Nadeau
636
http://docs.puppetlabs.com/learning/modules2.html#module-documentation
637
638 1 Patrice Nadeau
Format Rdoc (http://rdoc.rubyforge.org/RDoc/Markup.html) :
639 18 Patrice Nadeau
640
* Bloc de commentaires qui commence sur la première ligne du fichier
641
* Titre avec le symbole *<notextile>=</notextile>*
642
* Séparation avec le symbole *<notextile>-</notextile>*
643 1 Patrice Nadeau
* Emphase (mot entouré du symbole)
644 18 Patrice Nadeau
    * * : gras
645 1 Patrice Nadeau
    * _ : souligné
646
    * + : Police de caractères pour le code
647
* Sections
648
    * = Class:
649
    * == Parameters:
650 18 Patrice Nadeau
    * == Requires:
651
    * == Sample Usage:
652 1 Patrice Nadeau
* Classe
653
    * Une classe par fichier « manifest »
654
655 17 Patrice Nadeau
## Script
656 1 Patrice Nadeau
657
### Bash
658
659 40 Patrice Nadeau
    #/bin/bash
660 1 Patrice Nadeau
661 40 Patrice Nadeau
    function print_revision {
662
    }
663 1 Patrice Nadeau
664 40 Patrice Nadeau
    function print_help {
665
        print_revision
666
    }
667
    
668 1 Patrice Nadeau
### Perl
669
670
### PowerShell
671 17 Patrice Nadeau
672 1 Patrice Nadeau
Version 4.0. Supporte :
673 17 Patrice Nadeau
674 1 Patrice Nadeau
* Windows 8.1 (natif)
675
* Windows Server 2012 R2 (natif)
676
* Windows 7 SP1
677 17 Patrice Nadeau
* Windows Server 2008 R2 SP1
678 1 Patrice Nadeau
* Windows Server 2012
679
680
#### Fichier
681
682 41 Patrice Nadeau
Le fichier DOIT être composé de la manière suivante :
683
684 1 Patrice Nadeau
* L’extension est .ps1
685
* Une longue ligne peux être séparée avec un « back tick » (‘).
686
687
#### Commentaires
688
689 20 Patrice Nadeau
L’aide est accéder par _Get-Help_
690
691
692
	#REQUIRES -Version 2.0
693
	<#
694
	.SYNOPSIS
695
	A brief description of the function or script.
696
	This keyword can be used only once in each topic.
697
	.DESCRIPTION
698
	A detailed description of the function or script.
699
	This keyword can be used only once in each topic.
700
	.NOTES
701
	File Name
702
	: xxxx.ps1
703
	Author
704
	:
705
	Prerequisite
706
	: PowerShell V2 over Vista and upper.
707
	Copyright 2011 -
708
	.LINK
709
	Script posted over:
710
	http://
711
	.EXAMPLE
712
	Example 1
713
	.EXAMPLE
714
	Example 2
715
	#>
716
717 1 Patrice Nadeau
718
719
## Vim
720 19 Patrice Nadeau
721
* Entête (en commentaires)
722
    * Titre
723
    * Last Change:
724 1 Patrice Nadeau
    * Maintainer:
725 19 Patrice Nadeau
    * License: This file is placed in the public domain.
726
* Autre mots reconnus
727
    * BUG: (Error:)
728
    * TODO:
729 1 Patrice Nadeau
    * Note:
730
    * FIXME
731
732
## Références
733
734 20 Patrice Nadeau
Références ayant servis à ce document.
735 19 Patrice Nadeau
736 1 Patrice Nadeau
[ChangeLog](http://www.gnu.org/prep/standards/html_node/Change-Logs.html#Change-Logs)
737
[GNU deprecated attribute](http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Type-Attributes.html)