Skip to content

docs(useOutlineFromDOM): add hook docs and an article example block - #11234

Merged
cixzhang merged 4 commits into
meta:mainfrom
popsiclelmlm:docs/use-outline-from-dom
Nov 13, 2026
Merged

cixzhang merged 4 commits into
meta:mainfrom
popsiclelmlm:docs/use-outline-from-dom

Conversation

@popsiclelmlm

Copy link
Copy Markdown
Contributor

Part of #11207

Reader impact

A builder cannot find useOutlineFromDOM: astryx hook does not return it, and the hook has no docsite page or runnable example. After this change the hook has a page, astryx hook and astryx search return it, and astryx template useOutlineFromDOMHookUsage copies the example.

Source of truth

packages/core/src/Outline/useOutlineFromDOM.ts reads h1–h6 that already have an id and text. architecture:knowledge-contracts INV28.

Correction

Adds a HookDoc next to the source, and blocks/components/Outline/useOutlineFromDOMHookUsage (exampleFor: 'useOutlineFromDOM'). The article's headings are Heading elements. The hook gives Outline its items. "Add section" appends a heading, and a new entry appears.

Evidence

use-outline-from-dom-hook-usage.test.tsx links each outline entry to a rendered heading, and adds one when the button adds a heading.

Scope

Components: Outline, useOutlineFromDOM

  • This PR changes documentation only, or names every necessary generated artifact.
  • Runtime, API, visual, and policy changes were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

vitest run packages/cli/api/template/use-outline-from-dom-hook-usage.test.tsx

Hook docs for `useOutlineFromDOM`, so `astryx hook useOutlineFromDOM` and `astryx search` return it, and a `useOutlineFromDOM — Article` example block: an article and an Outline built from its headings through the hook, with a button that adds a section and its linked entry.
@vercel

vercel Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 13, 2026 3:23am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 11, 2026
@astracat-bot

astracat-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 13, 2026, 3:39 AM UTC

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge needs:design-review Affects visuals — Design should review labels Nov 11, 2026
@popsiclelmlm
popsiclelmlm marked this pull request as ready for review November 11, 2026 13:51

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the useOutlineFromDOM hook doc and the article example. They describe the hook accurately and meet the hook-example requirements, but one test fixture needs updating before this can merge.

