Mauro Carvalho Chehab | 2dde123 | 2016-11-17 08:32:35 -0200 | [diff] [blame^] | 1 | =========================== |
| 2 | Including uAPI header files |
| 3 | =========================== |
| 4 | |
| 5 | Sometimes, it is useful to include header files and C example codes in |
| 6 | order to describe the userspace API and to generate cross-references |
| 7 | between the code and the documentation. Adding cross-references for |
| 8 | userspace API files has an additional vantage: Sphinx will generate warnings |
| 9 | if a symbol is not found at the documentation. That helps to keep the |
| 10 | uAPI documentation in sync with the Kernel changes. |
| 11 | The :ref:`parse_headers.pl <parse_headers>` provide a way to generate such |
| 12 | cross-references. It has to be called via Makefile, while building the |
| 13 | documentation. Please see ``Documentation/media/Makefile`` for an example |
| 14 | about how to use it inside the Kernel tree. |
| 15 | |
| 16 | .. _parse_headers: |
| 17 | |
Mauro Carvalho Chehab | 327f5a7 | 2016-11-17 08:32:34 -0200 | [diff] [blame] | 18 | parse_headers.pl |
Mauro Carvalho Chehab | 2dde123 | 2016-11-17 08:32:35 -0200 | [diff] [blame^] | 19 | ^^^^^^^^^^^^^^^^ |
| 20 | |
| 21 | .. NOTE: the man pages below were generated using pod2rst tool: |
| 22 | .. http://search.cpan.org/~dowens/Pod-POM-View-Restructured-0.02/bin/pod2rst |
| 23 | .. If you need to change anything below this point, please do the changes |
| 24 | .. at parse-headers.pl directly, re-run the script and paste the output of |
| 25 | .. the script here. |
Mauro Carvalho Chehab | 327f5a7 | 2016-11-17 08:32:34 -0200 | [diff] [blame] | 26 | |
| 27 | **** |
| 28 | NAME |
| 29 | **** |
| 30 | |
| 31 | |
| 32 | parse_headers.pl - parse a C file, in order to identify functions, structs, |
| 33 | enums and defines and create cross-references to a Sphinx book. |
| 34 | |
| 35 | |
| 36 | ******** |
| 37 | SYNOPSIS |
| 38 | ******** |
| 39 | |
| 40 | |
| 41 | \ **parse_headers.pl**\ [<options>] <C_FILE> <OUT_FILE> [<EXCEPTIONS_FILE>] |
| 42 | |
| 43 | Where <options> can be: --debug, --help or --man. |
| 44 | |
| 45 | |
| 46 | ******* |
| 47 | OPTIONS |
| 48 | ******* |
| 49 | |
| 50 | |
| 51 | |
| 52 | \ **--debug**\ |
| 53 | |
| 54 | Put the script in verbose mode, useful for debugging. |
| 55 | |
| 56 | |
| 57 | |
| 58 | \ **--help**\ |
| 59 | |
| 60 | Prints a brief help message and exits. |
| 61 | |
| 62 | |
| 63 | |
| 64 | \ **--man**\ |
| 65 | |
| 66 | Prints the manual page and exits. |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | *********** |
| 72 | DESCRIPTION |
| 73 | *********** |
| 74 | |
| 75 | |
| 76 | Convert a C header or source file (C_FILE), into a ReStructured Text |
| 77 | included via ..parsed-literal block with cross-references for the |
| 78 | documentation files that describe the API. It accepts an optional |
| 79 | EXCEPTIONS_FILE with describes what elements will be either ignored or |
| 80 | be pointed to a non-default reference. |
| 81 | |
| 82 | The output is written at the (OUT_FILE). |
| 83 | |
| 84 | It is capable of identifying defines, functions, structs, typedefs, |
| 85 | enums and enum symbols and create cross-references for all of them. |
| 86 | It is also capable of distinguish #define used for specifying a Linux |
| 87 | ioctl. |
| 88 | |
| 89 | The EXCEPTIONS_FILE contain two types of statements: \ **ignore**\ or \ **replace**\ . |
| 90 | |
| 91 | The syntax for the ignore tag is: |
| 92 | |
| 93 | |
| 94 | ignore \ **type**\ \ **name**\ |
| 95 | |
| 96 | The \ **ignore**\ means that it won't generate cross references for a |
| 97 | \ **name**\ symbol of type \ **type**\ . |
| 98 | |
| 99 | The syntax for the replace tag is: |
| 100 | |
| 101 | |
| 102 | replace \ **type**\ \ **name**\ \ **new_value**\ |
| 103 | |
| 104 | The \ **replace**\ means that it will generate cross references for a |
| 105 | \ **name**\ symbol of type \ **type**\ , but, instead of using the default |
| 106 | replacement rule, it will use \ **new_value**\ . |
| 107 | |
| 108 | For both statements, \ **type**\ can be either one of the following: |
| 109 | |
| 110 | |
| 111 | \ **ioctl**\ |
| 112 | |
| 113 | The ignore or replace statement will apply to ioctl definitions like: |
| 114 | |
| 115 | #define VIDIOC_DBG_S_REGISTER _IOW('V', 79, struct v4l2_dbg_register) |
| 116 | |
| 117 | |
| 118 | |
| 119 | \ **define**\ |
| 120 | |
| 121 | The ignore or replace statement will apply to any other #define found |
| 122 | at C_FILE. |
| 123 | |
| 124 | |
| 125 | |
| 126 | \ **typedef**\ |
| 127 | |
| 128 | The ignore or replace statement will apply to typedef statements at C_FILE. |
| 129 | |
| 130 | |
| 131 | |
| 132 | \ **struct**\ |
| 133 | |
| 134 | The ignore or replace statement will apply to the name of struct statements |
| 135 | at C_FILE. |
| 136 | |
| 137 | |
| 138 | |
| 139 | \ **enum**\ |
| 140 | |
| 141 | The ignore or replace statement will apply to the name of enum statements |
| 142 | at C_FILE. |
| 143 | |
| 144 | |
| 145 | |
| 146 | \ **symbol**\ |
| 147 | |
| 148 | The ignore or replace statement will apply to the name of enum statements |
| 149 | at C_FILE. |
| 150 | |
| 151 | For replace statements, \ **new_value**\ will automatically use :c:type: |
| 152 | references for \ **typedef**\ , \ **enum**\ and \ **struct**\ types. It will use :ref: |
| 153 | for \ **ioctl**\ , \ **define**\ and \ **symbol**\ types. The type of reference can |
| 154 | also be explicitly defined at the replace statement. |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | ******** |
| 160 | EXAMPLES |
| 161 | ******** |
| 162 | |
| 163 | |
| 164 | ignore define _VIDEODEV2_H |
| 165 | |
| 166 | |
| 167 | Ignore a #define _VIDEODEV2_H at the C_FILE. |
| 168 | |
| 169 | ignore symbol PRIVATE |
| 170 | |
| 171 | |
| 172 | On a struct like: |
| 173 | |
| 174 | enum foo { BAR1, BAR2, PRIVATE }; |
| 175 | |
| 176 | It won't generate cross-references for \ **PRIVATE**\ . |
| 177 | |
| 178 | replace symbol BAR1 :c:type:\`foo\` |
| 179 | replace symbol BAR2 :c:type:\`foo\` |
| 180 | |
| 181 | |
| 182 | On a struct like: |
| 183 | |
| 184 | enum foo { BAR1, BAR2, PRIVATE }; |
| 185 | |
| 186 | It will make the BAR1 and BAR2 enum symbols to cross reference the foo |
| 187 | symbol at the C domain. |
| 188 | |
| 189 | |
| 190 | **** |
| 191 | BUGS |
| 192 | **** |
| 193 | |
| 194 | |
| 195 | Report bugs to Mauro Carvalho Chehab <mchehab@s-opensource.com> |
| 196 | |
| 197 | |
| 198 | ********* |
| 199 | COPYRIGHT |
| 200 | ********* |
| 201 | |
| 202 | |
| 203 | Copyright (c) 2016 by Mauro Carvalho Chehab <mchehab@s-opensource.com>. |
| 204 | |
| 205 | License GPLv2: GNU GPL version 2 <http://gnu.org/licenses/gpl.html>. |
| 206 | |
| 207 | This is free software: you are free to change and redistribute it. |
| 208 | There is NO WARRANTY, to the extent permitted by law. |