Skip to content

Commit

Permalink
Merge pull request #60 from MarcelKoch/parse-exception-qualifier
Browse files Browse the repository at this point in the history
Parse exception and ref qualifier
  • Loading branch information
JasperCraeghs authored Jan 21, 2025
2 parents 3060ac5 + 4cbf1f4 commit ee2dbca
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
15 changes: 10 additions & 5 deletions sphinxcontrib/doxylink/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,16 @@ def normalise(symbol: str) -> Tuple[str, str]:

# This is a very common signature so we'll make a special case for it. It requires no parsing anyway
if arglist_input_string.startswith('()'):
arglist_input_string_no_spaces = arglist_input_string.replace(' override', '').replace(' final', '').replace(' ', '')
if arglist_input_string_no_spaces in ('()', '()=0', '()=default'):
return function_name, '()'
if arglist_input_string_no_spaces in ('()const', '()const=0'):
return function_name, '() const'
arglist_input_string_no_spaces = arglist_input_string
substrings_to_remove = (' override', ' final', ' ', '=0', '=default')
for part in substrings_to_remove:
arglist_input_string_no_spaces = arglist_input_string_no_spaces.replace(part, '')
exception_qualifier = max(arglist_input_string_no_spaces.find('noexcept'),
arglist_input_string_no_spaces.find('throw'))
if exception_qualifier != -1:
# Remove everything starting with the exception keyword
arglist_input_string_no_spaces = arglist_input_string_no_spaces[:exception_qualifier]
return function_name, arglist_input_string_no_spaces.replace('const', ' const')

# By now we're left with something like "(blah, blah)", "(blah, blah) const" or "(blah, blah) const =0"
try:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
('(uint32_t uNoOfBlocksToProcess=(std::numeric_limits< uint32_t >::max)())', ('', '(uint32_t)')),
('( QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0 )', ('', '(QWidget*, const char*, Qt::WindowFlags)')),
('()', ('', '()')),
('() noexcept', ('', '()')),
('() const noexcept', ('', '() const')),
('() noexcept(true)', ('', '()')),
('() throw()', ('', '()')),
('() const throw()', ('', '() const')),
('() throw(false)', ('', '()')),
('() const &', ('', '() const&')),
('() &', ('', '()&')),
('() &&', ('', '()&&')),
('( int index = 0 )', ('', '(int)')),
('( bool ascending = true )', ('', '(bool)')),
('( const QIcon & icon, const QString & label, int width = -1 )', ('', '(const QIcon&, const QString&, int)')),
Expand Down

0 comments on commit ee2dbca

Please sign in to comment.