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

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 dropped variable 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
« no previous file with comments | « tools/gn/README.md ('k') | tools/gn/docs/reference.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/command_help.cc
diff --git a/tools/gn/command_help.cc b/tools/gn/command_help.cc
index cf67a06244777cbd8b817cc24abb0b49fc3b8c77..fda8269664b337a62d9cbcb4cec369267b3f430d 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698