Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse exception and ref qualifier #60

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')
JasperCraeghs marked this conversation as resolved.
Show resolved Hide resolved
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
Loading