Add a helper for calling kernel-doc, with the -w parameter describing
the parameters to pass on to kernel-doc, in a special format.

[This is easier to explain and will make more sense in the context of
the following patches. The -w parameter is expected to be a filename
with the kernel-doc parameters encoded at the end of the filename. This
could be included in kernel-doc itself, but it feels like polluting the
tool. So here's a helper, at least for now.]

Signed-off-by: Jani Nikula <jani.nik...@intel.com>
---
 scripts/kernel-doc-helper | 70 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100755 scripts/kernel-doc-helper

diff --git a/scripts/kernel-doc-helper b/scripts/kernel-doc-helper
new file mode 100755
index 000000000000..1e26266f9feb
--- /dev/null
+++ b/scripts/kernel-doc-helper
@@ -0,0 +1,70 @@
+#!/bin/bash
+
+KERNELDOC=kernel-doc
+OUTPUT_FORMAT=-asciidoc
+
+WHAT=
+
+usage()
+{
+       cat <<EOF
+$ kernel-doc-helper [-k KERNELDOC] -w WHAT SOURCE
+
+Run KERNELDOC (kernel-doc by default) on SOURCE to extract information 
specified
+by WHAT.
+
+WHAT is an arbitrary string ending in special suffixes that are converted to
+kernel-doc parameters.
+EOF
+       exit 0
+}
+
+while getopts "hw:k:" opt; do
+       case "$opt" in
+               h)
+                       usage
+                       ;;
+               w)
+                       WHAT="$OPTARG"
+                       ;;
+               k)
+                       KERNELDOC="$OPTARG"
+                       ;;
+               *)
+                       exit 1
+       esac
+done
+shift `expr $OPTIND - 1`
+
+if [ "$#" = "0" ]; then
+       echo "$0: source file missing" >&2
+       exit 1
+fi
+
+if [ -z "$WHAT" ]; then
+       echo "$0: output selection (-w) missing" >&2
+       exit 1
+fi
+
+SOURCE=$1
+
+case $WHAT in
+       *,export)
+               exec $KERNELDOC $OUTPUT_FORMAT -export $SOURCE
+               ;;
+       *,internal)
+               exec $KERNELDOC $OUTPUT_FORMAT -internal $SOURCE
+               ;;
+       *,function,*)
+               name=${WHAT##*,function,}
+               exec $KERNELDOC $OUTPUT_FORMAT -function $name $SOURCE
+               ;;
+       *,doc,*)
+               name=${WHAT##*,doc,}
+               exec $KERNELDOC $OUTPUT_FORMAT -doc $name $SOURCE
+               ;;
+       *)
+               echo "$0: unknown output selection '$WHAT'" >&2
+               exit 1
+               ;;
+esac
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to