[PATCH] D70003: [clang-format] Ensure dump_format_style.py can generate ClangFormatStyleOptions.rst without manual intervention
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 8 03:37:25 PST 2019
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: mitchell-stellar, klimek, sammccall, owenpan.
MyDeveloperDay added projects: clang-format, clang.
MyDeveloperDay added a comment.
Just in case you want proof the generated html looks the same:
F10665472: image.png <https://reviews.llvm.org/F10665472>
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: [clang-format] Add ability to wrap braces after multi-line control statements <https://reviews.llvm.org/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: [clang-format] NFC allow Format.h to be clang-formatted but still maintain the same doc layout in ClangFormatStyleOptions.rst <https://reviews.llvm.org/D69951>
D69433: [clang-format] [NFC] update the documentation in Format.h to allow dump_format_style.py to get a little closer to being correct. (part 2) <https://reviews.llvm.org/D69433>
D69404: [clang-format] [NFC] update the documentation in Format.h to allow dump_format_style.py to get a little closer to being correct. <https://reviews.llvm.org/D69404>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D70003
Files:
clang/docs/ClangFormatStyleOptions.rst
clang/docs/tools/dump_format_style.py
Index: clang/docs/tools/dump_format_style.py
===================================================================
--- clang/docs/tools/dump_format_style.py
+++ clang/docs/tools/dump_format_style.py
@@ -77,6 +77,20 @@
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 @@
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
Index: clang/docs/ClangFormatStyleOptions.rst
===================================================================
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -819,6 +819,7 @@
for (int i = 0; i < 10; ++i)
{}
+
* ``bool AfterEnum`` Wrap enum definitions.
.. code-block:: c++
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70003.228402.patch
Type: text/x-patch
Size: 1826 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191108/92fb2cf6/attachment.bin>
More information about the cfe-commits
mailing list