[PATCH 2/4] docproc: handle asciidoc templates

From: Jonathan Corbet
Date: Mon Jan 25 2016 - 18:29:02 EST


There's really nothing different that needs to be done except for invoking
kernel-doc with the -asciidoc argument. Look at the input file name to
recognize asciidoc templates, so no special command-line flags are needed.

Signed-off-by: Jonathan Corbet <corbet@xxxxxxx>
---
scripts/docproc.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/scripts/docproc.c b/scripts/docproc.c
index e267e621..89284b5 100644
--- a/scripts/docproc.c
+++ b/scripts/docproc.c
@@ -68,12 +68,15 @@ FILELINE * docsection;
#define KERNELDOCPATH "scripts/"
#define KERNELDOC "kernel-doc"
#define DOCBOOK "-docbook"
+#define ASCIIDOC "-asciidoc"
#define LIST "-list"
#define FUNCTION "-function"
#define NOFUNCTION "-nofunction"
#define NODOCSECTIONS "-no-doc-sections"
#define SHOWNOTFOUND "-show-not-found"

+static char *doc_format = DOCBOOK;
+
static char *srctree, *kernsrctree;

static char **all_list = NULL;
@@ -242,7 +245,7 @@ static void find_export_symbols(char * filename)
/*
* Document all external or internal functions in a file.
* Call kernel-doc with following parameters:
- * kernel-doc -docbook -nofunction function_name1 filename
+ * kernel-doc [-docbook|-asciidoc] -nofunction function_name1 filename
* Function names are obtained from all the src files
* by find_export_symbols.
* intfunc uses -nofunction
@@ -263,7 +266,7 @@ static void docfunctions(char * filename, char * type)
exit(1);
}
vec[idx++] = KERNELDOC;
- vec[idx++] = DOCBOOK;
+ vec[idx++] = doc_format;
vec[idx++] = NODOCSECTIONS;
for (i=0; i < symfilecnt; i++) {
struct symfile * sym = &symfilelist[i];
@@ -275,7 +278,7 @@ static void docfunctions(char * filename, char * type)
}
vec[idx++] = filename;
vec[idx] = NULL;
- printf("<!-- %s -->\n", filename);
+ /* printf("<!-- %s -->\n", filename); */
exec_kernel_doc(vec);
fflush(stdout);
free(vec);
@@ -294,7 +297,7 @@ static void singfunc(char * filename, char * line)
int i, idx = 0;
int startofsym = 1;
vec[idx++] = KERNELDOC;
- vec[idx++] = DOCBOOK;
+ vec[idx++] = doc_format;
vec[idx++] = SHOWNOTFOUND;

/* Split line up in individual parameters preceded by FUNCTION */
@@ -343,7 +346,7 @@ static void docsect(char *filename, char *line)
free(s);

vec[0] = KERNELDOC;
- vec[1] = DOCBOOK;
+ vec[1] = doc_format;
vec[2] = SHOWNOTFOUND;
vec[3] = FUNCTION;
vec[4] = line;
@@ -497,6 +500,16 @@ static void parse_file(FILE *infile)
fflush(stdout);
}

+/*
+ * Is this an asciidoc template? Answer the question by seeing if its
+ * name ends in ".adt".
+ */
+static int is_asciidoc(const char *file)
+{
+ int len = strlen(file);
+
+ return len > 4 && ! strcmp(file + len - 4, ".adt");
+}

int main(int argc, char *argv[])
{
@@ -520,6 +533,8 @@ int main(int argc, char *argv[])
perror(argv[2]);
exit(2);
}
+ if (is_asciidoc(argv[2]))
+ doc_format = ASCIIDOC;

if (strcmp("doc", argv[1]) == 0) {
/* Need to do this in two passes.
--
2.7.0