Repository navigation
docs: an API index of every export, and contributor docs that match the repository - #222
Merged
Merged
Conversation
…he repository - /docs/api lists every export of each entry point in package.json, with its declaration and doc comment, read from dist/*.d.ts when the site builds (lib/api.ts, getApiIndex). content/docs/api.md holds the prose and one `<!-- exports: <entry point> -->` line per entry point, which readGuide fills in, so the page, its .md, the docs search, Ask and llms-full.txt all have the exports. An export several entry points share is listed once, under signoff-ui/core when it is there. An export a component page documents links that page; the others link the pages that use them. In the sidebar under Resources. - CONTRIBUTING.md: a Where to start section. The checks list adds pnpm perf, test:site, registry:build, smoke:assistant-ui and the CopilotKit smoke, which CI runs, and says how to run the browser checks in WebKit and Firefox. The kit-scope path is packages/signoff-ui/scripts. The version step moves every example but the playground, not only examples/coding-agent. - RELEASING.md: the same for the version pull request. - ARCHITECTURE.md: the package's layers and entry points, the build, the registry, the site, the examples and the checks. - ROADMAP.md: #172 and #173 (0.10.1) and #174 (0.11.0) move to a Released section, with #171, #175 and #211, which merged with no release. In review is empty. - test/api-index.test.ts (site) reads each entry point's exports with TypeScript and checks the page lists each, with its declaration and doc comment, and that its links land. test/contributor-docs.test.ts (library) checks CONTRIBUTING's checks against ci.yml, the paths CONTRIBUTING and ARCHITECTURE name, what the version step moves, and the roadmap against the changelog.
… absolute links in the .md - The exports a component page documents (76 of 222) get no section of their own: each entry point has one line of links to them, "On the component pages". Their sections only repeated a first line, and took places in Ask's and the MCP server's results: for "What props does ApprovalCard take?" the ApprovalCard props table had dropped out of the top 6. custom-markdown's "It also exports" links go to the same component sections. - A one-line declaration is inline code; a longer one, or one with a backtick, stays a code block. - toMarkdown makes links to the page's own headings absolute, so /docs/api.md and llms-full.txt have no relative links (smoke:playground). - The regex that finds an export's mentions escapes every metacharacter. - readGuide fails the build for the API index even when it has no exports line at all, and getApiIndex throws on a default or renamed export, which the page would print under the wrong name. - ARCHITECTURE: a module needs 'use client' when it has hooks, state or event handlers; the icons have none. - ROADMAP: #191 and #193 leave Good first issues; 0.10.2 (#209) is under Released; #207, #219 and #223 merged without a release.
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.
Roadmap item SU2-54. Part of #186.
What was wrong
dist/*.d.tson main, againstcontent/docs,content/componentsandlib/components.ts). Some are API the changelog announced:evaluateRules,matchesGlob,ruleFromDecision,ruleMatches,toToolApprovalResponse,isSubagentPart,createAgUiRun,fromAgUiUsage. The site's API tables read onlyindex.d.tsandag-ui.d.ts.pnpm perf,pnpm test:site,pnpm registry:build,pnpm smoke:assistant-uiand the CopilotKit build and smoke, whichci.ymlruns on every pull request. It didn't say how to run the WebKit and Firefox checks either. It pointed atscripts/kit-scope.mjs, which is reallypackages/signoff-ui/scripts/kit-scope.mjs, and it didn't point newcomers to the good first issues or to Discussions.examples/coding-agent.scripts/example-versions.mjsmoves every example that asks for a published range: assistant-ui, coding-agent, copilotkit and nextjs-minimal.What changed
/docs/api. It lists every export of each entry point inpackage.json'sexports, read from the built.d.tsfiles when the site builds (lib/api.ts,getApiIndex). The page is an ordinary guide.content/docs/api.mdhas the prose for each entry point and one<!-- exports: <entry point> -->line under it.readGuidereplaces that line with the entry point's exports, so the page,/docs/api.md("Copy page"), the docs search, Ask, the MCP server andllms-full.txtall get the exports with no new route. If an entry point has no line, if the page has no line at all, or if a line names an entry point that doesn't exist, the site build fails. The page is in the sidebar under Resources, so it is linked from every docs page, the component pages included.ApprovalCard, …". A section of their own only repeated the declaration's first line, and it took places in Ask's and the MCP server's results that the component page's own sections should get (see "Ask and the MCP server" below)..d.tswithout its comments, and a destructured parameter readsprops, as an editor's hover shows it. Any declaration over 30 lines shows only its first line.signoff-ui/corewhen it is there, otherwise under the first entry point that has it. The other entry points link to it ("It also exports everything insignoff-ui/core", or a list of names forsignoff-ui/acpandsignoff-ui/custom-markdown). Those links go to the component page when one documents the export./docs/api.mdandllms-full.txtwrite the page's links to its own headings as absolute URLs, as they already did for links to other pages.getApiIndexthrows, saying what to do, on a default export or one renamed on the way out (export { a as b }), which the page would print under the wrong name. The package has neither today.lib/api.tsnow loads every entry point. The component pages still look an export up by name in the first entry point that has it, soAgentMessageis still the main entry's.pnpm exec playwright-core install webkit firefox, thenBROWSER=webkitorBROWSER=firefox). The kit-scope path. Step 2 of "Adding a component" now asks for a doc comment on each export, since the component page or the index shows it. The version step: "every example but the playground". The Checks list and the audit paragraph from ci: run pnpm audit on every pull request and daily #211 are unchanged apart from the added lines.'use client'; the icons (src/lib/icons.tsx) only render markup and have none.No changeset: this changes docs, the site and tests only.
Page weight
The built page is 761,986 bytes of HTML (71,710 gzipped), down from 1,400,548 (97,482) before this round. The next largest are
labels.htmlat 712,782 (41,546 gzipped) andgetting-started.htmlat 613,089 (64,120)./docs/api.mdis 59,280 bytes and/llms-full.txt424,939.In Chrome through Playwright, at 1280 by 800 with the GPU off and the CPU slowed down by CDP (
Emulation.setCPUThrottlingRate), the median of 3 loads each. Total blocking time is the long tasks after first contentful paint, until 5 seconds pass without one. The theme tap is the Event Timing duration of a click on Dark in the header. The machine was shared, so I ran it twice; both runs are below (load average 6 to 16, then 8 to 22)./docs/api/docs/labelsLoading the page now blocks no longer than the labels page. A theme tap still takes about twice as long. A trace of the tap at 4x shows why: the style recalculation after it covers 6,758 nodes on
/docs/api(49 ms) and 682 on/docs/labels(15 ms), where 3,879 of the page's 4,035 code tokens sit in a folded block. Then 643 links on the API page restyle on each frame of their colour transition, against 107. Laying the page out in fewer nodes would take a change to the site's CSS (content-visibility: autoon each entry point's section) or one page per entry point, so I left it out of this PR (see the follow-ups).Ask and the MCP server
The site's Ask index is 24 pages and 627 sections (main: 23 pages, 468; this branch before this round: 697). The API index is 159 of them, 51,628 characters (before: 229, 60,733).
With ondocs' own retrieval (
retrieve, keyword-only, the top 6, as/api/askand/api/mcpsearch), over an index built asscripts/ask-index.tsbuilds it:ApprovalRuleLimits, 728 charactersevaluateRules,ruleMatchesand that section, 2,433 charactersUseApprovalPolicyOptionsanduseApprovalPolicyfirst, 3,453 characterstoToolApprovalanddecisionsFromAcpOptionsfrom the index among its own sections, 4,126 charactersHow it was tested
New tests, each written to fail first:
packages/signoff-ui/test/contributor-docs.test.ts(9 tests; all 9 failed against main's docs):ci.yml's pull-request jobs is in CONTRIBUTING's Checks section;BROWSERvalues CI uses (webkit, firefox) and the install command are there;examples/playground/test/api-index.test.ts(11 tests; 4 of them new in this round, which fail against the branch's previous site code):ApprovalCard,ApprovalCardProps,useApprovalPolicy) links to its section there and has no heading here, andsignoff-ui/custom-markdown's links go to the component page too;evaluateRules), a longer one a code block (computeReviewResult), and no code block holds one line without a backtick;function|const|interface|type <name>) and the first line of its doc comment;evaluateRules,memoryRuleStorage,formatCost,createAgUiRun) have headings and declarations;/docs/api.mdhas the exports, no<!-- exports:line left, and no relative link (assert.doesNotMatch(served, /\]\((?!https?:)/));api.mdhas no line for an entry point, no exports line at all, or a line for an entry point that doesn't exist.Gate, after merging main (#219, #223) into the branch:
pnpm install --frozen-lockfile --prefer-offline,pnpm format:check,pnpm lint,pnpm lint:registry,pnpm build:lib,pnpm size,pnpm typecheck,pnpm test(96 files, 1,584 tests),pnpm test:site(95 tests),pnpm registry:buildandpnpm build:playground(Ask's index: 24 pages, 627 sections) all pass. With the built site onnext start,pnpm smoke:playgroundpasses in Chrome (75 checks), WebKit (74) and Firefox (75),/llms-full.txt: plain markdown with absolute linksincluded.I also loaded
/docs/apiin Chrome:evaluateRulesgoes to/docs/api#evaluaterules);/llms-full.txthas the exports and no](#link.Follow-ups (outside this PR's files)
components/docs/component-page.tsx. For now, every page reaches the index through the sidebar.@internaland stop exporting before 1.0, with a changeset. Candidates the finding names:cn,useHydrated,usePrefersReducedMotion,AgentStatusDot,ToolCallDetails,inferLanguage.ActivityWindow,LineRange,DiffSegment,DiffLineTypeandDeepPartial;useAgUiAgent's second parameter isUseAgUiAgentOptions, which isn't exported either./docs/apito the list of docs pages inscripts/a11y-audit.mjs./docs/api. If it should cost what it does on other pages, trycontent-visibility: autoon each entry point's section inapp/globals.css, or one page per entry point..github/ISSUE_TEMPLATE/bug_report.yml, add an integration field for ACP and the other adapters, addstyles.layered.cssto the install options, and make theaiversion optional. Point the roadmap link infeature_request.ymlto Roadmap #49. Add a "docs page updated" box topull_request_template.md.labels.md(SU2-43 edits that file);theme.auto.cssline in the Tailwind snippet;labels-pt.tscode block title;examples/playground, and thepnpm-workspace.yamlcomment about examples running when copied out;styles.cssfigure on the limits page.