Skip to content

fix: drop CrossrefProcessor that corrupts URL fragments in docstrings#83

Merged
barjin merged 2 commits into
masterfrom
fix/crossref-mangles-url-fragments
Jun 19, 2026
Merged

fix: drop CrossrefProcessor that corrupts URL fragments in docstrings#83
barjin merged 2 commits into
masterfrom
fix/crossref-mangles-url-fragments

Conversation

@vdusek

@vdusek vdusek commented Jun 18, 2026

Copy link
Copy Markdown

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.

@vdusek vdusek self-assigned this Jun 18, 2026
@vdusek vdusek marked this pull request as ready for review June 18, 2026 12:38
@vdusek vdusek requested a review from barjin June 18, 2026 12:38
@vdusek

vdusek commented Jun 19, 2026

Copy link
Copy Markdown
Author

@barjin see apify/apify-client-python#865 - for the consequences this causes.

@barjin barjin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, thank you @vdusek !

@barjin barjin merged commit 8136598 into master Jun 19, 2026
3 checks passed
@barjin barjin deleted the fix/crossref-mangles-url-fragments branch June 19, 2026 11:28
@barjin

barjin commented Jun 19, 2026

Copy link
Copy Markdown
Member

released in 5.1.14 (see npm)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants