]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - Documentation/doc-guide/parse-headers.rst
parse-headers.pl: add documentation for this script
[mirror_ubuntu-zesty-kernel.git] / Documentation / doc-guide / parse-headers.rst
CommitLineData
327f5a75
MCC
1================
2parse_headers.pl
3================
4
5****
6NAME
7****
8
9
10parse_headers.pl - parse a C file, in order to identify functions, structs,
11enums and defines and create cross-references to a Sphinx book.
12
13
14********
15SYNOPSIS
16********
17
18
19\ **parse_headers.pl**\ [<options>] <C_FILE> <OUT_FILE> [<EXCEPTIONS_FILE>]
20
21Where <options> can be: --debug, --help or --man.
22
23
24*******
25OPTIONS
26*******
27
28
29
30\ **--debug**\
31
32 Put the script in verbose mode, useful for debugging.
33
34
35
36\ **--help**\
37
38 Prints a brief help message and exits.
39
40
41
42\ **--man**\
43
44 Prints the manual page and exits.
45
46
47
48
49***********
50DESCRIPTION
51***********
52
53
54Convert a C header or source file (C_FILE), into a ReStructured Text
55included via ..parsed-literal block with cross-references for the
56documentation files that describe the API. It accepts an optional
57EXCEPTIONS_FILE with describes what elements will be either ignored or
58be pointed to a non-default reference.
59
60The output is written at the (OUT_FILE).
61
62It is capable of identifying defines, functions, structs, typedefs,
63enums and enum symbols and create cross-references for all of them.
64It is also capable of distinguish #define used for specifying a Linux
65ioctl.
66
67The EXCEPTIONS_FILE contain two types of statements: \ **ignore**\ or \ **replace**\ .
68
69The syntax for the ignore tag is:
70
71
72ignore \ **type**\ \ **name**\
73
74The \ **ignore**\ means that it won't generate cross references for a
75\ **name**\ symbol of type \ **type**\ .
76
77The syntax for the replace tag is:
78
79
80replace \ **type**\ \ **name**\ \ **new_value**\
81
82The \ **replace**\ means that it will generate cross references for a
83\ **name**\ symbol of type \ **type**\ , but, instead of using the default
84replacement rule, it will use \ **new_value**\ .
85
86For both statements, \ **type**\ can be either one of the following:
87
88
89\ **ioctl**\
90
91 The ignore or replace statement will apply to ioctl definitions like:
92
93 #define VIDIOC_DBG_S_REGISTER _IOW('V', 79, struct v4l2_dbg_register)
94
95
96
97\ **define**\
98
99 The ignore or replace statement will apply to any other #define found
100 at C_FILE.
101
102
103
104\ **typedef**\
105
106 The ignore or replace statement will apply to typedef statements at C_FILE.
107
108
109
110\ **struct**\
111
112 The ignore or replace statement will apply to the name of struct statements
113 at C_FILE.
114
115
116
117\ **enum**\
118
119 The ignore or replace statement will apply to the name of enum statements
120 at C_FILE.
121
122
123
124\ **symbol**\
125
126 The ignore or replace statement will apply to the name of enum statements
127 at C_FILE.
128
129 For replace statements, \ **new_value**\ will automatically use :c:type:
130 references for \ **typedef**\ , \ **enum**\ and \ **struct**\ types. It will use :ref:
131 for \ **ioctl**\ , \ **define**\ and \ **symbol**\ types. The type of reference can
132 also be explicitly defined at the replace statement.
133
134
135
136
137********
138EXAMPLES
139********
140
141
142ignore define _VIDEODEV2_H
143
144
145Ignore a #define _VIDEODEV2_H at the C_FILE.
146
147ignore symbol PRIVATE
148
149
150On a struct like:
151
152enum foo { BAR1, BAR2, PRIVATE };
153
154It won't generate cross-references for \ **PRIVATE**\ .
155
156replace symbol BAR1 :c:type:\`foo\`
157replace symbol BAR2 :c:type:\`foo\`
158
159
160On a struct like:
161
162enum foo { BAR1, BAR2, PRIVATE };
163
164It will make the BAR1 and BAR2 enum symbols to cross reference the foo
165symbol at the C domain.
166
167
168****
169BUGS
170****
171
172
173Report bugs to Mauro Carvalho Chehab <mchehab@s-opensource.com>
174
175
176*********
177COPYRIGHT
178*********
179
180
181Copyright (c) 2016 by Mauro Carvalho Chehab <mchehab@s-opensource.com>.
182
183License GPLv2: GNU GPL version 2 <http://gnu.org/licenses/gpl.html>.
184
185This is free software: you are free to change and redistribute it.
186There is NO WARRANTY, to the extent permitted by law.