Projet

Général

Profil

SOP 001-Programmation » Historique » Version 26

Patrice Nadeau, 2018-03-24 17:04

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