提交 e662af42 编写于 作者: J Johannes Berg 提交者: Sam Ravnborg

kernel-doc: new P directive for DOC: sections

The !P directive includes the contents of a DOC: section
given by title, e.g.
!Pfilename Title of the section
Signed-off-by: NJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: NRandy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: NSam Ravnborg <sam@ravnborg.org>
上级 2e95972c
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
* !Ifilename * !Ifilename
* !Dfilename * !Dfilename
* !Ffilename * !Ffilename
* !Pfilename
* *
*/ */
...@@ -57,6 +58,7 @@ FILEONLY *symbolsonly; ...@@ -57,6 +58,7 @@ FILEONLY *symbolsonly;
typedef void FILELINE(char * file, char * line); typedef void FILELINE(char * file, char * line);
FILELINE * singlefunctions; FILELINE * singlefunctions;
FILELINE * entity_system; FILELINE * entity_system;
FILELINE * docsection;
#define MAXLINESZ 2048 #define MAXLINESZ 2048
#define MAXFILES 250 #define MAXFILES 250
...@@ -288,13 +290,37 @@ void singfunc(char * filename, char * line) ...@@ -288,13 +290,37 @@ void singfunc(char * filename, char * line)
exec_kernel_doc(vec); exec_kernel_doc(vec);
} }
/*
* Insert specific documentation section from a file.
* Call kernel-doc with the following parameters:
* kernel-doc -docbook -function "doc section" filename
*/
void docsect(char *filename, char *line)
{
char *vec[6]; /* kerneldoc -docbook -function "section" file NULL */
char *s;
for (s = line; *s; s++)
if (*s == '\n')
*s = '\0';
vec[0] = KERNELDOC;
vec[1] = DOCBOOK;
vec[2] = FUNCTION;
vec[3] = line;
vec[4] = filename;
vec[5] = NULL;
exec_kernel_doc(vec);
}
/* /*
* Parse file, calling action specific functions for: * Parse file, calling action specific functions for:
* 1) Lines containing !E * 1) Lines containing !E
* 2) Lines containing !I * 2) Lines containing !I
* 3) Lines containing !D * 3) Lines containing !D
* 4) Lines containing !F * 4) Lines containing !F
* 5) Default lines - lines not matching the above * 5) Lines containing !P
* 6) Default lines - lines not matching the above
*/ */
void parse_file(FILE *infile) void parse_file(FILE *infile)
{ {
...@@ -328,6 +354,15 @@ void parse_file(FILE *infile) ...@@ -328,6 +354,15 @@ void parse_file(FILE *infile)
s++; s++;
singlefunctions(line +2, s); singlefunctions(line +2, s);
break; break;
case 'P':
/* filename */
while (*s && !isspace(*s)) s++;
*s++ = '\0';
/* DOC: section name */
while (isspace(*s))
s++;
docsection(line + 2, s);
break;
default: default:
defaultline(line); defaultline(line);
} }
...@@ -374,6 +409,7 @@ int main(int argc, char *argv[]) ...@@ -374,6 +409,7 @@ int main(int argc, char *argv[])
externalfunctions = find_export_symbols; externalfunctions = find_export_symbols;
symbolsonly = find_export_symbols; symbolsonly = find_export_symbols;
singlefunctions = noaction2; singlefunctions = noaction2;
docsection = noaction2;
parse_file(infile); parse_file(infile);
/* Rewind to start from beginning of file again */ /* Rewind to start from beginning of file again */
...@@ -383,6 +419,7 @@ int main(int argc, char *argv[]) ...@@ -383,6 +419,7 @@ int main(int argc, char *argv[])
externalfunctions = extfunc; externalfunctions = extfunc;
symbolsonly = printline; symbolsonly = printline;
singlefunctions = singfunc; singlefunctions = singfunc;
docsection = docsect;
parse_file(infile); parse_file(infile);
} }
...@@ -396,6 +433,7 @@ int main(int argc, char *argv[]) ...@@ -396,6 +433,7 @@ int main(int argc, char *argv[])
externalfunctions = adddep; externalfunctions = adddep;
symbolsonly = adddep; symbolsonly = adddep;
singlefunctions = adddep2; singlefunctions = adddep2;
docsection = adddep2;
parse_file(infile); parse_file(infile);
printf("\n"); printf("\n");
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册