Required change

  • packages/cli/api/component/__fixtures__/resolutions/modules.txt line 280 still records Outline/Outline.doc.mjs for useOutlineFromDOM. Now that the name opens Outline/useOutlineFromDOM.doc.mjs, packages/cli/api/component/resolution-compat.test.mjs fails. Change the line to useOutlineFromDOM useOutlineFromDOM Outline/useOutlineFromDOM.doc.mjs Outline/useOutlineFromDOM.ts, as the useTruncation hook-doc change (#10555) did.

Optionally, the "adds a linked entry" test could also assert that the new entry links to #new-section-1. CI has not run on this commit yet: a maintainer needs to add the ci:run label so it runs.

Automated review (maintainer link)

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec d419b57

The hook name now opens its own doc, so the resolution fixture still named Outline.doc.mjs.
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 3425c36

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
Outline · Storybook 25.2 kB (0) · 4.1 kB CSS (0) 1,188 (0) ✓ · ✓ · ✓

Package size:

  • @astryxdesign/cli 4.17 MB packed (+449 B); no new dependencies
  • @astryxdesign/core 7.48 MB packed (+402 B); no new dependencies

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

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 2a78033

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this commit yet, so a maintainer needs to add the ci:run label for it to run.

The useOutlineFromDOM hook doc and the article example meet the hook-example requirements, and this commit fixes both earlier points: the resolution fixture now records the hook's own doc, and the block test checks that the added entry links to #new-section-1. No changes are needed.

Claims and files checked

Claims:

  • Changeset: patch releases for core and cli fit a docs-only change to both packages — verified (.changeset/hook-doc-use-outline-from-dom.md).
  • Changeset: astryx hook useOutlineFromDOM returns the hook — verified (the CLI's hook discovery reads Outline/useOutlineFromDOM.doc.mjs).
  • Changeset: astryx search returns the hook — verified (search lists the hook, the new block, then Outline).
  • Changeset: the "useOutlineFromDOM — Article" block shows an article, an Outline built from its headings through the hook, and a button that adds a section and its linked entry — verified (useOutlineFromDOMHookUsage.tsx:19-20, :41-48, :52-58).
  • Description: before this change astryx hook cannot find the hook, and it has no page or runnable example — verified (the base has no hook doc and no block that names it).
  • Description: after it the hook has a docs page — verified (routes.lock.json:4305-4306; the docs preview built for this commit).
  • Description: astryx hook and astryx search return it — verified (as above).
  • Description: astryx template useOutlineFromDOMHookUsage copies the example — verified (the block is a template with its own same-stem doc).
  • Description: the hook reads h1–h6 that already have an id and text — verified (useOutlineFromDOM.ts:25-35).
  • Description: the hook doc sits next to the source and the block names the hook in exampleFor — verified (useOutlineFromDOM.doc.mjs, useOutlineFromDOMHookUsage.doc.mjs:6).
  • Description: the article's headings are Heading elements, the hook gives Outline its items, and Add section appends a heading that gains an entry — verified (useOutlineFromDOMHookUsage.tsx:33, :43, :52).
  • Description: the test links each entry to a rendered heading and adds one when the button adds a heading — verified (use-outline-from-dom-hook-usage.test.tsx:54-66, :68-79).
  • Description: the scope is Outline and useOutlineFromDOM — verified (no other component changes).
  • Description: documentation only, with runtime, API, visual and policy changes left out — verified (the only source change is a header comment line, and no public API changes).
  • Description: no internal context in public text or artifacts — verified.
  • Description: the block test runs with vitest — verified as written; CI has not run it on this commit yet.

Files:

  • .changeset/hook-doc-use-outline-from-dom.md — clear
  • apps/sandbox/scripts/next-export-routes.json — clear
  • internal/shadcn-registry/routes.lock.json — clear
  • packages/cli/api/component/__fixtures__/resolutions/modules.txt — clear
  • packages/cli/api/template/use-outline-from-dom-hook-usage.test.tsx — clear
  • packages/cli/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.doc.mjs — clear
  • packages/cli/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.tsx — clear
  • packages/core/src/Outline/useOutlineFromDOM.doc.mjs — clear
  • packages/core/src/Outline/useOutlineFromDOM.ts — clear

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as draft November 12, 2026 11:51
@cixzhang
cixzhang marked this pull request as ready for review November 12, 2026 11:52
@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 12, 2026
@cixzhang
cixzhang marked this pull request as draft November 12, 2026 16:47
@cixzhang
cixzhang marked this pull request as ready for review November 12, 2026 16:47
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec d09ee76

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: the test-node (4/5) shard stopped at its 15-minute job limit with no failing test, so a maintainer needs to re-run it before this can merge.

The useOutlineFromDOM hook doc and the article example meet the hook-example requirements, and both earlier points stay fixed: the resolution fixture records the hook's own doc, and the block test checks that the added entry links to #new-section-1. No changes are needed.

Claims and files checked

Claims:

  • Changeset: patch releases for core and cli fit a docs-only change to both packages — verified (.changeset/hook-doc-use-outline-from-dom.md).
  • Changeset: astryx hook useOutlineFromDOM returns the hook — verified (the CLI's hook discovery finds Outline/useOutlineFromDOM.doc.mjs by its file name).
  • Changeset: astryx search returns the hook — verified (search gathers hooks through the same discovery).
  • Changeset: the "useOutlineFromDOM — Article" block shows an article, an Outline built from its headings through the hook, and a button that adds a section and its linked entry — verified (useOutlineFromDOMHookUsage.tsx:19-20, :41-48, :52-58).
  • Description: before this change astryx hook cannot find the hook, and it has no page or runnable example — verified (the base has no hook doc and no block that names it).
  • Description: after it the hook has a docs page — verified (routes.lock.json:4305-4306; the docs build passed for this commit).
  • Description: astryx hook and astryx search return it — verified (as above).
  • Description: astryx template useOutlineFromDOMHookUsage copies the example — verified (the block is a template with its own same-stem doc; with a target path the command writes it).
  • Description: the hook reads h1–h6 that already have an id and text — verified (useOutlineFromDOM.ts:25-35).
  • Description: the hook doc sits next to the source and the block names the hook in exampleFor — verified (useOutlineFromDOM.doc.mjs, useOutlineFromDOMHookUsage.doc.mjs:6).
  • Description: the article's headings are Heading elements, the hook gives Outline its items, and Add section appends a heading that gains an entry — verified (useOutlineFromDOMHookUsage.tsx:33, :43, :52).
  • Description: the test links each entry to a rendered heading and adds one when the button adds a heading — verified (use-outline-from-dom-hook-usage.test.tsx:55-67, :69-80; it passes in CI on this commit).
  • Description: the scope is Outline and useOutlineFromDOM — verified (no other component changes).
  • Description: documentation only, with runtime, API, visual and policy changes left out — verified (the only source change is a header comment line, and no public API changes).
  • Description: no internal context in public text or artifacts — verified.
  • Description: the block test runs with vitest — verified (it passes in CI on this commit).

Files:

  • .changeset/hook-doc-use-outline-from-dom.md — clear
  • apps/sandbox/scripts/next-export-routes.json — clear
  • internal/shadcn-registry/routes.lock.json — clear
  • packages/cli/api/component/__fixtures__/resolutions/modules.txt — clear
  • packages/cli/api/template/use-outline-from-dom-hook-usage.test.tsx — clear
  • packages/cli/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.doc.mjs — clear
  • packages/cli/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.tsx — clear
  • packages/core/src/Outline/useOutlineFromDOM.doc.mjs — clear
  • packages/core/src/Outline/useOutlineFromDOM.ts — clear

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as draft November 13, 2026 03:13
@cixzhang
cixzhang marked this pull request as ready for review November 13, 2026 03:14
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 3425c36

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not finished on this commit because its run stopped with "CI is full", so a maintainer needs to re-run the jobs before this can merge.

The useOutlineFromDOM hook doc and the article example meet the hook-example requirements. The docs build passes with the new hook page and its example. Both earlier points stay fixed: the resolution fixture records the hook's own doc, and the block test checks that the added entry links to #new-section-1. No changes are needed.

Claims and files checked

Claims:

  • Changeset: patch releases for core and cli fit a docs-only change to both packages. Verified (.changeset/hook-doc-use-outline-from-dom.md).
  • Changeset: astryx hook useOutlineFromDOM returns the hook. Verified: the command prints its parameter, return value and best practices.
  • Changeset: astryx search returns the hook. Verified: the results are the hook, then the new block, then Outline.
  • Changeset: the "useOutlineFromDOM — Article" block shows an article, an Outline built from its headings through the hook, and a button that adds a section and its linked entry. Verified (useOutlineFromDOMHookUsage.tsx:20, :41-48, :52-58).
  • Description: before this change, astryx hook cannot find the hook, and the hook has no docs page or runnable example. Verified: the base answers "No hook named", and no block names the hook.
  • Description: after the change, the hook has a docs page. Verified: the docs build renders the page with the example.
  • Description: astryx hook and astryx search return the hook. Verified, as above.
  • Description: astryx template useOutlineFromDOMHookUsage copies the example. Verified: the command emits the block's source.
  • Description: the hook reads h1–h6 that already have an id and text. Verified (useOutlineFromDOM.ts:25-35).
  • Description: the hook doc sits next to the source, and the block names the hook in exampleFor. Verified (useOutlineFromDOM.doc.mjs, useOutlineFromDOMHookUsage.doc.mjs:6).
  • Description: the article's headings are Heading elements, the hook gives Outline its items, and Add section appends a heading that gets an entry. Verified (useOutlineFromDOMHookUsage.tsx:33, :52, :43).
  • Description: the test links each entry to a rendered heading and adds an entry when the button adds a heading. Verified (use-outline-from-dom-hook-usage.test.tsx:55-80; it passes).
  • Description: the scope is Outline and useOutlineFromDOM. Verified: no other component changes.
  • Description: the change is documentation only and names every generated artifact. Verified: both route lists match their generators.
  • Description: runtime, API, visual and policy changes are left out. Verified: no public API changes, and the only source change is a header comment line.
  • Description: public text and artifacts contain no internal context. Verified.
  • Description: the block test runs with vitest. Verified: 2 of 2 pass.

Files:

  • .changeset/hook-doc-use-outline-from-dom.md: clear
  • apps/sandbox/scripts/next-export-routes.json: clear
  • internal/shadcn-registry/routes.lock.json: clear
  • packages/cli/api/component/__fixtures__/resolutions/modules.txt: clear
  • packages/cli/api/template/use-outline-from-dom-hook-usage.test.tsx: clear
  • packages/cli/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.doc.mjs: clear
  • packages/cli/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.tsx: clear
  • packages/core/src/Outline/useOutlineFromDOM.doc.mjs: clear
  • packages/core/src/Outline/useOutlineFromDOM.ts: clear

Automated review (maintainer link)

@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Nov 13, 2026
@cixzhang
cixzhang merged commit f5b5f96 into meta:main Nov 13, 2026
190 of 247 checks passed

This branch was successfully deployed

1 active deployment
Preview — 3425c368 Deployed Nov 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants