From 511c5d8d0c0b1dcd0fd435fa1a2f58ba58df2af2 Mon Sep 17 00:00:00 2001 From: Robert Schwebel Date: Mon, 12 Jul 2010 18:03:05 +0200 Subject: doc: add macros to unify command help with doxygen Currently we have duplicated all the information that appears online in 'help ' and in the doxygen documentation. This patch adds some infrastructure to specify help texts only once and re-use them for the integrated help as well as for the manual. Signed-off-by: Robert Schwebel --- scripts/doxy_filter.awk | 103 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 scripts/doxy_filter.awk (limited to 'scripts') diff --git a/scripts/doxy_filter.awk b/scripts/doxy_filter.awk new file mode 100644 index 0000000000..5ec0406298 --- /dev/null +++ b/scripts/doxy_filter.awk @@ -0,0 +1,103 @@ +#!/usr/bin/awk + +/BAREBOX_CMD_HELP_START[[:space:]]*\((.*)\)/ { + + this_opt = 0; + my_usage = ""; + my_short = ""; + my_cmd = gensub("BAREBOX_CMD_HELP_START[[:space:]]*\\((.*)\\)", "\\1", "g"); + this_text = 0; + delete(my_text); + delete(my_opts); + next; +} + +/BAREBOX_CMD_HELP_USAGE[[:space:]]*\((.*)\)/ { + + $0 = gensub("<", "\\<", "g"); + $0 = gensub(">", "\\>", "g"); + $0 = gensub("BAREBOX_CMD_HELP_USAGE[[:space:]]*\\((.*)\\)", "\\1", "g"); + $0 = gensub("\\\\n", "", "g"); + my_usage = gensub("\"", "", "g"); + next; + +} + +/BAREBOX_CMD_HELP_SHORT[[:space:]]*\((.*)\)/ { + + $0 = gensub("<", "\\<", "g"); + $0 = gensub(">", "\\>", "g"); + $0 = gensub("BAREBOX_CMD_HELP_SHORT[[:space:]]*\\((.*)\\)", "\\1", "g"); + $0 = gensub("\\\\n", "", "g"); + my_short = gensub("\"", "", "g"); + next; + +} + +/BAREBOX_CMD_HELP_OPT[[:space:]]*\([[:space:]]*(.*)[[:space:]]*,[[:space:]]*(.*)[[:space:]]*\)/ { + + $0 = gensub("<", "\\<", "g"); + $0 = gensub(">", "\\>", "g"); + $0 = gensub("@", "\\\\@", "g"); + $0 = gensub("BAREBOX_CMD_HELP_OPT[[:space:]]*\\([[:space:]]*\"*(.*)\"[[:space:]]*,[[:space:]]*\"(.*)\"[[:space:]]*\\)", \ + " \\1 \\ \\ \\  \\2 ", "g"); + $0 = gensub("\\\\n", "", "g"); + my_opts[this_opt] = gensub("\"", "", "g"); + this_opt ++; + next; +} + +/BAREBOX_CMD_HELP_TEXT[[:space:]]*\((.*)\)/ { + + $0 = gensub("<", "\\<", "g"); + $0 = gensub(">", "\\>", "g"); + $0 = gensub("BAREBOX_CMD_HELP_TEXT[[:space:]]*\\((.*)\\)", "\\1", "g"); + $0 = gensub("\\\\n", "
", "g"); + my_text[this_text] = gensub("\"", "", "g"); + this_text ++; + next; +} + +/BAREBOX_CMD_HELP_END/ { + + printf "/**\n"; + printf " * @page " my_cmd "_command " my_cmd "\n"; + printf " *\n"; + printf " * \\par Usage:\n"; + printf " * " my_usage "\n"; + printf " *\n"; + + if (this_opt != 0) { + printf " * \\par Options:\n"; + printf " *\n"; + printf " * \n"; + n = asorti(my_opts, my_opts_sorted); + for (i=1; i<=n; i++) { + printf " * " my_opts[my_opts_sorted[i]] "\n"; + } + printf " *
\n"; + printf " *\n"; + } + + printf " * " my_short "\n"; + printf " *\n"; + + n = asorti(my_text, my_text_sorted); + if (n > 0) { + for (i=1; i<=n; i++) { + printf " * " my_text[my_text_sorted[i]] "\n"; + } + printf " *\n"; + } + + printf " */\n"; + + next; +} + +/^.*$/ { + + print $0; + +} + -- cgit v1.2.3