Repository navigation
Conversation
Snippets marked with the `docs` class and a `file` attribute, either as
Pandoc fenced divs (`::: {.docs file=...}`) or as Markdown code blocks
(``` {.markdown .docs file=...} ```), are collected into one Markdown
target, grouped by `section` and sorted by `order`. Fenced divs are only
read when the hook is enabled; code inside them is not tangled.
The generated file is a regular annotated target, so edits can be
stitched back. To support this, hooks get a `post_read` method that is
called after loading, before both tangle and stitch.
Also adds Markdown to the default languages.
Closes #114
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On Windows the names contained backslashes, so references to them from the generated docs file did not resolve. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #114.
Summary
The new
docshook collects user documentation from across the chapters into a single generated Markdown file. A snippet can be written in either of two forms:::: {.docs file=reference.md section="The mel language" order=10} `mel("...")` reads a melody from text. ```python mel("g4:q bb4 d5") ``` ::: ``` {.markdown .docs file=reference.md section="Patches"} Patches are defined with `patch`. ```filegoes into that file. Snippets without asectioncome first, then each section follows under a heading (level set by thesection_levelhook config, default 2). Snippets are sorted byorder(default 0), then by reading order. A section's position comes from the lowestorderamong its snippets.docshook is enabled. Code fences and nested divs inside them are copied verbatim and are not tangled. Projects that don't enable the hook behave exactly as before.<!-- ~/~ begin <<chapters/a.md#...>>[init] -->), soentangled stitchmaps edits back to the chapters.Changes
entangled/readers/markdown.py: new reader for fenced divs; the namespace logic is factored into a shared helper.entangled/hooks/docs.py: the new hook.entangled/hooks/base.py,entangled/interface/document.py: newHookBase.post_read(refs), called at the end ofDocument.load. The docs target has to be registered there instead of inpre_tangle, becausestitchnever callspre_tangle.entangled/config/language.py: addsMarkdown(<!-- -->comments) to the default languages.Caveats
#idare namedunnamed-<file>:<line>. If a chapter is edited above a snippet and the generated file is then stitched before re-tangling, the names won't match. The docs should recommend giving snippets an#id.:::docsshorthand is not supported, since it has no way to give thefileattribute.Tests
test/hooks/test_docs_hook.pycovers ordering, sections, nested fences and divs, stitching back, and leaving divs alone when the hook is disabled. The full suite passes (103 tests).🤖 Generated with Claude Code