• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef TOOLS_GN_STANDARD_OUT_H_
6 #define TOOLS_GN_STANDARD_OUT_H_
7 
8 #include <string>
9 
10 enum TextDecoration {
11   DECORATION_NONE = 0,
12   DECORATION_DIM,
13   DECORATION_RED,
14   DECORATION_GREEN,
15   DECORATION_BLUE,
16   DECORATION_YELLOW,
17   DECORATION_MAGENTA
18 };
19 
20 enum HtmlEscaping {
21   NO_ESCAPING,
22 
23   // Convert < and > to &lt; and &gt; when writing markdown output in non-code
24   // sections.
25   DEFAULT_ESCAPING,
26 };
27 
28 void OutputString(const std::string& output,
29                   TextDecoration dec = DECORATION_NONE,
30                   HtmlEscaping = DEFAULT_ESCAPING);
31 
32 // If printing markdown, this generates table-of-contents entries with
33 // links to the actual help; otherwise, prints a one-line description.
34 void PrintSectionHelp(const std::string& line,
35                       const std::string& topic,
36                       const std::string& tag);
37 
38 // Prints a line for a command, assuming there is a colon. Everything before
39 // the colon is the command (and is highlighted). After the colon if there is
40 // a square bracket, the contents of the bracket is dimmed.
41 //
42 // The link_tag is set, it will be used for markdown output links. This is
43 // used when generating the markdown for all help topics. If empty, no link tag
44 // will be emitted. In non-markdown mode, this parameter will be ignored.
45 //
46 // The line is indented 2 spaces.
47 void PrintShortHelp(const std::string& line,
48                     const std::string& link_tag = std::string());
49 
50 // Prints a longer help section.
51 //
52 // Rules:
53 // - Lines beginning with non-whitespace are highlighted up to the first
54 //   colon (or the whole line if not).
55 // - Lines whose first non-whitespace character is a # are dimmed.
56 //
57 // The tag will be used as a link target for the first header. This is used
58 // when generating the markdown for all help topics. If empty, no link tag will
59 // be emitted. Used only in markdown mode.
60 void PrintLongHelp(const std::string& text, const std::string& tag = "");
61 
62 #endif  // TOOLS_GN_STANDARD_OUT_H_
63