Skip to content

Commit

Permalink
Fix matching a tricky function case
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Wouda committed Feb 2, 2024
1 parent c91bc59 commit d0fe546
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docblock/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
_OP = pp.Word("<>!=&|*/+-~^", min=1, max=3) | "()" | "[]"
OPERATOR = pp.Combine("operator" + _OP)
FUNC_NAME = OPERATOR | QUALIFIED_ID
ARG_LIST = LPAR + ... + RPAR[1, ...]
LAST_RPAR = RPAR + ~pp.FollowedBy(pp.Word("),"))
ARG_LIST = LPAR + ... + LAST_RPAR
FUNC = FUNC_NAME + (ARG_LIST + ID[...] + CLOSE_STMT).suppress()

# Line comment and documentation blocks.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "docblock"
version = "0.1.4"
version = "0.1.5"
description = "Reads and parses documentation from header files in pure Python."
authors = ["Niels Wouda <nielswouda@gmail.com>"]
license = "MIT"
Expand Down
8 changes: 8 additions & 0 deletions tests/test_grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ def test_func_matches_complicated():
"""
)

assert FUNC.matches(
"""
timeWarp(Duration const maxDuration
= std::numeric_limits<Duration>::max(),
Duration const maxOvertime = 0) const;
"""
)

assert not FUNC.matches(
"""
operator[](size_t idx) const
Expand Down

0 comments on commit d0fe546

Please sign in to comment.