Skip to content

Commit

Permalink
doxygen: parse function attributes also without leading space.
Browse files Browse the repository at this point in the history
  • Loading branch information
mosra committed Feb 23, 2019
1 parent 193ab80 commit 38e0d62
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 10 deletions.
22 changes: 12 additions & 10 deletions doxygen/dox2html5.py
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,8 @@ def parse_func(state: State, element: ET.Element):
if func.type.startswith('friend '):
func.type = func.type[7:]

def is_identifier(a): return a == '_' or a.isalnum()

# Extract function signature to prefix, suffix and various flags. Important
# things affecting caller such as static or const (and rvalue overloads)
# are put into signature prefix/suffix, other things to various is_*
Expand Down Expand Up @@ -1882,24 +1884,24 @@ def parse_func(state: State, element: ET.Element):
func.is_pure_virtual = False
# Final tested twice because it can be both `override final`
func.is_final = False
if signature.endswith(' final'):
signature = signature[:-6]
if signature.endswith('final') and not is_identifier(signature[-6]):
signature = signature[:-5].rstrip()
func.is_final = True
if signature.endswith(' override'):
signature = signature[:-9]
if signature.endswith('override') and not is_identifier(signature[-9]):
signature = signature[:-8].rstrip()
func.is_override = True
else:
func.is_override = False
# ... and `final override`
if signature.endswith(' final'):
signature = signature[:-6]
if signature.endswith('final') and not is_identifier(signature[-6]):
signature = signature[:-5].rstrip()
func.is_final = True
if signature.endswith(' noexcept'):
signature = signature[:-9]
if signature.endswith('noexcept') and not is_identifier(signature[-9]):
signature = signature[:-8].rstrip()
func.is_noexcept = True
func.is_conditional_noexcept = False
elif ' noexcept(' in signature:
signature = signature[:signature.index(' noexcept(')]
elif 'noexcept(' in signature and not is_identifier(signature[signature.index('noexcept(') - 1]):
signature = signature[:signature.index('noexcept(')].rstrip()
func.is_noexcept = True
func.is_conditional_noexcept = True
else:
Expand Down
14 changes: 14 additions & 0 deletions doxygen/test/cpp_function_attributes_nospace/Doxyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
INPUT = input.h
AUTOLINK_SUPPORT = NO
QUIET = YES
GENERATE_HTML = NO
GENERATE_LATEX = NO
GENERATE_XML = YES
XML_PROGRAMLISTING = NO

##! M_PAGE_FINE_PRINT =
##! M_THEME_COLOR =
##! M_FAVICON =
##! M_LINKS_NAVBAR1 =
##! M_LINKS_NAVBAR2 =
##! M_SEARCH_DISABLED = YES
21 changes: 21 additions & 0 deletions doxygen/test/cpp_function_attributes_nospace/input.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/** @brief Base class */
class Base {
virtual void doThing()noexcept;
virtual void doAnotherThing();
virtual void doYetAnotherThing();
};

/** @brief Keywords without spaces */
struct Foo: Base {
/** @brief Final w/o override (will cause a compiler warning), w/o a space */
void doThing() &&noexcept final;

/** @brief Do more things, without a space */
void doMoreStuff() &&noexcept(false);

/** @brief Final override, without a space */
void doAnotherThing() &&final override;

/** @brief Override final, without a space */
void doYetAnotherThing() &&override final;
};
73 changes: 73 additions & 0 deletions doxygen/test/cpp_function_attributes_nospace/structFoo.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions doxygen/test/test_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,11 @@ def test(self):
self.assertEqual(*self.actual_expected_contents('classBase.html'))
self.assertEqual(*self.actual_expected_contents('classDerived.html'))
self.assertEqual(*self.actual_expected_contents('structFinal.html'))

class FunctionAttributesNospace(IntegrationTestCase):
def __init__(self, *args, **kwargs):
super().__init__(__file__, 'function_attributes_nospace', *args, **kwargs)

def test(self):
self.run_dox2html5(wildcard='structFoo.xml')
self.assertEqual(*self.actual_expected_contents('structFoo.html'))

0 comments on commit 38e0d62

Please sign in to comment.