Skip to content

Commit

Permalink
Merge pull request #62 from MarcelKoch/parse-parameter-pack
Browse files Browse the repository at this point in the history
Handle parameter packs `T...`
  • Loading branch information
JasperCraeghs authored Jan 21, 2025
2 parents a976300 + 0410fe6 commit fe6e241
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sphinxcontrib/doxylink/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ def normalise_templates(toks):

# A combination building up the interesting bit -- the argument type, e.g. 'const QString &', 'int' or 'char*'
argument_type = Opt(qualifier, default='')("qualifier1") + \
input_type("input_type").setParseAction(' '.join) + Opt(qualifier, default='')("qualifier2") + Group(ZeroOrMore(pointer_or_reference))("pointer_or_references")
input_type("input_type").setParseAction(' '.join) + \
Opt(qualifier, default='')("qualifier2") + \
Group(ZeroOrMore(pointer_or_reference))("pointer_or_references") + \
Opt('...')("parameter_pack")

# Argument + variable name + default
argument = Group(argument_type('argument_type') + Opt(input_name) + Opt(default_value))
Expand Down Expand Up @@ -137,6 +140,9 @@ def normalise(symbol: str) -> Tuple[str, str]:
# Functions can have a funny combination of *, & and const between the type and the name so build up a list of those here:
argument_string_list.extend(''.join(arg.pointer_or_references))

# Add template parameter pack
argument_string_list.append(arg.parameter_pack)

# Finally we join our argument string and add it to our list
normalised_arg_list.append(''.join(argument_string_list))

Expand Down
1 change: 1 addition & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
]

varargs = [
('(Args&& ... args)', ('', '(Args&&...)')),
('(int nb=0,...)', ('', '(int, ...)')),
('printf( const char* format, ... )', ('printf', '(const char*, ...)')),
('fprintf( std::FILE* stream, const char* format, ... )', ('fprintf', '(std::FILE*, const char*, ...)')),
Expand Down

0 comments on commit fe6e241

Please sign in to comment.