diff options
author | Krasimir Georgiev <krasimir@google.com> | 2017-06-23 11:29:40 +0000 |
---|---|---|
committer | Krasimir Georgiev <krasimir@google.com> | 2017-06-23 11:29:40 +0000 |
commit | 4c8bc8646c93899503aa9efbb92832e952c4bbec (patch) | |
tree | fd6d84cbcaf78924aee6fd96b92454045c0a1c07 /docs | |
parent | 8864382ad994c9d0b90802128e349c04677feb4d (diff) | |
download | clang-4c8bc8646c93899503aa9efbb92832e952c4bbec.tar.gz |
[clang-format] Update dump_format_style.py to indent nested fields
Summary:
This updates the format options documentation script to indent the
documentation of nested fields. The previous format caused some problems,
as when a bulleted list ends with a multiline comment. See the buildbot failure
http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/10020/steps/docs-clang-html/logs/stdio
Reviewers: djasper
Reviewed By: djasper
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D34552
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306093 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs')
-rw-r--r-- | docs/ClangFormatStyleOptions.rst | 204 | ||||
-rwxr-xr-x | docs/tools/dump_format_style.py | 11 |
2 files changed, 108 insertions, 107 deletions
diff --git a/docs/ClangFormatStyleOptions.rst b/docs/ClangFormatStyleOptions.rst index a94a8b67a4..8555f06875 100644 --- a/docs/ClangFormatStyleOptions.rst +++ b/docs/ClangFormatStyleOptions.rst @@ -538,158 +538,158 @@ the configuration (without a prefix: ``Auto``). * ``bool AfterClass`` Wrap class definitions. - .. code-block:: c++ + .. code-block:: c++ - true: - class foo {}; + true: + class foo {}; - false: - class foo - {}; + false: + class foo + {}; * ``bool AfterControlStatement`` Wrap control statements (``if``/``for``/``while``/``switch``/..). - .. code-block:: c++ + .. code-block:: c++ - true: - if (foo()) - { - } else - {} - for (int i = 0; i < 10; ++i) - {} + true: + if (foo()) + { + } else + {} + for (int i = 0; i < 10; ++i) + {} - false: - if (foo()) { - } else { - } - for (int i = 0; i < 10; ++i) { - } + false: + if (foo()) { + } else { + } + for (int i = 0; i < 10; ++i) { + } * ``bool AfterEnum`` Wrap enum definitions. - .. code-block:: c++ + .. code-block:: c++ - true: - enum X : int - { - B - }; + true: + enum X : int + { + B + }; - false: - enum X : int { B }; + false: + enum X : int { B }; * ``bool AfterFunction`` Wrap function definitions. - .. code-block:: c++ + .. code-block:: c++ - true: - void foo() - { - bar(); - bar2(); - } + true: + void foo() + { + bar(); + bar2(); + } - false: - void foo() { - bar(); - bar2(); - } + false: + void foo() { + bar(); + bar2(); + } * ``bool AfterNamespace`` Wrap namespace definitions. - .. code-block:: c++ + .. code-block:: c++ - true: - namespace - { - int foo(); - int bar(); - } + true: + namespace + { + int foo(); + int bar(); + } - false: - namespace { - int foo(); - int bar(); - } + false: + namespace { + int foo(); + int bar(); + } * ``bool AfterObjCDeclaration`` Wrap ObjC definitions (``@autoreleasepool``, interfaces, ..). * ``bool AfterStruct`` Wrap struct definitions. - .. code-block:: c++ + .. code-block:: c++ - true: - struct foo - { - int x; - }; + true: + struct foo + { + int x; + }; - false: - struct foo { - int x; - }; + false: + struct foo { + int x; + }; * ``bool AfterUnion`` Wrap union definitions. - .. code-block:: c++ + .. code-block:: c++ - true: - union foo - { - int x; - } + true: + union foo + { + int x; + } - false: - union foo { - int x; - } + false: + union foo { + int x; + } * ``bool BeforeCatch`` Wrap before ``catch``. - .. code-block:: c++ + .. code-block:: c++ - true: - try { - foo(); - } - catch () { - } + true: + try { + foo(); + } + catch () { + } - false: - try { - foo(); - } catch () { - } + false: + try { + foo(); + } catch () { + } * ``bool BeforeElse`` Wrap before ``else``. - .. code-block:: c++ + .. code-block:: c++ - true: - if (foo()) { - } - else { - } + true: + if (foo()) { + } + else { + } - false: - if (foo()) { - } else { - } + false: + if (foo()) { + } else { + } * ``bool IndentBraces`` Indent the wrapped braces themselves. * ``bool SplitEmptyFunctionBody`` If ``false``, empty function body can be put on a single line. - This option is used only if the opening brace of the function has - already been wrapped, i.e. the `AfterFunction` brace wrapping mode is - set, and the function could/should not be put on a single line (as per - `AllowShortFunctionsOnASingleLine` and constructor formatting options). + This option is used only if the opening brace of the function has + already been wrapped, i.e. the `AfterFunction` brace wrapping mode is + set, and the function could/should not be put on a single line (as per + `AllowShortFunctionsOnASingleLine` and constructor formatting options). - .. code-block:: c++ + .. code-block:: c++ - int f() vs. inf f() - {} { - } + int f() vs. inf f() + {} { + } **BreakAfterJavaFieldAnnotations** (``bool``) diff --git a/docs/tools/dump_format_style.py b/docs/tools/dump_format_style.py index 81a5af6ef4..e2571f4644 100755 --- a/docs/tools/dump_format_style.py +++ b/docs/tools/dump_format_style.py @@ -24,10 +24,10 @@ def doxygen2rst(text): text = re.sub(r'\\\w+ ', '', text) return text -def indent(text, columns): +def indent(text, columns, indent_first_line=True): indent = ' ' * columns s = re.sub(r'\n([^\n])', '\n' + indent + '\\1', text, flags=re.S) - if s.startswith('\n'): + if not indent_first_line or s.startswith('\n'): return s return indent + s @@ -64,7 +64,9 @@ class NestedField: self.comment = comment.strip() def __str__(self): - return '\n* ``%s`` %s' % (self.name, doxygen2rst(self.comment)) + return '\n* ``%s`` %s' % ( + self.name, + doxygen2rst(indent(self.comment, 2, indent_first_line=False))) class Enum: def __init__(self, name, comment): @@ -179,7 +181,7 @@ def read_options(header): if enums.has_key(option.type): option.enum = enums[option.type] elif nested_structs.has_key(option.type): - option.nested_struct = nested_structs[option.type]; + option.nested_struct = nested_structs[option.type] else: raise Exception('Unknown type: %s' % option.type) return options @@ -195,4 +197,3 @@ contents = substitute(contents, 'FORMAT_STYLE_OPTIONS', options_text) with open(DOC_FILE, 'wb') as output: output.write(contents) - |