diff options
| author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
| commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
| tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /scripts/kernel-doc | |
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'scripts/kernel-doc')
| -rwxr-xr-x | scripts/kernel-doc | 1831 |
1 files changed, 1831 insertions, 0 deletions
diff --git a/scripts/kernel-doc b/scripts/kernel-doc new file mode 100755 index 00000000000..8b1dab63f11 --- /dev/null +++ b/scripts/kernel-doc | |||
| @@ -0,0 +1,1831 @@ | |||
| 1 | #!/usr/bin/perl -w | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | |||
| 5 | ## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## | ||
| 6 | ## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## | ||
| 7 | ## Copyright (C) 2001 Simon Huggins ## | ||
| 8 | ## ## | ||
| 9 | ## #define enhancements by Armin Kuster <akuster@mvista.com> ## | ||
| 10 | ## Copyright (c) 2000 MontaVista Software, Inc. ## | ||
| 11 | ## ## | ||
| 12 | ## This software falls under the GNU General Public License. ## | ||
| 13 | ## Please read the COPYING file for more information ## | ||
| 14 | |||
| 15 | # w.o. 03-11-2000: added the '-filelist' option. | ||
| 16 | |||
| 17 | # 18/01/2001 - Cleanups | ||
| 18 | # Functions prototyped as foo(void) same as foo() | ||
| 19 | # Stop eval'ing where we don't need to. | ||
| 20 | # -- huggie@earth.li | ||
| 21 | |||
| 22 | # 27/06/2001 - Allowed whitespace after initial "/**" and | ||
| 23 | # allowed comments before function declarations. | ||
| 24 | # -- Christian Kreibich <ck@whoop.org> | ||
| 25 | |||
| 26 | # Still to do: | ||
| 27 | # - add perldoc documentation | ||
| 28 | # - Look more closely at some of the scarier bits :) | ||
| 29 | |||
| 30 | # 26/05/2001 - Support for separate source and object trees. | ||
| 31 | # Return error code. | ||
| 32 | # Keith Owens <kaos@ocs.com.au> | ||
| 33 | |||
| 34 | # 23/09/2001 - Added support for typedefs, structs, enums and unions | ||
| 35 | # Support for Context section; can be terminated using empty line | ||
| 36 | # Small fixes (like spaces vs. \s in regex) | ||
| 37 | # -- Tim Jansen <tim@tjansen.de> | ||
| 38 | |||
| 39 | |||
| 40 | # | ||
| 41 | # This will read a 'c' file and scan for embedded comments in the | ||
| 42 | # style of gnome comments (+minor extensions - see below). | ||
| 43 | # | ||
| 44 | |||
| 45 | # Note: This only supports 'c'. | ||
| 46 | |||
| 47 | # usage: | ||
| 48 | # kerneldoc [ -docbook | -html | -text | -man ] | ||
| 49 | # [ -function funcname [ -function funcname ...] ] c file(s)s > outputfile | ||
| 50 | # or | ||
| 51 | # [ -nofunction funcname [ -function funcname ...] ] c file(s)s > outputfile | ||
| 52 | # | ||
| 53 | # Set output format using one of -docbook -html -text or -man. Default is man. | ||
| 54 | # | ||
| 55 | # -function funcname | ||
| 56 | # If set, then only generate documentation for the given function(s). All | ||
| 57 | # other functions are ignored. | ||
| 58 | # | ||
| 59 | # -nofunction funcname | ||
| 60 | # If set, then only generate documentation for the other function(s). All | ||
| 61 | # other functions are ignored. Cannot be used with -function together | ||
| 62 | # (yes thats a bug - perl hackers can fix it 8)) | ||
| 63 | # | ||
| 64 | # c files - list of 'c' files to process | ||
| 65 | # | ||
| 66 | # All output goes to stdout, with errors to stderr. | ||
| 67 | |||
| 68 | # | ||
| 69 | # format of comments. | ||
| 70 | # In the following table, (...)? signifies optional structure. | ||
| 71 | # (...)* signifies 0 or more structure elements | ||
| 72 | # /** | ||
| 73 | # * function_name(:)? (- short description)? | ||
| 74 | # (* @parameterx: (description of parameter x)?)* | ||
| 75 | # (* a blank line)? | ||
| 76 | # * (Description:)? (Description of function)? | ||
| 77 | # * (section header: (section description)? )* | ||
| 78 | # (*)?*/ | ||
| 79 | # | ||
| 80 | # So .. the trivial example would be: | ||
| 81 | # | ||
| 82 | # /** | ||
| 83 | # * my_function | ||
| 84 | # **/ | ||
| 85 | # | ||
| 86 | # If the Description: header tag is ommitted, then there must be a blank line | ||
| 87 | # after the last parameter specification. | ||
| 88 | # e.g. | ||
| 89 | # /** | ||
| 90 | # * my_function - does my stuff | ||
| 91 | # * @my_arg: its mine damnit | ||
| 92 | # * | ||
| 93 | # * Does my stuff explained. | ||
| 94 | # */ | ||
| 95 | # | ||
| 96 | # or, could also use: | ||
| 97 | # /** | ||
| 98 | # * my_function - does my stuff | ||
| 99 | # * @my_arg: its mine damnit | ||
| 100 | # * Description: Does my stuff explained. | ||
| 101 | # */ | ||
| 102 | # etc. | ||
| 103 | # | ||
| 104 | # Beside functions you can also write documentation for structs, unions, | ||
| 105 | # enums and typedefs. Instead of the function name you must write the name | ||
| 106 | # of the declaration; the struct/union/enum/typedef must always precede | ||
| 107 | # the name. Nesting of declarations is not supported. | ||
| 108 | # Use the argument mechanism to document members or constants. | ||
| 109 | # e.g. | ||
| 110 | # /** | ||
| 111 | # * struct my_struct - short description | ||
| 112 | # * @a: first member | ||
| 113 | # * @b: second member | ||
| 114 | # * | ||
| 115 | # * Longer description | ||
| 116 | # */ | ||
| 117 | # struct my_struct { | ||
| 118 | # int a; | ||
| 119 | # int b; | ||
| 120 | # }; | ||
| 121 | # | ||
| 122 | # All descriptions can be multiline, except the short function description. | ||
| 123 | # | ||
| 124 | # You can also add additional sections. When documenting kernel functions you | ||
| 125 | # should document the "Context:" of the function, e.g. whether the functions | ||
| 126 | # can be called form interrupts. Unlike other sections you can end it with an | ||
| 127 | # empty line. | ||
| 128 | # Example-sections should contain the string EXAMPLE so that they are marked | ||
| 129 | # appropriately in DocBook. | ||
| 130 | # | ||
| 131 | # Example: | ||
| 132 | # /** | ||
| 133 | # * user_function - function that can only be called in user context | ||
| 134 | # * @a: some argument | ||
| 135 | # * Context: !in_interrupt() | ||
| 136 | # * | ||
| 137 | # * Some description | ||
| 138 | # * Example: | ||
| 139 | # * user_function(22); | ||
| 140 | # */ | ||
| 141 | # ... | ||
| 142 | # | ||
| 143 | # | ||
| 144 | # All descriptive text is further processed, scanning for the following special | ||
| 145 | # patterns, which are highlighted appropriately. | ||
| 146 | # | ||
| 147 | # 'funcname()' - function | ||
| 148 | # '$ENVVAR' - environmental variable | ||
| 149 | # '&struct_name' - name of a structure (up to two words including 'struct') | ||
| 150 | # '@parameter' - name of a parameter | ||
| 151 | # '%CONST' - name of a constant. | ||
| 152 | |||
| 153 | my $errors = 0; | ||
| 154 | my $warnings = 0; | ||
| 155 | |||
| 156 | # match expressions used to find embedded type information | ||
| 157 | my $type_constant = '\%([-_\w]+)'; | ||
| 158 | my $type_func = '(\w+)\(\)'; | ||
| 159 | my $type_param = '\@(\w+)'; | ||
| 160 | my $type_struct = '\&((struct\s*)?[_\w]+)'; | ||
| 161 | my $type_env = '(\$\w+)'; | ||
| 162 | |||
| 163 | # Output conversion substitutions. | ||
| 164 | # One for each output format | ||
| 165 | |||
| 166 | # these work fairly well | ||
| 167 | my %highlights_html = ( $type_constant, "<i>\$1</i>", | ||
| 168 | $type_func, "<b>\$1</b>", | ||
| 169 | $type_struct, "<i>\$1</i>", | ||
| 170 | $type_param, "<tt><b>\$1</b></tt>" ); | ||
| 171 | my $blankline_html = "<p>"; | ||
| 172 | |||
| 173 | # XML, docbook format | ||
| 174 | my %highlights_xml = ( "([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>", | ||
| 175 | $type_constant, "<constant>\$1</constant>", | ||
| 176 | $type_func, "<function>\$1</function>", | ||
| 177 | $type_struct, "<structname>\$1</structname>", | ||
| 178 | $type_env, "<envar>\$1</envar>", | ||
| 179 | $type_param, "<parameter>\$1</parameter>" ); | ||
| 180 | my $blankline_xml = "</para><para>\n"; | ||
| 181 | |||
| 182 | # gnome, docbook format | ||
| 183 | my %highlights_gnome = ( $type_constant, "<replaceable class=\"option\">\$1</replaceable>", | ||
| 184 | $type_func, "<function>\$1</function>", | ||
| 185 | $type_struct, "<structname>\$1</structname>", | ||
| 186 | $type_env, "<envar>\$1</envar>", | ||
| 187 | $type_param, "<parameter>\$1</parameter>" ); | ||
| 188 | my $blankline_gnome = "</para><para>\n"; | ||
| 189 | |||
| 190 | # these are pretty rough | ||
| 191 | my %highlights_man = ( $type_constant, "\$1", | ||
| 192 | $type_func, "\\\\fB\$1\\\\fP", | ||
| 193 | $type_struct, "\\\\fI\$1\\\\fP", | ||
| 194 | $type_param, "\\\\fI\$1\\\\fP" ); | ||
| 195 | my $blankline_man = ""; | ||
| 196 | |||
| 197 | # text-mode | ||
| 198 | my %highlights_text = ( $type_constant, "\$1", | ||
| 199 | $type_func, "\$1", | ||
| 200 | $type_struct, "\$1", | ||
| 201 | $type_param, "\$1" ); | ||
| 202 | my $blankline_text = ""; | ||
| 203 | |||
| 204 | |||
| 205 | sub usage { | ||
| 206 | print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man ]\n"; | ||
| 207 | print " [ -function funcname [ -function funcname ...] ]\n"; | ||
| 208 | print " [ -nofunction funcname [ -nofunction funcname ...] ]\n"; | ||
| 209 | print " c source file(s) > outputfile\n"; | ||
| 210 | exit 1; | ||
| 211 | } | ||
| 212 | |||
| 213 | # read arguments | ||
| 214 | if ($#ARGV==-1) { | ||
| 215 | usage(); | ||
| 216 | } | ||
| 217 | |||
| 218 | my $verbose = 0; | ||
| 219 | my $output_mode = "man"; | ||
| 220 | my %highlights = %hi | ||
