Skip to content

Commit

Permalink
feat: relative cross-references
Browse files Browse the repository at this point in the history
Fixes mkdocstrings#27

This commit fixes:
 - the regular expression for checking valid python identifiers
 - update of line offset into doc string for error messages
  • Loading branch information
analog-cbarber committed Jun 26, 2022
1 parent a83252e commit 0ec859c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mkdocstrings_handlers/python/crossref.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _re_named(name: str, exp: str, optional: bool = False) -> str:
- 'current': an expression of the form '.'
"""

_RE_ID = re.compile("[a-zA-Z][a-zA-Z_.]*")
_RE_ID = re.compile("[a-zA-Z_][a-zA-Z0-9_.]*")
"""Regular expression that matches a qualified python identifier."""


Expand Down Expand Up @@ -221,7 +221,7 @@ def _error(self, msg: str) -> None:
line = doc.lineno
if line is not None:
# Add line offset to match in docstring
line + doc.value.count("\n", 0, self._cur_offset)
line += doc.value.count("\n", 0, self._cur_offset)
prefix += f"{line}:"
# It would be nice to add the column as well, but we cannot determine
# that without knowing how much the doc string was unindented.
Expand Down
2 changes: 2 additions & 0 deletions tests/test_crossref.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,5 @@ def test_substitute_relative_crossrefs(caplog):
[bar][mod1.mod2.bar]
"""
) # noqa: WPS355

assert not caplog.records

0 comments on commit 0ec859c

Please sign in to comment.