fix(build): collect per-doc order/group frontmatter for book sorting#1944
Merged
Conversation
collectDocsFromSrc parsed only title:/description: from src/docs/*.md frontmatter, so the order/group fields on the Doc schema (ADR-0046 §6) were never populated on the compiled doc item. resolveBookTree already sorts group members by doc.order then label and honors explicit doc.group placement, but the collection half silently dropped both, so frontmatter-driven sorting/placement never reached the artifact. parseFrontmatter now also reads order: (parsed to a number; ignored when non-numeric) and group: (string), threaded onto the collected doc when present; absent leaves both undefined so schema/resolver defaults apply. Also corrects the order JSDoc in doc.zod.ts to match the resolver, which treats absent order as 0 (not "after ordered siblings").
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 2 package(s): 92 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
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.
Problem
The CLI doc collector (
collectDocsFromSrc) parsed onlytitle:/description:from eachsrc/docs/*.mdfrontmatter, so theorderandgroupfields defined on theDocschema (ADR-0046 §6) were never populated on the compileddocitem.The book resolver (
resolveBookTree) already sorts group members bydoc.orderthen label and honors explicitdoc.groupplacement — but with the collection half silently dropping both fields, frontmatter-driven sorting/placement never reached the artifact. Confirmed against published9.7.0and source HEAD.Fix
parseFrontmatternow also readsorder:(parsed to a number; ignored when non-numeric) andgroup:(string), consistent with the existing single-linefrontmatterScalarhelper.collectDocsFromSrcthreadsorder/grouponto the collected doc item when present; absent leaves bothundefinedso schema/resolver defaults apply.DocIteminterface gainsorder?: number/group?: string.Secondary
Corrects the
orderJSDoc indoc.zod.ts: it claimed "Absent ⇒ sorts after ordered siblings", butresolveBookTreeuses(a.order ?? 0)— i.e. absent is treated as0(sorts among 0-keyed siblings), asbook.test.ts(z_doc // order 0 → first) confirms. Comment updated to match the implementation (zero behavior-change).Tests
New cases in
collect-docs.test.tscover:order:parsed as number, non-numericorder:ignored,order: 0retained,group:parsed as string, and absence leaving both undefined.doc.test.ts+book.test.ts): 26 passed