mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Robert Schwebel <r.schwebel@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 19/32] doc: add macros to unify command help with doxygen
Date: Fri, 22 Oct 2010 18:45:11 +0200	[thread overview]
Message-ID: <1287765924-1856-20-git-send-email-r.schwebel@pengutronix.de> (raw)
In-Reply-To: <1287765924-1856-1-git-send-email-r.schwebel@pengutronix.de>

Currently we have duplicated all the information that appears online in
'help <command>' 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 <r.schwebel@pengutronix.de>
---
 Doxyfile                |    2 +-
 include/command.h       |    9 ++++
 scripts/doxy_filter.awk |  101 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 111 insertions(+), 1 deletions(-)
 create mode 100644 scripts/doxy_filter.awk

diff --git a/Doxyfile b/Doxyfile
index 912abc1..23f3e43 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -575,7 +575,7 @@ IMAGE_PATH             =
 # to standard output.  If FILTER_PATTERNS is specified, this tag will be
 # ignored.
 
-INPUT_FILTER           =
+INPUT_FILTER           = "awk -f scripts/doxy_filter.awk"
 
 # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
 # basis.  Doxygen will compare the file name with each pattern and apply the
diff --git a/include/command.h b/include/command.h
index 0be7a69..e221546 100644
--- a/include/command.h
+++ b/include/command.h
@@ -89,6 +89,15 @@ const struct command __barebox_cmd_##_name						\
 #define BAREBOX_CMD_END					\
 };
 
+#define BAREBOX_CMD_HELP_START(_name) \
+static const __maybe_unused char cmd_##_name##_help[] =
+
+#define BAREBOX_CMD_HELP_USAGE(_name) "Usage: " _name
+#define BAREBOX_CMD_HELP_SHORT(_text) _text
+#define BAREBOX_CMD_HELP_OPT(_opt, _desc) _opt "\t" _desc
+#define BAREBOX_CMD_HELP_TEXT(_text)
+#define BAREBOX_CMD_HELP_END ;
+
 #ifdef CONFIG_LONGHELP
 #define BAREBOX_CMD_HELP(text)	.help = text,
 #else
