Skip to content

Commit e662af4

Browse files
jmbergsravnborg
authored andcommitted
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: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
1 parent 2e95972 commit e662af4

1 file changed

Lines changed: 39 additions & 1 deletion

File tree

scripts/basic/docproc.c

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
* !Ifilename
3131
* !Dfilename
3232
* !Ffilename
33+
* !Pfilename
3334
*
3435
*/
3536

@@ -57,6 +58,7 @@ FILEONLY *symbolsonly;
5758
typedef void FILELINE(char * file, char * line);
5859
FILELINE * singlefunctions;
5960
FILELINE * entity_system;
61+
FILELINE * docsection;
6062

6163
#define MAXLINESZ 2048
6264
#define MAXFILES 250
@@ -288,13 +290,37 @@ void singfunc(char * filename, char * line)
288290
exec_kernel_doc(vec);
289291
}
290292

293+
/*
294+
* Insert specific documentation section from a file.
295+
* Call kernel-doc with the following parameters:
296+
* kernel-doc -docbook -function "doc section" filename
297+
*/
298+
void docsect(char *filename, char *line)
299+
{
300+
char *vec[6]; /* kerneldoc -docbook -function "section" file NULL */
301+
char *s;
302+
303+
for (s = line; *s; s++)
304+
if (*s == '\n')
305+
*s = '\0';
306+
307+
vec[0] = KERNELDOC;
308+
vec[1] = DOCBOOK;
309+
vec[2] = FUNCTION;
310+
vec[3] = line;
311+
vec[4] = filename;
312+
vec[5] = NULL;
313+
exec_kernel_doc(vec);
314+
}
315+
291316
/*
292317
* Parse file, calling action specific functions for:
293318
* 1) Lines containing !E
294319
* 2) Lines containing !I
295320
* 3) Lines containing !D
296321
* 4) Lines containing !F
297-
* 5) Default lines - lines not matching the above
322+
* 5) Lines containing !P
323+
* 6) Default lines - lines not matching the above
298324
*/
299325
void parse_file(FILE *infile)
300326
{
@@ -328,6 +354,15 @@ void parse_file(FILE *infile)
328354
s++;
329355
singlefunctions(line +2, s);
330356
break;
357+
case 'P':
358+
/* filename */
359+
while (*s && !isspace(*s)) s++;
360+
*s++ = '\0';
361+
/* DOC: section name */
362+
while (isspace(*s))
363+
s++;
364+
docsection(line + 2, s);
365+
break;
331366
default:
332367
defaultline(line);
333368
}
@@ -374,6 +409,7 @@ int main(int argc, char *argv[])
374409
externalfunctions = find_export_symbols;
375410
symbolsonly = find_export_symbols;
376411
singlefunctions = noaction2;
412+
docsection = noaction2;
377413
parse_file(infile);
378414

379415
/* Rewind to start from beginning of file again */
@@ -383,6 +419,7 @@ int main(int argc, char *argv[])
383419
externalfunctions = extfunc;
384420
symbolsonly = printline;
385421
singlefunctions = singfunc;
422+
docsection = docsect;
386423

387424
parse_file(infile);
388425
}
@@ -396,6 +433,7 @@ int main(int argc, char *argv[])
396433
externalfunctions = adddep;
397434
symbolsonly = adddep;
398435
singlefunctions = adddep2;
436+
docsection = adddep2;
399437
parse_file(infile);
400438
printf("\n");
401439
}

0 commit comments

Comments
 (0)