Odoc merge word runs - #1488
Open
jonludlam wants to merge 5 commits into
Open
Conversation
OxCaml's ppx_template-heavy libraries attach the same comment text to
thousands of monomorphised copies (Container_intf in OxCaml's base:
~155K comments, 33 unique). Cache parse results keyed on the text —
but only parses that produced no warnings and contain no
location-sensitive constructs (headings, references, {!modules ...}),
since the AST bakes in absolute locations from the first occurrence.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
comment_docs rebuilt every docs element even though linking only
changes references, headings and {!modules ...} lists. Return the
input unchanged when none are present.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comments are parsed into one `Word`/`Space` node per token, and those per-word locations dominate .odoc and .odocl size while the backends only read the values. Coalesce each maximal run into a single `Word`, on the Ast so that Doc_attr's parse cache holds the merged form and repeated comments share it. The whitespace is kept verbatim, so offsets into a merged `Word` still map back to the source; `Space` carries its string for the same reason. The document layer collapses it for rendering, as does generate_heading_label when hyphenating, leaving anchors unchanged. Frontmatter tags are left unmerged: they report warnings against individual words. The markdown fixtures lose escapes that were never needed: `-` and `1.` matter only at the start of a line, and the escaper keys off the start of the string it is given, which used to be a single word. Co-Authored-By: Claude Opus 5 (1M context) <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.
Rather than storing comments as
[`Word "rather"; `Space; `Word "than"; `Space; `Word "storing";...]each of which actually also carries a location, store them as just one:[`Word "rather than storing ..."]This is built on top of #1480 so we can be sure it doesn't clobber the memoizing.