annotate DOCS/tech/code-documentation.txt @ 25460:3086b6d39052

Move two variable to the scope where they are indeed used.
author ulion
date Sat, 22 Dec 2007 03:45:14 +0000
parents e438a5af7771
children 32725ca88fed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13290
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
1 Code documentation guidelines
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
2 =============================
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
3
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
4 About this guide
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
5 ----------------
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
6
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
7 Due to the ever increasing complexity and size of MPlayer it became quite hard
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
8 to maintain the code and add new features. Part of this problem is the lack
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
9 of proper documentation what the code in question does and how it is doing it.
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
10 To tackle this problem every part of MPlayer should follow these guidelines
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
11 on what and how code should be documented.
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
12
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
13
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
14 Doxygen
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
15 -------
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
16
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
17 MPlayer uses doxygen for its code documentation. It generates HTML files
13302
05d3254e05b1 typos, wording
diego
parents: 13290
diff changeset
18 which contain specially tagged comment lines from the code including
13290
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
19 cross references. To generate it type `make doxygen` in the source root
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
20 directory. It will generate the files in DOCS/tech/doxygen. To clear them
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
21 again, you can use `make doxygen_clean`.
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
22 For further information about doxygen and its sources please have a look
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
23 at their website: http://doxygen.sf.net
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
24
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
25
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
26 What should be documented?
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
27 --------------------------
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
28
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
29 - every function, no matter whether it is globally or just locally used
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
30 * what the function does
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
31 * all parameters and return values of the function and their valid ranges
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
32 * all side effects (to passed parameters, globals etc)
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
33 * all assumptions made within the function
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
34
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
35 - global, file local and important variables
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
36 * what it is used for
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
37 * its valid range
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
38 * where it is set (optional)
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
39 * where validity checking is done (optional, mandatory for variables which
22202
e438a5af7771 random small fixes
diego
parents: 14899
diff changeset
40 are set by something external, e.g. user parameters, file information etc)
13290
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
41
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
42 - #define, typedefs, structs
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
43 * all global definitions
22202
e438a5af7771 random small fixes
diego
parents: 14899
diff changeset
44 * all local definitions whose use is not immediately clear by their name
13302
05d3254e05b1 typos, wording
diego
parents: 13290
diff changeset
45 (as a rule of thumb, it's better to document too much than not enough)
13290
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
46 * all dependencies
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
47
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
48 - non-trivial parts of the code
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
49 * tricky parts
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
50 * important parts
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
51 * special side effects
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
52 * assumptions of the code
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
53 * string operations and why they are safe
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
54
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
55 - workarounds
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
56 * why they are needed
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
57 * how they work
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
58 * what side effects they have
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
59
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
60 If you are unsure whether a comment is needed or not, add one.
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
61
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
62
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
63 How should it be documented?
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
64 ----------------------------
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
65
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
66 All comments should be in correct and clear English. Any other language is
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
67 not allowed. The language used should be kept simple as the code will be
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
68 read mostly by non-native speakers. For function and variable documentation,
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
69 a style usable by doxygen should be used. See section 3 "Documenting the code"
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
70 of the doxygen manual for an introduction. A very short overview follows:
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
71
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
72 Doxygen includes only special comments in the documentation, those are:
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
73
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
74 /// This is a line used by doxygen.
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
75
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
76 /** this one, too */
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
77
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
78 /** these
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
79 here
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
80 of
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
81 course,
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
82 too */
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
83
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
84 //! this form can be also used
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
85
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
86 // This line isn't included in doxygen documentation.
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
87
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
88 /* Neither is this. */
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
89
14899
335964188675 better explain where and how to use doxygen comments
diego
parents: 13302
diff changeset
90 Doxygen comments should come before the definition:
335964188675 better explain where and how to use doxygen comments
diego
parents: 13302
diff changeset
91
335964188675 better explain where and how to use doxygen comments
diego
parents: 13302
diff changeset
92 /** description */
335964188675 better explain where and how to use doxygen comments
diego
parents: 13302
diff changeset
93 int a_variable;
335964188675 better explain where and how to use doxygen comments
diego
parents: 13302
diff changeset
94
335964188675 better explain where and how to use doxygen comments
diego
parents: 13302
diff changeset
95 However, you can use '<' to describe things AFTER they are defined, like this:
335964188675 better explain where and how to use doxygen comments
diego
parents: 13302
diff changeset
96
335964188675 better explain where and how to use doxygen comments
diego
parents: 13302
diff changeset
97 int some_var; ///< description
335964188675 better explain where and how to use doxygen comments
diego
parents: 13302
diff changeset
98 #define foo(x) (x + 2) /**< returns x plus 2 */
335964188675 better explain where and how to use doxygen comments
diego
parents: 13302
diff changeset
99
13290
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
100 There are a couple of special tags for doxygen:
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
101
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
102 \brief <one line text>
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
103 Gives a brief description of a function.
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
104 \param <parameter> <text>
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
105 Describes a specific <parameter>.
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
106 \return <text>
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
107 Describes the return value.
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
108 \a <word>
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
109 Mark next word as a reference to a parameter.
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
110 \e <word>
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
111 Use italic font for the next word.
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
112 \b <word>
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
113 Use bold font for the next word.
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
114 \c <word>
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
115 Use typewriter font for the next word.
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
116 \sa <references>
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
117 Adds a section with crossreferences.
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
118 \bug <text>
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
119 Describe a known bug.
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
120 \todo <text>
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
121 Add a todo list.
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
122 \attention <text>
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
123 Add a section for something that needs attention.
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
124 \warning <text>
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
125 Add a section for a warning.
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
126 \anchor <refname>
22202
e438a5af7771 random small fixes
diego
parents: 14899
diff changeset
127 Set an invisible anchor which can be used to create a link with \ref.
13290
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
128 \ref <refname> [<text>]
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
129 Add a link to <refname>.
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
130
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
131 For a complete list of tags please read section 20 "Special commands" of the
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
132 doxygen manual.
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
133
fb8f8882fb6a adding the code documentation guide lines
attila
parents:
diff changeset
134