diff --git a/scripts/doxy_filter.awk b/scripts/doxy_filter.awk
new file mode 100644
index 0000000..0f6e891
--- /dev/null
+++ b/scripts/doxy_filter.awk
@@ -0,0 +1,101 @@
+#!/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("<", "\\&lt;", "g");
+	$0 = gensub(">", "\\&gt;", "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("<", "\\&lt;", "g");
+	$0 = gensub(">", "\\&gt;", "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("<", "\\&lt;", "g");
+	$0 = gensub(">", "\\&gt;", "g");
+	$0 = gensub("BAREBOX_CMD_HELP_OPT[[:space:]]*\\([[:space:]]*\"*(.*)\"[[:space:]]*,[[:space:]]*\"(.*)\"[[:space:]]*\\)", \
+		"<tr><td><tt> \\1 </tt></td><td>\\&nbsp;\\&nbsp;\\&nbsp;</td><td> \\2 </td></tr>", "g");
+	$0 = gensub("\\\\n", "", "g");
+	my_opts[this_opt] = gensub("\"", "", "g");
+	this_opt ++;
+	next;
+}
+
+/BAREBOX_CMD_HELP_TEXT[[:space:]]*\((.*)\)/ {
+
+	$0 = gensub("<", "\\&lt;", "g");
+	$0 = gensub(">", "\\&gt;", "g");
+	$0 = gensub("BAREBOX_CMD_HELP_TEXT[[:space:]]*\\((.*)\\)", "\\1", "g");
+	$0 = gensub("\\\\n", "<br>", "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 " * <table border=\"0\" cellpadding=\"0\">\n";
+		n = asorti(my_opts, my_opts_sorted);
+		for (i=1; i<=n; i++) {
+			printf " * " my_opts[my_opts_sorted[i]] "\n";
+		}
+		printf " * </table>\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;
+
+}
+
-- 
1.7.2.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2010-10-22 16:45 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-22 16:44 Documentation Updates Robert Schwebel
2010-10-22 16:44 ` [PATCH 01/32] reset_cpu: unify declaration Robert Schwebel
2010-10-22 16:44 ` [PATCH 02/32] Doxyfile: enable quiet output Robert Schwebel
2010-10-22 16:44 ` [PATCH 03/32] Doxyfile: remove obsolete boards directory Robert Schwebel
2010-10-22 16:44 ` [PATCH 04/32] Doxyfile: add exclude rules Robert Schwebel
2010-10-22 16:44 ` [PATCH 05/32] Doxyfile: remove non-existing directories Robert Schwebel
2010-10-22 16:44 ` [PATCH 06/32] Doxyfile: remove unused features Robert Schwebel
2010-10-22 16:44 ` [PATCH 07/32] Doxyfile: enable assembler files Robert Schwebel
2010-10-22 16:45 ` [PATCH 08/32] doc: let doxygen find some assembler functions Robert Schwebel
2010-10-22 16:45 ` [PATCH 09/32] doc: remove nonexisting command Robert Schwebel
2010-10-22 16:45 ` [PATCH 10/32] doc: remove reference to non-existing documentation Robert Schwebel
2010-10-22 16:45 ` [PATCH 11/32] doc: eliminate nonexisting reference Robert Schwebel
2010-10-22 16:45 ` [PATCH 12/32] doc: add missing quoting Robert Schwebel
2010-10-22 16:45 ` [PATCH 13/32] doc: fix typo Robert Schwebel
2010-10-22 17:21   ` Juergen Beisert
2010-10-22 16:45 ` [PATCH 14/32] doc: mark code explicitely Robert Schwebel
2010-10-22 16:45 ` [PATCH 15/32] doc: avoid that doxygen parses magic in command.h Robert Schwebel
2010-10-22 16:45 ` [PATCH 16/32] doc: fix wrongly named parameter Robert Schwebel
2010-10-22 16:45 ` [PATCH 17/32] doc: fix parameter name in mci-core Robert Schwebel
2010-10-22 16:45 ` [PATCH 18/32] doc: silence doxygen warnings Robert Schwebel
2010-10-22 18:50   ` Sascha Hauer
2010-10-22 16:45 ` Robert Schwebel [this message]
2010-10-22 16:45 ` [PATCH 20/32] doc: add documentation for 'bmp' Robert Schwebel
2010-10-22 16:45 ` [PATCH 21/32] doc: add documentation for 'clear' Robert Schwebel
2010-10-22 16:45 ` [PATCH 22/32] doc: add documentation for 'crc32' Robert Schwebel
2010-10-22 16:45 ` [PATCH 23/32] doc: add documentation for 'dfu' Robert Schwebel
2010-10-22 16:45 ` [PATCH 24/32] doc: unify documentation for 'ls' Robert Schwebel
2010-10-22 16:45 ` [PATCH 25/32] doc: unify documentation for 'cat' Robert Schwebel
2010-10-22 16:45 ` [PATCH 26/32] doc: unify documentation for 'cd' Robert Schwebel
2010-10-22 16:45 ` [PATCH 27/32] doc: add documentation for 'echo' Robert Schwebel
2010-10-22 16:45 ` [PATCH 28/32] doc: unify documentation for 'edit' Robert Schwebel
2010-10-22 16:45 ` [PATCH 29/32] doc: add documentation for 'bootm' Robert Schwebel
2010-10-22 16:45 ` [PATCH 30/32] doc: unify documentation for 'addpart' Robert Schwebel
2010-10-22 16:45 ` [PATCH 31/32] doc: unify documentation for 'cp' Robert Schwebel
2010-10-22 16:45 ` [PATCH 32/32] doc: unify documentation for 'delpart' Robert Schwebel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1287765924-1856-20-git-send-email-r.schwebel@pengutronix.de \
    --to=r.schwebel@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox