Skip to content

Commit 8136598

Browse files
vdusekbarjin
andauthored
fix: drop CrossrefProcessor that corrupts URL fragments in docstrings (#83)
pydoc-markdown's `CrossrefProcessor` is run with `resolver=None` in `generate_ast.py`, so it can never resolve a `#ref` into a real link — it only falls back to wrapping the ref in backticks. Its regex `\B#([\w\d._]+)` also matches any `#word` preceded by a non-word char, so URL fragments like `.../dockerfile_best-practices/#leverage-build-cache` (the `/#` sequence) get corrupted into broken links such as ``...best-practices/`leverage`-build-cache``. The Apify docstrings don't use `#ref` cross-references, so this drops `CrossrefProcessor` from the processor list — it brought no benefit (never produced links) and only corrupted fragments. This also matches the griffe-based extractor, which doesn't run it either. Verified by running the patched `generate_ast.py` against apify-client-python: the generated AST now contains `#leverage-build-cache` intact. --------- Co-authored-by: Jindřich Bär <jindrichbar@gmail.com>
1 parent ca1da39 commit 8136598

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

python-scripts/docspec-gen/generate_ast.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from pydoc_markdown.interfaces import Context
88
from pydoc_markdown.contrib.loaders.python import PythonLoader
99
from pydoc_markdown.contrib.processors.filter import FilterProcessor
10-
from pydoc_markdown.contrib.processors.crossref import CrossrefProcessor
1110
from google_docstring_processor import ApifyGoogleProcessor
1211
from docspec import dump_module
1312

@@ -43,15 +42,13 @@ def main():
4342
documented_only=False,
4443
skip_empty_modules=False,
4544
)
46-
crossref = CrossrefProcessor()
4745
google = ApifyGoogleProcessor()
4846

4947
loader.init(context)
5048
filter.init(context)
5149
google.init(context)
52-
crossref.init(context)
5350

54-
processors = [filter, google, crossref]
51+
processors = [filter, google]
5552

5653
dump = []
5754

0 commit comments

Comments
 (0)