docs: rewrite out-of-docs links on the element tree instead of the raw Markdown
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Refactoring
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- markdown, python
- Ambito
- documentation, tooling
Direzione di ricerca
Start with dokimi/scripts/docs/hooks.py: the regex rewrite in on_page_markdown and the _REFDEF pattern are what gets replaced, and on_config is where a Markdown treeprocessor would be registered. Read how mkdocs' own relpath treeprocessor orders itself so the new one runs before it. Done means tests/test_docs_hooks.py covers links inside fenced and inline code, a link with a title, an angle-bracket link, a reference-style image, and a raw <a href> case, and each passes with the old behaviour kept for in-docs/ and missing targets.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Follow-up to #6 (review comment https://github.com/intel/dokimi/pull/6#discussion_r4270668787).
dokimi/scripts/docs/hooks.py points links that leave docs/ at the file on GitHub. It does that with regexes over the raw Markdown in on_page_markdown, which has known gaps. The current docs don't hit any of them: the hook changes exactly the real out-of-docs links. But any of them can start to matter as the docs change.
Gaps of the regex approach
- Code is rewritten too. The regexes also match inside fenced, indented and inline code. A
[x](../dokimi/cli.py)in a code sample becomes a GitHub URL on the rendered page, and_REFDEFmatches a[tool]: ../xline inside a TOML fence. - Titles and angle brackets are missed.
[x](../a "title")and[x](<../a>)are not rewritten. That is safe, because they then fail--strict, but they can't be used. - Raw HTML is missed. A raw
<a href="../x">or<img src="../x">is not rewritten, and mkdocs doesn't validate raw HTML, so it would 404 on the site without a warning. - Images only partly. #6 gives inline images (
) araw/URL. An image written through a reference definition (![x][id]with[id]: ../x.png) still getsblob/, which is an HTML page.
Proposed fix
Rewrite on the element tree instead of the text:
- Register a Markdown treeprocessor from
on_config, with a priority above mkdocs' ownrelpathtreeprocessor (0), so it sees the links before mkdocs resolves them. - Rewrite
a[href]andimg[src]:blob/(ortree/for a directory) for links,raw/for images. - Keep the behaviour #6 added: leave targets inside
docs/and missing targets alone, so mkdocs' "not found" warning still fails--strict, and warn, naming the page, on a target outside the repository.
Code is then never touched, titles and angle brackets are handled by the parser, and reference-style images get raw/ too. Raw HTML stays out of reach of a treeprocessor (it is stashed as a placeholder), so it would need either a postprocessor over the stashed HTML or a check that fails on a relative href/src in raw HTML.
Tests
Extend tests/test_docs_hooks.py with links in a fence, in inline code, with a title, in angle brackets, a reference-style image, and a raw <a href>.
- Lingua principale
- Python
- Stelle
- 8
- Fork
- 7
- Merge medio
- 1g 55m
- PR unite (30g)
- 126
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di intel/dokimi
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
dependencies
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
I maintainer di solito rispondono entro 1 giorno
-
User loop: eval engine contracts (plan/validate/compare/gate/record), 3 skills, GitHub ActionForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 18/100
intel/dokimi#121 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di intel/dokimi
Issue simili
-
Python Volcengine provider returns failures instead of raising themForse già presa @Ricardo-M-L l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
agent-infra/sandbox#248 ·
-
Textractor leaves empty temporary files when remote retrieval failsForse già presa @HuaTNA l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
test(bm_generation): pin the learning parameters and CPU sync shortcutForse già presa @iloveeyjafjalla l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
qboson/kaiwu-pytorch-plugin#1341 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
elder-plinius/V3R1T4S#625 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
foxglove/mcap#1907 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno