* ``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``)
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
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):
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
with open(DOC_FILE, 'wb') as output:
output.write(contents)
-