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 }; 18 19 enum HtmlEscaping { 20 NO_ESCAPING, 21 22 // Convert < and > to < and > when writing markdown output in non-code 23 // sections. 24 DEFAULT_ESCAPING, 25 }; 26 27 void OutputString(const std::string& output, 28 TextDecoration dec = DECORATION_NONE, 29 HtmlEscaping = DEFAULT_ESCAPING); 30 31 // If printing markdown, this generates table-of-contents entries with 32 // links to the actual help; otherwise, prints a one-line description. 33 void PrintSectionHelp(const std::string& line, 34 const std::string& topic, 35 const std::string& tag); 36 37 // Prints a line for a command, assuming there is a colon. Everything before 38 // the colon is the command (and is highlighted). After the colon if there is 39 // a square bracket, the contents of the bracket is dimmed. 40 // 41 // The link_tag is set, it will be used for markdown output links. This is 42 // used when generating the markdown for all help topics. If empty, no link tag 43 // will be emitted. In non-markdown mode, this parameter will be ignored. 44 // 45 // The line is indented 2 spaces. 46 void PrintShortHelp(const std::string& line, 47 const std::string& link_tag = std::string()); 48 49 // Prints a longer help section. 50 // 51 // Rules: 52 // - Lines beginning with non-whitespace are highlighted up to the first 53 // colon (or the whole line if not). 54 // - Lines whose first non-whitespace character is a # are dimmed. 55 // 56 // The tag will be used as a link target for the first header. This is used 57 // when generating the markdown for all help topics. If empty, no link tag will 58 // be emitted. Used only in markdown mode. 59 void PrintLongHelp(const std::string& text, const std::string& tag = ""); 60 61 #endif // TOOLS_GN_STANDARD_OUT_H_ 62