Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Unified Diff: tools/gn/command_help.cc

Issue 1024783002: Add a --markdown flag to GN to be able to output help in markdown. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn_all_help
Patch Set: fix bold/italic formatting Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/gn/command_help.cc
diff --git a/tools/gn/command_help.cc b/tools/gn/command_help.cc
index 409f921c2e48c4ab7bc16f78ff671471d020c56b..f80555c45d5d36de3ba2a99456fd8352efc76fae 100644
--- a/tools/gn/command_help.cc
+++ b/tools/gn/command_help.cc
@@ -69,18 +69,35 @@ void PrintToplevelHelp() {
}
void PrintSwitchHelp() {
+ const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
+ bool use_markdown = cmdline->HasSwitch(switches::kMarkdown);
+
OutputString("Available global switches\n", DECORATION_YELLOW);
OutputString(
" Do \"gn help --the_switch_you_want_help_on\" for more. Individual\n"
" commands may take command-specific switches not listed here. See the\n"
" help on your specific command for more.\n\n");
+ if (use_markdown)
+ OutputString("```\n\n", DECORATION_NONE);
+
for (const auto& s : switches::GetSwitches())
PrintShortHelp(s.second.short_help);
+
+ if (use_markdown)
+ OutputString("\n```\n", DECORATION_NONE);
}
void PrintAllHelp() {
- PrintToplevelHelp();
+ const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
+ if (cmdline->HasSwitch(switches::kMarkdown)) {
+ OutputString("# GN Reference\n\n");
+ OutputString("[TOC]\n\n");
+ OutputString("*This page is automatically generated from* "
+ "`gn help --markdown all`.\n\n");
+ } else {
+ PrintToplevelHelp();
+ }
for (const auto& s : switches::GetSwitches()) {
PrintLongHelp(s.second.long_help);
« no previous file with comments | « tools/gn/README.md ('k') | tools/gn/docs/reference.md » ('j') | tools/gn/docs/reference.md » ('J')

Powered by Google App Engine
This is Rietveld 408576698