summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpaul_hoad <paul_hoad@amat.com>2019-11-08 14:34:07 +0000
committerpaul_hoad <paul_hoad@amat.com>2019-11-08 14:40:36 +0000
commiteb00839c6eb4f5dc6adadc83be93f32bd6143362 (patch)
tree17e34e0b4ca2f6f94f36c2eea8d5ca54537fccfd
parent1d321434a202b12b3afe6f305262b930bbf05665 (diff)
downloadbcm5719-llvm-eb00839c6eb4f5dc6adadc83be93f32bd6143362.tar.gz
bcm5719-llvm-eb00839c6eb4f5dc6adadc83be93f32bd6143362.zip
[clang-format] Ensure dump_format_style.py can generate ClangFormatStyleOptions.rst without manual intervention
Summary: This revision is the last in a series of revisions to return `clang/doc/tools/dump_format_style.py` to be being able to parse Format.h without needing to manually merge the ClangFormatStyleOptions.rst file. The final modification to dump_format_style.py is needed following the addition of a nested enumeration inside a nested structure following the introduction of {D68296} Prior related revisions will allow for a fully clang-formatted `clang/include/clang/Format/Format.h` to once again be used at the source. {D69951} {D69433} {D69404} Reviewers: mitchell-stellar, klimek, sammccall, owenpan Reviewed By: mitchell-stellar Subscribers: cfe-commits Tags: #clang-format, #clang Differential Revision: https://reviews.llvm.org/D70003
-rw-r--r--clang/docs/ClangFormatStyleOptions.rst1
-rwxr-xr-xclang/docs/tools/dump_format_style.py21
2 files changed, 21 insertions, 1 deletions
diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index 1f915c34688..655923db9bc 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -819,6 +819,7 @@ the configuration (without a prefix: ``Auto``).
for (int i = 0; i < 10; ++i)
{}
+
* ``bool AfterEnum`` Wrap enum definitions.
.. code-block:: c++
diff --git a/clang/docs/tools/dump_format_style.py b/clang/docs/tools/dump_format_style.py
index db65e6e65b1..acb0dfcaf4a 100755
--- a/clang/docs/tools/dump_format_style.py
+++ b/clang/docs/tools/dump_format_style.py
@@ -77,6 +77,20 @@ class Enum(object):
def __str__(self):
return '\n'.join(map(str, self.values))
+class NestedEnum(object):
+ def __init__(self, name, enumtype, comment, values):
+ self.name = name
+ self.comment = comment
+ self.values = values
+ self.type = enumtype
+
+ def __str__(self):
+ s = '\n* ``%s %s``\n%s' % (self.type, self.name,
+ doxygen2rst(indent(self.comment, 2)))
+ s += indent('\nPossible values:\n\n', 2)
+ s += indent('\n'.join(map(str, self.values)),2)
+ return s;
+
class EnumValue(object):
def __init__(self, name, comment, config):
self.name = name
@@ -156,7 +170,12 @@ def read_options(header):
comment += clean_comment_line(line)
else:
state = State.InNestedStruct
- nested_struct.values.append(NestedField(line.replace(';', ''), comment))
+ field_type, field_name = re.match(r'([<>:\w(,\s)]+)\s+(\w+);',line).groups()
+ if field_type in enums:
+ nested_struct.values.append(NestedEnum(field_name,field_type,comment,enums[field_type].values))
+ else:
+ nested_struct.values.append(NestedField(field_type + " " + field_name, comment))
+
elif state == State.InEnum:
if line.startswith('///'):
state = State.InEnumMemberComment
OpenPOWER on IntegriCloud