Repository navigation
docs(useOutlineFromMarkdown): add hook docs and a docs article example block - #9719
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Hi @hskl18! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
AI review status for this pull request.
|
…e block useOutlineFromMarkdown is public but had no hook doc and no example, so astryx hook denied it exists and it had no docsite page. The doc lists its params and return, and says where its ids can differ from Markdown's: with sources, and while content streams. The block builds an article and an Outline from one Markdown string through the hook. A button adds a section and its linked entry. Fixes meta#9572
22365e3 to
863cb52
Compare
There was a problem hiding this comment.
This looks ready to merge. The hook doc and the useOutlineFromMarkdown — Docs Article block close the hook's docs gap, and the block meets each criterion for a public hook's example.
astryx hook useOutlineFromMarkdownandastryx searchnow return the hook. The block's outline entries link to the rendered headings, and both new tests fail when the hook call is removed.- The doc's note that a heading citing a
sourcesentry gets a different id is accurate. Whether to track that gap in its own issue is a maintainer decision, and it does not block this pull request.
[Automated review]
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| Outline · Storybook | 24.2 kB (0) · 4.2 kB CSS (0) | 1,233 (0) | ✓ · ✓ · ✓ |
Package size: measured; main has no measurement of the merge base to compare yet.
Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
Reader impact
A builder cannot find
useOutlineFromMarkdown:astryx hook useOutlineFromMarkdownanswersNo hook named "useOutlineFromMarkdown", and the hook has no docsite page or runnable example. After this change the hook has a page at/components/useOutlineFromMarkdown,astryx hookandastryx searchreturn it, andastryx template useOutlineFromMarkdownHookUsage <path>copies the example.Source of truth
useOutlineFromMarkdown.ts,parseOutlineFromMarkdown.tsandmodule:Outline/parseOutlineFromMarkdown.component:OutlineFR4, for the block'soffset.architecture:knowledge-contractsINV28.Correction
Adds a HookDoc next to the source, and
blocks/components/Outline/useOutlineFromMarkdownHookUsage(exampleFor: 'useOutlineFromMarkdown'). OneuseStateholds a Markdown string.Markdownrenders it,useOutlineFromMarkdowngives theOutlineits items, and "Add section" appends a heading to the string. The hook's source file adds the doc to its SYNC list.Choices you may want to check:
markdown.id,labelandlevelare all on screen, through the links, the text and the indent.optionsis in the HookDoc. docs(useCollator): add a locale-aware name sort example block #9510 callsuseCollator()the same way, though docs(useListFocus): add a recent files example block #9577 passes its defaults.createMarkdownHeadingLinkswould showplugins, but it adds a copy control to every heading, against the issue's "no unrelated UI".Outlinegetsoffset={8}, although its prop doc says to leave it at 0 when nothing overlays the content. The docs page mounts the block inline, and FR4 scrolls every ancestor at 0. In Chromium at 0, a click moved the docs page from 1572 to 1882 and left the block's top under the site header. A comment in the block gives the reason.ScrollableAreaso a link has somewhere to scroll. Its ref goes toscrollContainerRef, so the highlight follows the article.new-section,new-section-1).Review of the doc turned up two cases where the hook's ids differ from Markdown's. A test run confirmed both. The doc states them, and this PR leaves the behavior as it is:
# Intro [ref]withsources={{ref: {...}}}: Markdown rendersid="intro", the hook returnsintro-ref. The hook has no way to receive sources. Without sources both giveintro-ref.# Intro [pendingwithisStreaming: Markdown ends onintro, the hook withisFinal: falsereturnsintro-pending.One question:
module:Outline/parseOutlineFromMarkdownFR1 says both utilities take the same parser options as Markdown, so is thesourcescase a gap you want tracked in its own issue?Evidence
Headless Chromium against the docsite dev server,
/components/useOutlineFromMarkdown, 1440 x 1000:###entries are indented. Each entry's id is held by one element on the page, inside the article.#new-section-1. The first run, on a cold dev server that was still compiling, showed the new entry not current and no second entry. Two warm reruns showed both. I did not isolate the difference.Encountered a script tagerror on this page and on/components/useClipboard.packages/cli/api/template/use-outline-from-markdown-hook-usage.test.tsxchecks that each entry links to a rendered heading and that the button adds a linked entry. With the hook call replaced by an empty array, both tests fail.The coverage report no longer lists this hook under either gap. On this head it counts 44 hooks without a doc and 67 without a block.
Scope
internal/shadcn-registry/routes.lock.json, fromUPDATE_SHADCN_ROUTE_LOCK=1 node apps/docsite/scripts/generate-data.mjs.apps/sandbox/scripts/next-export-routes.json, the checked list, gains the block's route.Testing
On this head, macOS, Node 24.22.2 (
.nvmrcpins 24.22.1):pnpm lint:strict: 0 errors, 166 warnings, none in these files.prettier --checkon the touched source files: clean.pnpm build,pnpm -F @astryxdesign/docsite build,pnpm -F @astryxdesign/cli typecheck,node apps/docsite/scripts/generate-data.mjs(no route lock difference): pass.pnpm check:changesets,changeset-coverage pr,check-knowledge,sync-exports --check,verify-exports,generate-cli-readme --check: pass. The changeset is@astryxdesign/coreand@astryxdesign/clipatch,[docs].vitest run --project nodeon the new test andapps/sandbox/src/route-manifest.test.ts: 8 passed. Onpackages/cli/foundation/discovery,packages/cli/api/template,packages/cli/assets/templatesandinternal/shadcn-registry: 1177 passed. On thetree.test.mjsfiles inpackages/cli/api/build,packages/cli/api/searchandpackages/cli/foundation/doc-compiler: 35 passed.vitest run --project ui packages/core/src/Outline: 64 passed.apps/docsitedata-extractionandexample-coverage: 135 passed.Before the rebases and the doc's final wording,
pnpm typecheckpassed andpnpm testgave 34856 passed and 49 failed in 14 files, none of which this PR touches. On a clean base, those files gave 48 of the 49 failures. The other is a 30 s timeout indoctor-integration.test.mjs, which passes alone on this branch. Sampled logs show errors such as bash 3.2'sOBS_ARGS[@]: unbound variableandcp --reflink, which point to macOS. No Linux run confirms that, and not all 48 were traced. The full suite was not rerun after the rebases. The last one resolved a conflict in the two route lists, and the rest of the diff did not change.Not run:
pnpm test:buildpast its packed-consumer test (2 passed), becausetheme-layer-cascade.jsneeds Chromium 1228, which is not installed here. Left to hosted CI, so unverified until it runs:test:ui:isolated,test:docsite-browser, registry verification, and the a11y, visual, RTL and interaction lanes. WebKit, Firefox, dark theme and touch were not checked. The browser checks above used Chromium 1248 from a local cache.Hosted CI has not run. A draft runs no CI, and once this is marked ready the required checks fail with "Waiting for a maintainer's ci:run label" until a maintainer adds it.
I used Claude Code to write the doc, the block, the test and this description, and to run the checks above. Separate Claude Code sessions checked the plan and this description, and Codex reviewed the plan and the change.
Reviewed with sol loop: 2 rounds with GPT-6.1 Sol (xhigh). Sol verdict: approved. It found the two id differences above, which the doc now states.
Fixes #9572