@astryxdesign/cli 0.6.6 → 0.6.7-canary.796bcc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +129 -0
- package/README.md +84 -82
- package/api/build/_adapter.d.mts +20 -0
- package/api/build/_adapter.mjs +24 -0
- package/api/build/build.doc.mjs +1 -1
- package/api/build/build.test.mjs +1 -1
- package/api/build/build.type.d.mts +12 -0
- package/api/build/build.type.mjs +3 -0
- package/api/build/help/help.mjs +1 -1
- package/api/build/kit/kit.mjs +13 -1
- package/api/component/_adapter.d.mts +19 -0
- package/api/component/_adapter.mjs +33 -0
- package/api/component/component-replacement.test.mjs +615 -0
- package/api/component/component.doc.mjs +5 -2
- package/api/component/component.mjs +49 -15
- package/api/component/component.test.mjs +32 -0
- package/api/component/component.type.d.mts +33 -3
- package/api/component/component.type.mjs +10 -3
- package/api/component/detail/blocks/blocks.d.mts +2 -1
- package/api/component/detail/blocks/blocks.mjs +5 -2
- package/api/component/detail/detail.mjs +5 -1
- package/api/component/detail/props/props.d.mts +2 -1
- package/api/component/detail/props/props.mjs +3 -2
- package/api/component/detail/showcase/showcase.d.mts +3 -1
- package/api/component/detail/showcase/showcase.mjs +3 -1
- package/api/component/detail/source/source.d.mts +3 -2
- package/api/component/detail/source/source.mjs +7 -3
- package/api/component/list/list.mjs +128 -10
- package/api/docs/_adapter.d.mts +11 -0
- package/api/docs/_adapter.mjs +73 -1
- package/api/docs/compiled-topics.test.mjs +1 -1
- package/api/docs/detail/detail.mjs +19 -3
- package/api/docs/detail/section/section.d.mts +44 -0
- package/api/docs/detail/section/section.mjs +171 -14
- package/api/docs/detail/section/section.test.mjs +4 -4
- package/api/docs/docOverlays.test.mjs +38 -23
- package/api/docs/docs.depth.test.mjs +2 -0
- package/api/docs/docs.doc.mjs +3 -3
- package/api/docs/docs.mjs +13 -16
- package/api/docs/docs.test.mjs +9 -10
- package/api/docs/docs.type.d.mts +43 -3
- package/api/docs/docs.type.mjs +23 -3
- package/api/docs/index/index.mjs +11 -2
- package/api/docs/index/index.test.mjs +7 -2
- package/api/docs/integration-tree.test.mjs +26 -26
- package/api/docs/integrationDocs.test.mjs +8 -7
- package/api/docs/namespace-section.test.mjs +260 -0
- package/api/docs/node/node.mjs +3 -0
- package/api/docs/token-tables.test.mjs +93 -0
- package/api/doctor/_adapter.d.mts +50 -0
- package/api/doctor/_adapter.mjs +190 -0
- package/api/doctor/doctor.d.mts +6 -10
- package/api/doctor/doctor.doc.mjs +1 -3
- package/api/doctor/doctor.mjs +144 -150
- package/api/doctor/doctor.test.mjs +104 -0
- package/api/doctor/theme-checks.d.mts +24 -0
- package/api/doctor/theme-checks.mjs +1231 -0
- package/api/doctor/theme-checks.test.mjs +667 -0
- package/api/gap-report/gap-report.doc.mjs +2 -1
- package/api/gap-report/gap-report.mjs +15 -1
- package/api/hook/_adapter.d.mts +1 -0
- package/api/hook/_adapter.mjs +3 -0
- package/api/hook/detail/detail.mjs +2 -2
- package/api/hook/detail/params/params.mjs +2 -2
- package/api/hook/hook.type.d.mts +12 -0
- package/api/hook/hook.type.mjs +3 -0
- package/api/hook/list/list.mjs +8 -8
- package/api/index.d.mts +1 -1
- package/api/index.mjs +4 -0
- package/api/init/run/run.d.mts +3 -5
- package/api/init/run/run.mjs +11 -11
- package/api/integration/__fixtures__/released-0.6.5-ocean.d.mts +14 -0
- package/api/integration/__fixtures__/released-0.6.5-ocean.mjs +15 -0
- package/api/integration/add-helpers.d.mts +26 -5
- package/api/integration/add-helpers.mjs +50 -5
- package/api/integration/add-theme.mjs +16 -2
- package/api/integration/add-theme.test.mjs +66 -15
- package/api/integration/authoring-checks.mjs +21 -1
- package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
- package/api/integration/pack-check.component-replaces.test.mjs +126 -0
- package/api/integration/pack-check.d.mts +10 -0
- package/api/integration/pack-check.lifecycle-output.test.mjs +21 -2
- package/api/integration/pack-check.mjs +485 -3
- package/api/integration/pack-check.test.mjs +578 -10
- package/api/integration/validate-integration.mjs +20 -4
- package/api/integration/validate-integration.test.mjs +73 -0
- package/api/layout/check/check.d.mts +1 -0
- package/api/layout/check/check.mjs +1 -0
- package/api/layout/expand/expand.d.mts +1 -0
- package/api/layout/expand/expand.mjs +1 -0
- package/api/layout/grammar/grammar.d.mts +1 -0
- package/api/layout/grammar/grammar.mjs +1 -0
- package/api/layout/layoutCheck.doc.mjs +1 -1
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/layout/layoutGrammar.doc.mjs +1 -1
- package/api/search/search.d.mts +47 -3
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.domain-priority.test.mjs +261 -0
- package/api/search/search.mjs +247 -43
- package/api/search/search.test.mjs +5 -1
- package/api/search/search.type.d.mts +3 -3
- package/api/search/search.type.mjs +2 -2
- package/api/swizzle/_adapter.d.mts +10 -0
- package/api/swizzle/_adapter.mjs +23 -0
- package/api/swizzle/copy/copy.d.mts +5 -6
- package/api/swizzle/copy/copy.mjs +29 -10
- package/api/swizzle/list/list.mjs +2 -2
- package/api/swizzle/swizzle.doc.mjs +5 -2
- package/api/swizzle/swizzle.test.mjs +55 -5
- package/api/swizzle/swizzle.type.d.mts +8 -0
- package/api/swizzle/swizzle.type.mjs +2 -0
- package/api/template/copy/copy.mjs +14 -1
- package/api/template/show/show.mjs +2 -0
- package/api/template/skeleton/skeleton.mjs +2 -1
- package/api/template/template.d.mts +1 -1
- package/api/template/template.doc.mjs +1 -1
- package/api/template/template.mjs +1 -0
- package/api/template/template.type.d.mts +15 -0
- package/api/template/template.type.mjs +6 -0
- package/api/theme/_adapter.d.mts +106 -6
- package/api/theme/_adapter.mjs +687 -18
- package/api/theme/add/add.binary.test.mjs +76 -3
- package/api/theme/add/add.d.mts +5 -9
- package/api/theme/add/add.mjs +87 -64
- package/api/theme/add/add.rollback.test.mjs +9 -9
- package/api/theme/add/add.staging.test.mjs +9 -9
- package/api/theme/add/add.test.mjs +461 -55
- package/api/theme/add/add.types.test.mjs +151 -0
- package/api/theme/build/build.d.mts +96 -2
- package/api/theme/build/build.family.test.mjs +13 -4
- package/api/theme/build/build.mjs +286 -118
- package/api/theme/build/build.test.mjs +30 -0
- package/api/theme/build/font-warning.d.mts +11 -0
- package/api/theme/build/font-warning.mjs +28 -3
- package/api/theme/eject/eject.binary.test.mjs +90 -0
- package/api/theme/eject/eject.d.mts +17 -0
- package/api/theme/eject/eject.mjs +65 -0
- package/api/theme/eject/eject.rollback.test.mjs +158 -0
- package/api/theme/eject/eject.staging.test.mjs +83 -0
- package/api/theme/eject/eject.test.mjs +160 -0
- package/api/theme/integration-themes.test.mjs +30 -6
- package/api/theme/list/list.d.mts +10 -0
- package/api/theme/list/list.mjs +75 -7
- package/api/theme/list/list.test.mjs +155 -4
- package/api/theme/remove/remove.d.mts +12 -0
- package/api/theme/remove/remove.mjs +15 -0
- package/api/theme/remove/remove.test.mjs +94 -0
- package/api/theme/template/template.mjs +3 -4
- package/api/theme/theme.d.mts +5 -2
- package/api/theme/theme.mjs +13 -8
- package/api/theme/theme.type.d.mts +106 -2
- package/api/theme/theme.type.mjs +54 -5
- package/api/theme/themeAdd.doc.d.mts +1 -3
- package/api/theme/themeAdd.doc.mjs +35 -22
- package/api/theme/themeBuild.doc.mjs +1 -1
- package/api/theme/themeEject.doc.d.mts +8 -0
- package/api/theme/themeEject.doc.mjs +89 -0
- package/api/theme/themeListAvailable.doc.mjs +4 -4
- package/api/theme/themeListCopySources.doc.d.mts +8 -0
- package/api/theme/themeListCopySources.doc.mjs +60 -0
- package/api/theme/themeRemove.doc.d.mts +6 -0
- package/api/theme/themeRemove.doc.mjs +50 -0
- package/api/theme/themeTemplate.doc.mjs +4 -3
- package/api/theme/themeUse.doc.d.mts +6 -0
- package/api/theme/themeUse.doc.mjs +47 -0
- package/api/theme/use/use.d.mts +12 -0
- package/api/theme/use/use.mjs +15 -0
- package/api/theme/use/use.test.mjs +98 -0
- package/api/upgrade/_adapter.d.mts +1 -0
- package/api/upgrade/_adapter.mjs +3 -0
- package/api/upgrade/list/list.mjs +9 -3
- package/api/upgrade/upgrade.type.d.mts +4 -0
- package/api/upgrade/upgrade.type.mjs +1 -0
- package/assets/codemods/__tests__/registry.test.mjs +1 -0
- package/assets/codemods/integration-discovery.mjs +1 -1
- package/assets/codemods/integration-discovery.test.mjs +64 -0
- package/assets/codemods/registry.mjs +1 -0
- package/assets/codemods/transforms/v0.6.7/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
- package/assets/codemods/transforms/v0.6.7/index.mjs +23 -0
- package/assets/codemods/transforms/v0.6.7/migrate-copied-themes-to-descriptors.mjs +54 -0
- package/assets/docs/author-a-theme.doc.mjs +166 -0
- package/assets/docs/getting-started.doc.mjs +61 -17
- package/assets/docs/principles.doc.dense.mjs +4 -4
- package/assets/docs/principles.doc.mjs +6 -6
- package/assets/docs/principles.doc.zh.mjs +4 -4
- package/assets/docs/styling-overview.doc.mjs +211 -0
- package/assets/docs/theme.doc.dense.mjs +10 -198
- package/assets/docs/theme.doc.mjs +13 -771
- package/assets/docs/theme.doc.zh.mjs +31 -12
- package/assets/docs/tree/add-a-theme.doc.mjs +2 -2
- package/assets/docs/tree/checks.doc.mjs +6 -5
- package/assets/docs/tree/component-migration.doc.mjs +107 -0
- package/assets/docs/tree/css-and-stylex.doc.mjs +150 -0
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
- package/assets/docs/tree/font-setup.doc.mjs +122 -0
- package/assets/docs/tree/fonts-and-assets.doc.mjs +25 -20
- package/assets/docs/tree/headers-and-footers.doc.mjs +67 -0
- package/assets/docs/tree/i18n-library-integration.doc.mjs +167 -0
- package/assets/docs/tree/i18n-quick-start.doc.mjs +101 -0
- package/assets/docs/{internationalization.doc.mjs → tree/i18n-rtl-and-testing.doc.mjs} +17 -223
- package/assets/docs/tree/internationalization.doc.mjs +29 -0
- package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
- package/assets/docs/tree/layout.doc.mjs +55 -0
- package/assets/docs/{migration.doc.mjs → tree/migration-setup.doc.mjs} +24 -129
- package/assets/docs/tree/migration-verification.doc.mjs +67 -0
- package/assets/docs/tree/migration.doc.mjs +28 -0
- package/assets/docs/tree/non-css-processing.doc.mjs +112 -0
- package/assets/docs/tree/other-libraries.doc.mjs +218 -0
- package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
- package/assets/docs/tree/replace-a-core-template.doc.mjs +1 -1
- package/assets/docs/tree/responsive.doc.mjs +98 -0
- package/assets/docs/tree/scaffold.doc.mjs +140 -0
- package/assets/docs/tree/side-panels.doc.mjs +81 -0
- package/assets/docs/tree/structure.doc.mjs +140 -0
- package/assets/docs/tree/styling-advanced.doc.mjs +159 -0
- package/assets/docs/tree/styling-basics.doc.mjs +181 -0
- package/assets/docs/tree/styling-libraries.doc.mjs +30 -0
- package/assets/docs/tree/styling.doc.mjs +29 -0
- package/assets/docs/tree/tailwind.doc.mjs +65 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/themes.doc.mjs +2 -2
- package/assets/docs/tree/tokens-and-setup.doc.mjs +128 -0
- package/assets/docs/tree/tokens-border.doc.mjs +46 -0
- package/assets/docs/tree/tokens-color.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-color.doc.mjs +438 -0
- package/assets/docs/tree/tokens-color.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-data.doc.mjs +323 -0
- package/assets/docs/tree/tokens-duration.doc.mjs +78 -0
- package/assets/docs/tree/tokens-ease.doc.mjs +46 -0
- package/assets/docs/tree/tokens-focus.doc.mjs +57 -0
- package/assets/docs/tree/tokens-font-weight.doc.mjs +58 -0
- package/assets/docs/tree/tokens-radius.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-radius.doc.mjs +70 -0
- package/assets/docs/tree/tokens-radius.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.mjs +74 -0
- package/assets/docs/tree/tokens-shadow.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.mjs +54 -0
- package/assets/docs/tree/tokens-size.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.mjs +102 -0
- package/assets/docs/tree/tokens-spacing.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-syntax.doc.mjs +98 -0
- package/assets/docs/tree/tokens-text-size.doc.mjs +90 -0
- package/assets/docs/tree/tokens-type-scale.doc.mjs +210 -0
- package/assets/docs/tree/tokens-typography.doc.mjs +54 -0
- package/assets/docs/tree/tokens-usage.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-usage.doc.mjs +36 -0
- package/assets/docs/tree/tokens-usage.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens.doc.mjs +28 -0
- package/assets/docs/tree/troubleshooting.doc.mjs +7 -3
- package/assets/docs/tree/type-scale.doc.mjs +147 -0
- package/assets/docs/tree/typography-best-practices.doc.mjs +55 -0
- package/assets/docs/tree/typography.doc.mjs +29 -0
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
- package/assets/docs/tree/versioning.doc.mjs +6 -3
- package/assets/docs/use-a-theme.doc.mjs +212 -0
- package/assets/templates/pages/incident-console/page.tsx +1 -1
- package/assets/templates/pages/table-collapsible/page.tsx +1474 -0
- package/assets/templates/pages/table-collapsible/template.doc.mjs +12 -0
- package/assets/templates/pages/table-comparison/page.tsx +1449 -0
- package/assets/templates/pages/table-comparison/template.doc.mjs +12 -0
- package/assets/theme.template.ts +4 -3
- package/authoring/doctypes/command/command.doc.mjs +5 -0
- package/authoring/doctypes/command/type.ts +2 -0
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/component/type.ts +8 -4
- package/authoring/doctypes/template/template.doc.mjs +2 -2
- package/authoring/doctypes/template/type.ts +5 -3
- package/authoring/integration/integration.doc.mjs +1 -1
- package/clients/cli/commands/blog.mjs +3 -3
- package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
- package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
- package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
- package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
- package/clients/cli/commands/build-theme.mjs +338 -45
- package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
- package/clients/cli/commands/build.mjs +8 -6
- package/clients/cli/commands/build.text-fields.test.mjs +1 -1
- package/clients/cli/commands/component/index.mjs +91 -12
- package/clients/cli/commands/component-replacement.text.test.mjs +316 -0
- package/clients/cli/commands/component.doc.mjs +9 -2
- package/clients/cli/commands/docs.doc.mjs +2 -1
- package/clients/cli/commands/docs.mjs +63 -23
- package/clients/cli/commands/docs.test.mjs +17 -15
- package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -4
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.test.mjs +59 -52
- package/clients/cli/commands/gap-report.doc.mjs +2 -2
- package/clients/cli/commands/hook/index.mjs +7 -2
- package/clients/cli/commands/import-hint-correctness.test.mjs +28 -5
- package/clients/cli/commands/init.next-steps.test.mjs +18 -23
- package/clients/cli/commands/integration-real-world.test.mjs +61 -12
- package/clients/cli/commands/layout-check.doc.mjs +2 -0
- package/clients/cli/commands/layout-expand.doc.mjs +2 -0
- package/clients/cli/commands/layout-grammar.doc.mjs +2 -0
- package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +140 -0
- package/clients/cli/commands/layout.doc.mjs +2 -0
- package/clients/cli/commands/layout.mjs +40 -4
- package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
- package/clients/cli/commands/search.test.mjs +10 -4
- package/clients/cli/commands/swizzle.doc.mjs +12 -3
- package/clients/cli/commands/swizzle.mjs +2 -1
- package/clients/cli/commands/swizzle.routing.test.mjs +2 -1
- package/clients/cli/commands/template.mjs +56 -5
- package/clients/cli/commands/text-json-parity.test.mjs +40 -0
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +135 -0
- package/clients/cli/commands/theme-add.doc.mjs +19 -19
- package/clients/cli/commands/theme-build.doc.mjs +3 -1
- package/clients/cli/commands/theme-eject.doc.mjs +47 -0
- package/clients/cli/commands/theme-list.behavior.test.mjs +5 -2
- package/clients/cli/commands/theme-list.doc.mjs +2 -2
- package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -2
- package/clients/cli/commands/theme-remove.doc.mjs +22 -0
- package/clients/cli/commands/theme-template.doc.mjs +4 -3
- package/clients/cli/commands/theme-use.doc.mjs +22 -0
- package/clients/cli/commands/theme.doc.mjs +21 -16
- package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
- package/clients/cli/commands/upgrade.mjs +1 -1
- package/clients/cli/index.mjs +5 -2
- package/clients/cli/lib/component-format.mjs +29 -2
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +4 -0
- package/clients/cli/lib/resolve-theme.mjs +80 -78
- package/clients/cli/lib/resolve-theme.test.mjs +523 -27
- package/foundation/agent-docs/agent-docs.mjs +48 -30
- package/foundation/agent-docs/agent-docs.test.mjs +47 -34
- package/foundation/agent-docs/app-theme-workflow.test.mjs +13 -0
- package/foundation/config/project.d.mts +20 -5
- package/foundation/config/project.mjs +43 -6
- package/foundation/config/project.test.mjs +1 -1
- package/foundation/config/theme-private-vars.d.mts +12 -0
- package/foundation/config/theme-private-vars.mjs +107 -0
- package/foundation/config/theme-private-vars.test.mjs +55 -0
- package/foundation/config/theme-state.d.mts +145 -0
- package/foundation/config/theme-state.mjs +417 -0
- package/foundation/config/theme-state.test.mjs +182 -0
- package/foundation/discovery/component-discovery.d.mts +5 -2
- package/foundation/discovery/component-discovery.mjs +12 -6
- package/foundation/discovery/component-replacement.d.mts +91 -0
- package/foundation/discovery/component-replacement.mjs +417 -0
- package/foundation/discovery/component-replacement.test.mjs +480 -0
- package/foundation/discovery/docs-discovery.test.mjs +1 -1
- package/foundation/discovery/docs-output-budget.d.mts +6 -2
- package/foundation/discovery/docs-output-budget.mjs +2 -1
- package/foundation/discovery/docs-section-key.d.mts +4 -2
- package/foundation/discovery/docs-section-key.mjs +1 -1
- package/foundation/discovery/module-exports.d.mts +10 -0
- package/foundation/discovery/module-exports.mjs +146 -0
- package/foundation/discovery/package-exports.d.mts +29 -0
- package/foundation/discovery/package-exports.mjs +200 -0
- package/foundation/discovery/template-needs.d.mts +31 -0
- package/foundation/discovery/template-needs.mjs +156 -0
- package/foundation/discovery/template-needs.test.mjs +203 -0
- package/foundation/discovery/theme-discovery.d.mts +72 -5
- package/foundation/discovery/theme-discovery.mjs +134 -18
- package/foundation/discovery/theme-discovery.test.mjs +9 -3
- package/foundation/discovery/theme-imports.d.mts +15 -0
- package/foundation/discovery/theme-imports.mjs +217 -0
- package/foundation/discovery/theme-imports.test.mjs +173 -0
- package/foundation/doc-compiler/bundle.mjs +52 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +15 -5
- package/foundation/doc-compiler/inputs.mjs +2 -1
- package/foundation/doc-compiler/lenses.d.mts +4 -2
- package/foundation/doc-compiler/lenses.mjs +1 -1
- package/foundation/doc-compiler/split-topic-keywords.test.mjs +73 -0
- package/foundation/doc-compiler/tree.d.mts +10 -0
- package/foundation/doc-compiler/tree.mjs +22 -0
- package/foundation/doc-compiler/tree.test.mjs +3 -2
- package/foundation/env/package-manager.d.mts +31 -8
- package/foundation/env/package-manager.mjs +120 -13
- package/foundation/env/package-manager.test.mjs +174 -1
- package/foundation/fs/module-loader.d.mts +9 -0
- package/foundation/fs/module-loader.mjs +71 -2
- package/foundation/integrations/cli-requirement.d.mts +43 -10
- package/foundation/integrations/cli-requirement.mjs +56 -13
- package/foundation/integrations/cli-requirement.test.mjs +160 -23
- package/foundation/integrations/contribution-inventory.mjs +3 -3
- package/foundation/integrations/validate-contributions.d.mts +16 -0
- package/foundation/integrations/validate-contributions.mjs +56 -8
- package/foundation/response/base.d.ts +9 -3
- package/foundation/response/json.d.mts +7 -4
- package/foundation/response/json.mjs +10 -6
- package/foundation/response/response-types.doc.mjs +41 -26
- package/foundation/response/response.doc.mjs +18 -4
- package/foundation/text/copyright-header.mjs +1 -1
- package/foundation/text/copyright-header.test.mjs +1 -1
- package/package.json +9 -9
- package/assets/docs/layout.doc.dense.mjs +0 -388
- package/assets/docs/layout.doc.mjs +0 -550
- package/assets/docs/styling-libraries.doc.mjs +0 -469
- package/assets/docs/styling.doc.mjs +0 -412
- package/assets/docs/tokens.doc.dense.mjs +0 -15
- package/assets/docs/tokens.doc.mjs +0 -1491
- package/assets/docs/tokens.doc.zh.mjs +0 -15
- package/assets/docs/typography.doc.mjs +0 -286
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
* token-ref blocks inlined — matching `astryx --json docs <topic> <section>`.
|
|
12
12
|
* Throws ERR_UNKNOWN_SECTION when nothing matches, or when the query matches
|
|
13
13
|
* more than one section (the candidates come back as suggestions).
|
|
14
|
+
* A namespace's section read (spec:AST-046 FR6) finds the one guide below the
|
|
15
|
+
* namespace that has the section and answers exactly as that guide's section
|
|
16
|
+
* read does.
|
|
14
17
|
* @position Leaf nested under api/docs/detail. Shares topic resolution with the
|
|
15
18
|
* detail leaf via _adapter.mjs and reads through the compiler's lenses.
|
|
16
19
|
*/
|
|
@@ -20,13 +23,19 @@ import {ERROR_CODES} from '../../../../foundation/response/error-codes.mjs';
|
|
|
20
23
|
import {
|
|
21
24
|
findDocSection,
|
|
22
25
|
sectionKey,
|
|
26
|
+
sectionTitleKey,
|
|
27
|
+
sourceTitle,
|
|
23
28
|
} from '../../../../foundation/discovery/docs-section-key.mjs';
|
|
24
29
|
import {linkReferenceSection} from '../../../../foundation/doc-compiler/compile.mjs';
|
|
25
30
|
import {
|
|
26
31
|
readerSections,
|
|
27
32
|
sectionView,
|
|
28
33
|
} from '../../../../foundation/doc-compiler/lenses.mjs';
|
|
29
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
referenceTargets,
|
|
36
|
+
resolveTopicDocs,
|
|
37
|
+
sectionPackageOf,
|
|
38
|
+
} from '../../_adapter.mjs';
|
|
30
39
|
|
|
31
40
|
/**
|
|
32
41
|
* @param {string} topic
|
|
@@ -39,19 +48,9 @@ import {referenceTargets, resolveTopicDocs} from '../../_adapter.mjs';
|
|
|
39
48
|
* @returns {Promise<import('../../docs.type.mjs').DocsDetailSectionResponse>}
|
|
40
49
|
*/
|
|
41
50
|
export async function section(topic, sectionName, options = {}) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (typeof sectionName !== 'string' || !sectionName.trim()) {
|
|
46
|
-
throw new AstryxError(
|
|
47
|
-
'A section name is required',
|
|
48
|
-
undefined,
|
|
49
|
-
ERROR_CODES.ERR_UNKNOWN_SECTION,
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const {catalog, node, lang, entry} = await resolveTopicDocs(topic, options);
|
|
54
|
-
const sections = readerSections(node);
|
|
51
|
+
requireSectionName(sectionName);
|
|
52
|
+
const resolved = await resolveTopicDocs(topic, options);
|
|
53
|
+
const sections = readerSections(resolved.node);
|
|
55
54
|
const {section: match} = findDocSection(sections, sectionName);
|
|
56
55
|
if (!match) {
|
|
57
56
|
throw new AstryxError(
|
|
@@ -64,6 +63,33 @@ export async function section(topic, sectionName, options = {}) {
|
|
|
64
63
|
);
|
|
65
64
|
}
|
|
66
65
|
|
|
66
|
+
return sectionResponse(resolved, sections, match);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* An empty section name must error, not resolve to the first section. The
|
|
71
|
+
* docs() dispatcher routes a falsy section to the topic, but a leaf must be
|
|
72
|
+
* safe on its own; a non-string would otherwise throw a raw TypeError.
|
|
73
|
+
* @param {unknown} sectionName
|
|
74
|
+
*/
|
|
75
|
+
function requireSectionName(sectionName) {
|
|
76
|
+
if (typeof sectionName !== 'string' || !sectionName.trim()) {
|
|
77
|
+
throw new AstryxError(
|
|
78
|
+
'A section name is required',
|
|
79
|
+
undefined,
|
|
80
|
+
ERROR_CODES.ERR_UNKNOWN_SECTION,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The docs.detail.section response for one section of a resolved topic.
|
|
87
|
+
* @param {Awaited<ReturnType<typeof resolveTopicDocs>>} resolved
|
|
88
|
+
* @param {any[]} sections the topic's reader sections
|
|
89
|
+
* @param {any} match one of them
|
|
90
|
+
* @returns {Promise<import('../../docs.type.mjs').DocsDetailSectionResponse>}
|
|
91
|
+
*/
|
|
92
|
+
async function sectionResponse({catalog, node, lang, entry}, sections, match) {
|
|
67
93
|
// A section read on its own inlines its token refs, as the whole topic does;
|
|
68
94
|
// otherwise a section that is only a token-ref prints blank. Only this
|
|
69
95
|
// section is linked, so a broken reference elsewhere cannot fail the read.
|
|
@@ -84,6 +110,137 @@ export async function section(topic, sectionName, options = {}) {
|
|
|
84
110
|
}
|
|
85
111
|
return {
|
|
86
112
|
type: 'docs.detail.section',
|
|
113
|
+
// The package that wrote this section: the topic's own, or an extension's.
|
|
114
|
+
package: sectionPackageOf(entry, node)(match.id),
|
|
87
115
|
data: {...sectionView(node, linked), links},
|
|
88
116
|
};
|
|
89
117
|
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @typedef {object} GuideMatch
|
|
121
|
+
* @property {import('../../../../foundation/doc-compiler/tree.mjs').TreeNode} guide
|
|
122
|
+
* @property {Awaited<ReturnType<typeof resolveTopicDocs>>} resolved
|
|
123
|
+
* @property {any[]} sections the guide's reader sections
|
|
124
|
+
* @property {any} match the section it has
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* One section of a namespace (spec:AST-046 FR6): the section read of the one
|
|
129
|
+
* guide below the namespace, at any depth, that has it. Each guide answers
|
|
130
|
+
* with the section its own section read returns for the query; when that
|
|
131
|
+
* section's key (its `id`, else the key its title derives) is the query in
|
|
132
|
+
* some guides, those guides answer first. No guide, or several, fail with ERR_UNKNOWN_SECTION, naming
|
|
133
|
+
* the guides to read instead.
|
|
134
|
+
* @param {import('../../../../foundation/doc-compiler/tree.mjs').DocsTree} tree
|
|
135
|
+
* @param {import('../../../../foundation/doc-compiler/tree.mjs').TreeNode} namespace
|
|
136
|
+
* @param {string} sectionName
|
|
137
|
+
* @param {object} [options] as {@link section}
|
|
138
|
+
* @returns {Promise<import('../../docs.type.mjs').DocsDetailSectionResponse>}
|
|
139
|
+
*/
|
|
140
|
+
export async function namespaceSection(
|
|
141
|
+
tree,
|
|
142
|
+
namespace,
|
|
143
|
+
sectionName,
|
|
144
|
+
options = {},
|
|
145
|
+
) {
|
|
146
|
+
requireSectionName(sectionName);
|
|
147
|
+
const guides = guidesBelow(tree, namespace);
|
|
148
|
+
/** @type {Omit<GuideMatch, 'match'>[]} */
|
|
149
|
+
const reads = [];
|
|
150
|
+
for (const guide of guides) {
|
|
151
|
+
const resolved = await resolveTopicDocs(guide.route, options);
|
|
152
|
+
reads.push({guide, resolved, sections: readerSections(resolved.node)});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const wanted = sectionName.trim();
|
|
156
|
+
const derived = sectionTitleKey(wanted);
|
|
157
|
+
/** @type {GuideMatch[]} */
|
|
158
|
+
const byKey = [];
|
|
159
|
+
/** @type {GuideMatch[]} */
|
|
160
|
+
const found = [];
|
|
161
|
+
for (const read of reads) {
|
|
162
|
+
// The section the guide's own section read returns for this query, so the
|
|
163
|
+
// namespace read answers exactly what `astryx docs <guide> <section>` does.
|
|
164
|
+
const {section: match} = findDocSection(read.sections, wanted);
|
|
165
|
+
if (!match) continue;
|
|
166
|
+
found.push({...read, match});
|
|
167
|
+
if (
|
|
168
|
+
sectionKey(match) === wanted ||
|
|
169
|
+
(derived !== '' && sectionTitleKey(sourceTitle(match)) === derived)
|
|
170
|
+
) {
|
|
171
|
+
byKey.push({...read, match});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const matches = byKey.length > 0 ? byKey : found;
|
|
175
|
+
const chosen = oneGuide(matches);
|
|
176
|
+
if (chosen)
|
|
177
|
+
return sectionResponse(chosen.resolved, chosen.sections, chosen.match);
|
|
178
|
+
|
|
179
|
+
if (guides.length === 0) {
|
|
180
|
+
// A namespace with no guide below it (a reference level such as cli/api)
|
|
181
|
+
// has no sections to read: name its children, as before.
|
|
182
|
+
throw new AstryxError(
|
|
183
|
+
`"${namespace.route}" has no sections. Open one of its children instead.`,
|
|
184
|
+
namespace.slots.flatMap(slot =>
|
|
185
|
+
slot.children.map(route => ({
|
|
186
|
+
name: route,
|
|
187
|
+
reason: tree.get(route)?.summary ?? '',
|
|
188
|
+
})),
|
|
189
|
+
),
|
|
190
|
+
ERROR_CODES.ERR_UNKNOWN_SECTION,
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
if (matches.length === 0) {
|
|
194
|
+
throw new AstryxError(
|
|
195
|
+
`Section "${sectionName}" is not in any guide under "${namespace.route}". Open one of its guides instead.`,
|
|
196
|
+
guides.map(guide => ({name: guide.route, reason: guide.summary})),
|
|
197
|
+
ERROR_CODES.ERR_UNKNOWN_SECTION,
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
throw new AstryxError(
|
|
201
|
+
`Section "${sectionName}" matches sections in more than one guide under "${namespace.route}". Read it from one of them.`,
|
|
202
|
+
matches.map(({guide, match}) => ({
|
|
203
|
+
name: guide.route,
|
|
204
|
+
reason: `has "${match.title}"`,
|
|
205
|
+
})),
|
|
206
|
+
ERROR_CODES.ERR_UNKNOWN_SECTION,
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* The guide a namespace section read answers from, or null to ask. When the
|
|
212
|
+
* query matches sections in several guides, the read asks the reader which
|
|
213
|
+
* guide they mean (spec:AST-046 FR6), where a flat topic's section read
|
|
214
|
+
* returned its first title match. To return the first match in tree order
|
|
215
|
+
* instead, return `matches[0]` here.
|
|
216
|
+
* @param {GuideMatch[]} matches in tree order
|
|
217
|
+
* @returns {GuideMatch | null}
|
|
218
|
+
*/
|
|
219
|
+
export function oneGuide(matches) {
|
|
220
|
+
return matches.length === 1 ? matches[0] : null;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Every guide below a namespace, at any depth, in tree order.
|
|
225
|
+
* @param {import('../../../../foundation/doc-compiler/tree.mjs').DocsTree} tree
|
|
226
|
+
* @param {import('../../../../foundation/doc-compiler/tree.mjs').TreeNode} namespace
|
|
227
|
+
* @returns {import('../../../../foundation/doc-compiler/tree.mjs').TreeNode[]}
|
|
228
|
+
*/
|
|
229
|
+
function guidesBelow(tree, namespace) {
|
|
230
|
+
/** @type {import('../../../../foundation/doc-compiler/tree.mjs').TreeNode[]} */
|
|
231
|
+
const guides = [];
|
|
232
|
+
/** @param {import('../../../../foundation/doc-compiler/tree.mjs').TreeNode} parent */
|
|
233
|
+
const walk = parent => {
|
|
234
|
+
for (const slot of parent.slots) {
|
|
235
|
+
for (const route of slot.children) {
|
|
236
|
+
const child = tree.get(route);
|
|
237
|
+
if (!child || child.parent !== parent.route) continue;
|
|
238
|
+
if (child.kind === 'namespace') walk(child);
|
|
239
|
+
else if (child.kind === 'generic' && child.ref?.topicFile)
|
|
240
|
+
guides.push(child);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
walk(namespace);
|
|
245
|
+
return guides;
|
|
246
|
+
}
|
|
@@ -16,7 +16,7 @@ const SLOW = 30_000;
|
|
|
16
16
|
|
|
17
17
|
describe('docs.detail.section leaf', () => {
|
|
18
18
|
it('resolves a named section (case-insensitive) into a docs.detail.section envelope', async () => {
|
|
19
|
-
const res = await section('tokens', 'spacing');
|
|
19
|
+
const res = await section('tokens/tokens-spacing', 'spacing');
|
|
20
20
|
expect(res.type).toBe('docs.detail.section');
|
|
21
21
|
expect(res.data.title.toLowerCase()).toContain('spacing');
|
|
22
22
|
}, SLOW);
|
|
@@ -24,7 +24,7 @@ describe('docs.detail.section leaf', () => {
|
|
|
24
24
|
it('throws ERR_UNKNOWN_SECTION for an unknown section', async () => {
|
|
25
25
|
let err;
|
|
26
26
|
try {
|
|
27
|
-
await section('tokens', 'zzzznope');
|
|
27
|
+
await section('tokens/tokens-spacing', 'zzzznope');
|
|
28
28
|
} catch (e) {
|
|
29
29
|
err = e;
|
|
30
30
|
}
|
|
@@ -44,10 +44,10 @@ describe('docs.detail.section leaf', () => {
|
|
|
44
44
|
}, SLOW);
|
|
45
45
|
|
|
46
46
|
it('does not return the first section for an empty section name', async () => {
|
|
47
|
-
await expect(section('tokens', '')).rejects.toMatchObject({
|
|
47
|
+
await expect(section('tokens/tokens-spacing', '')).rejects.toMatchObject({
|
|
48
48
|
code: 'ERR_UNKNOWN_SECTION',
|
|
49
49
|
});
|
|
50
|
-
await expect(section('tokens', ' ')).rejects.toMatchObject({
|
|
50
|
+
await expect(section('tokens/tokens-spacing', ' ')).rejects.toMatchObject({
|
|
51
51
|
code: 'ERR_UNKNOWN_SECTION',
|
|
52
52
|
});
|
|
53
53
|
}, SLOW);
|
|
@@ -114,39 +114,54 @@ describe('reference doc overlays (#2182)', () => {
|
|
|
114
114
|
|
|
115
115
|
describe('the reported defect: docs tokens --dense (#2182)', () => {
|
|
116
116
|
it('does not print the colour table under the Spacing heading', async () => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
117
|
+
// The spacing table lives in its own guide; the spacing topic shows it
|
|
118
|
+
// through a token reference to the tokens namespace. Both, read dense.
|
|
119
|
+
for (const topic of ['tokens/tokens-spacing', 'spacing']) {
|
|
120
|
+
const result = await docs(topic, null, {dense: true});
|
|
121
|
+
const spacing = result.data.sections.find(s =>
|
|
122
|
+
JSON.stringify(s).includes('--spacing-'),
|
|
123
|
+
);
|
|
124
|
+
expect(spacing, `${topic} --dense should show the spacing table`).toBeTruthy();
|
|
125
|
+
const text = JSON.stringify(spacing);
|
|
126
|
+
expect(
|
|
127
|
+
text.includes('--color-'),
|
|
128
|
+
`The "${spacing.title}" section of \`docs ${topic} --dense\` contains ` +
|
|
129
|
+
`colour tokens. An agent reading this learns that spacing tokens are ` +
|
|
130
|
+
`named --color-*.`,
|
|
131
|
+
).toBe(false);
|
|
132
|
+
}
|
|
129
133
|
});
|
|
130
134
|
|
|
131
135
|
it('keeps every base section reachable, even without an overlay entry', async () => {
|
|
132
|
-
// The tokens
|
|
133
|
-
// still render (in English), not vanish or
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
|
|
136
|
+
// The tokens overlays compress 5 of 15 category tables. Read through the
|
|
137
|
+
// namespace, the other 10 must still render (in English), not vanish or
|
|
138
|
+
// absorb a neighbour's title.
|
|
139
|
+
const full = await docs('tokens', null, {depth: 'all', detail: 'full'});
|
|
140
|
+
const dense = await docs('tokens', null, {depth: 'all', detail: 'full', dense: true});
|
|
141
|
+
const titles = read =>
|
|
142
|
+
read.data.slots.flatMap(slot =>
|
|
143
|
+
slot.children.flatMap(child => (child.sections ?? []).map(s => s.title)),
|
|
144
|
+
);
|
|
145
|
+
expect(titles(dense).length).toBe(titles(full).length);
|
|
146
|
+
expect(titles(dense)).toContain('Color');
|
|
147
|
+
expect(titles(dense)).toContain('Font Size Tokens');
|
|
137
148
|
});
|
|
138
149
|
|
|
139
|
-
it('does not lose
|
|
150
|
+
it('does not lose a section from docs theme --dense', async () => {
|
|
151
|
+
const full = await docs('theme');
|
|
140
152
|
const dense = await docs('theme', null, {dense: true});
|
|
141
153
|
const titles = dense.data.sections.map(s => s.title);
|
|
142
|
-
|
|
154
|
+
// The dense overlay keeps every base section.
|
|
155
|
+
expect(titles.length).toBe(full.data.sections.length);
|
|
143
156
|
});
|
|
144
157
|
|
|
145
|
-
it('does not emit a duplicate
|
|
158
|
+
it('does not emit a duplicate heading in docs theme --dense', async () => {
|
|
146
159
|
const dense = await docs('theme', null, {dense: true});
|
|
147
160
|
const titles = dense.data.sections.map(s => s.title.toLowerCase());
|
|
148
|
-
const
|
|
149
|
-
|
|
161
|
+
const counts = new Map();
|
|
162
|
+
for (const t of titles) counts.set(t, (counts.get(t) ?? 0) + 1);
|
|
163
|
+
const dupes = [...counts.entries()].filter(([, c]) => c > 1);
|
|
164
|
+
expect(dupes).toEqual([]);
|
|
150
165
|
});
|
|
151
166
|
|
|
152
167
|
it('does not leak English headings into docs theme --zh', async () => {
|
|
@@ -154,6 +169,6 @@ describe('the reported defect: docs tokens --dense (#2182)', () => {
|
|
|
154
169
|
const titles = zh.data.sections.map(s => s.title);
|
|
155
170
|
// Every section the overlay translates must appear once, in Chinese only.
|
|
156
171
|
expect(titles).not.toContain('Dark mode');
|
|
157
|
-
expect(titles).toContain('
|
|
172
|
+
expect(titles).toContain('深色模式');
|
|
158
173
|
});
|
|
159
174
|
});
|
|
@@ -41,6 +41,7 @@ describe('docs() depth', () => {
|
|
|
41
41
|
expect(Object.keys(child).sort()).toEqual([
|
|
42
42
|
'kind',
|
|
43
43
|
'name',
|
|
44
|
+
'package',
|
|
44
45
|
'route',
|
|
45
46
|
'summary',
|
|
46
47
|
'title',
|
|
@@ -60,6 +61,7 @@ describe('docs() depth', () => {
|
|
|
60
61
|
expect(findRoute(result.data, 'cli/api/functions/search')).toEqual({
|
|
61
62
|
route: 'cli/api/functions/search',
|
|
62
63
|
name: 'search',
|
|
64
|
+
package: '@astryxdesign/cli',
|
|
63
65
|
kind: 'function',
|
|
64
66
|
title: 'search()',
|
|
65
67
|
summary: expect.any(String),
|
package/api/docs/docs.doc.mjs
CHANGED
|
@@ -121,7 +121,7 @@ export const doc = {
|
|
|
121
121
|
{
|
|
122
122
|
type: 'docs.detail.section',
|
|
123
123
|
description:
|
|
124
|
-
'One ReferenceSection of the topic, found by key or title, with token-ref and reference blocks inlined.',
|
|
124
|
+
'One ReferenceSection of the topic, found by key or title, with token-ref and reference blocks inlined. Asked of a docs-tree namespace, it is the section read of the one guide below the namespace that has the section.',
|
|
125
125
|
},
|
|
126
126
|
{
|
|
127
127
|
type: 'docs.node',
|
|
@@ -144,7 +144,7 @@ export const doc = {
|
|
|
144
144
|
},
|
|
145
145
|
{
|
|
146
146
|
code: 'ERR_UNKNOWN_SECTION',
|
|
147
|
-
when: 'a section is requested but is empty, matches no section, matches more than one
|
|
147
|
+
when: 'a section is requested but is empty, matches no section, or matches more than one; asked of a docs-tree namespace, when no guide below it or more than one has the section (suggestions name those guides); or asked of a typed doc, which has no sections',
|
|
148
148
|
},
|
|
149
149
|
],
|
|
150
150
|
examples: [
|
|
@@ -168,7 +168,7 @@ export const doc = {
|
|
|
168
168
|
label: 'A whole guide from the docs tree',
|
|
169
169
|
code: "await docs('cli/integrations/quick-start');",
|
|
170
170
|
},
|
|
171
|
-
{label: 'One section by key', code: "await docs('
|
|
171
|
+
{label: 'One section by key', code: "await docs('spacing', 'scale');"},
|
|
172
172
|
],
|
|
173
173
|
command: 'docs',
|
|
174
174
|
related: ['search', 'component', 'hook', 'template'],
|
package/api/docs/docs.mjs
CHANGED
|
@@ -26,7 +26,10 @@
|
|
|
26
26
|
import {list} from './list/list.mjs';
|
|
27
27
|
import {index} from './index/index.mjs';
|
|
28
28
|
import {detail} from './detail/detail.mjs';
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
namespaceSection,
|
|
31
|
+
section as sectionLeaf,
|
|
32
|
+
} from './detail/section/section.mjs';
|
|
30
33
|
import {node as nodeLeaf, nodeView} from './node/node.mjs';
|
|
31
34
|
import {resolveDocsArgument} from './_adapter.mjs';
|
|
32
35
|
import {AstryxError} from '../error.mjs';
|
|
@@ -98,28 +101,22 @@ export async function docs(topic, section, options = {}) {
|
|
|
98
101
|
if (!topic) return list(options);
|
|
99
102
|
const found = await resolveDocsArgument(topic, options);
|
|
100
103
|
if (found.kind === 'node') {
|
|
101
|
-
// A namespace or a typed doc has no sections: it is one read. `--index`
|
|
102
|
-
// asks for what the node read already is.
|
|
103
104
|
if (section) {
|
|
105
|
+
// A namespace answers a section read from the one guide below it that
|
|
106
|
+
// has the section (spec:AST-046 FR6). A typed doc is one read.
|
|
107
|
+
if (found.node.kind === 'namespace') {
|
|
108
|
+
return namespaceSection(found.tree, found.node, section, options);
|
|
109
|
+
}
|
|
104
110
|
throw new AstryxError(
|
|
105
|
-
`"${found.node.route}" has no sections. ${
|
|
106
|
-
|
|
107
|
-
? 'Open one of its children instead.'
|
|
108
|
-
: `Read it whole: astryx docs ${found.node.route}.`
|
|
109
|
-
}`,
|
|
110
|
-
found.node.kind === 'namespace'
|
|
111
|
-
? found.node.slots.flatMap(slot =>
|
|
112
|
-
slot.children.map(route => ({
|
|
113
|
-
name: route,
|
|
114
|
-
reason: found.tree.get(route)?.summary ?? '',
|
|
115
|
-
})),
|
|
116
|
-
)
|
|
117
|
-
: [{name: found.node.route, reason: found.node.summary}],
|
|
111
|
+
`"${found.node.route}" has no sections. Read it whole: astryx docs ${found.node.route}.`,
|
|
112
|
+
[{name: found.node.route, reason: found.node.summary}],
|
|
118
113
|
ERROR_CODES.ERR_UNKNOWN_SECTION,
|
|
119
114
|
);
|
|
120
115
|
}
|
|
121
116
|
return {
|
|
122
117
|
type: 'docs.node',
|
|
118
|
+
// The docs tree names each node's npm package as its provider.
|
|
119
|
+
package: found.node.provider,
|
|
123
120
|
data: await nodeView(found.catalog, found.tree, found.node, read),
|
|
124
121
|
};
|
|
125
122
|
}
|
package/api/docs/docs.test.mjs
CHANGED
|
@@ -53,7 +53,7 @@ describe('docs() dispatcher routing', () => {
|
|
|
53
53
|
|
|
54
54
|
it('reads a shortened section by its old key, which its title still derives', async () => {
|
|
55
55
|
const r = await docs(
|
|
56
|
-
'styling',
|
|
56
|
+
'styling/tokens-and-setup',
|
|
57
57
|
'stylex-build-setup-required-for-swizzled-components',
|
|
58
58
|
);
|
|
59
59
|
expect(r.type).toBe('docs.detail.section');
|
|
@@ -92,7 +92,7 @@ describe('docs() dispatcher routing', () => {
|
|
|
92
92
|
|
|
93
93
|
it("lists the docs tree's namespaces in meta, so every data entry reads as a topic", async () => {
|
|
94
94
|
const res = await docs();
|
|
95
|
-
expect(res.meta.namespaces.map(entry => entry.topic)).toEqual(['cli', 'unorganized']);
|
|
95
|
+
expect(res.meta.namespaces.map(entry => entry.topic)).toEqual(['cli', 'internationalization', 'layout', 'migration', 'styling', 'styling-libraries', 'tokens', 'typography', 'unorganized']);
|
|
96
96
|
for (const entry of res.data) {
|
|
97
97
|
expect((await docs(entry.topic)).type).toBe('docs.detail');
|
|
98
98
|
}
|
|
@@ -240,16 +240,15 @@ describe('docs() dispatcher routing', () => {
|
|
|
240
240
|
);
|
|
241
241
|
}, SLOW);
|
|
242
242
|
|
|
243
|
-
it('a section of a namespace -> ERR_UNKNOWN_SECTION, naming its
|
|
244
|
-
const err = await docs('cli', '
|
|
243
|
+
it('a section no guide of a namespace has -> ERR_UNKNOWN_SECTION, naming its guides', async () => {
|
|
244
|
+
const err = await docs('cli', 'zzzz-nope').catch(e => e);
|
|
245
245
|
expect(err).toBeInstanceOf(AstryxError);
|
|
246
246
|
expect(err.code).toBe('ERR_UNKNOWN_SECTION');
|
|
247
|
-
// It names
|
|
248
|
-
const
|
|
249
|
-
expect(
|
|
250
|
-
|
|
251
|
-
);
|
|
252
|
-
expect(err.suggestions.map(s => s.name)).toContain('cli/commands');
|
|
247
|
+
// It names every guide below the namespace, at any depth.
|
|
248
|
+
const names = err.suggestions.map(s => s.name);
|
|
249
|
+
expect(names).toContain('cli/component-lookups');
|
|
250
|
+
expect(names).toContain('cli/integrations/quick-start');
|
|
251
|
+
expect(names.every(name => name.startsWith('cli/'))).toBe(true);
|
|
253
252
|
}, SLOW);
|
|
254
253
|
|
|
255
254
|
it('an unknown route suggests the children of the deepest namespace it reaches', async () => {
|
package/api/docs/docs.type.d.mts
CHANGED
|
@@ -57,6 +57,10 @@ export type DocsListNamespace = {
|
|
|
57
57
|
*/
|
|
58
58
|
export type DocsIndexResponse = {
|
|
59
59
|
type: "docs.index";
|
|
60
|
+
/**
|
|
61
|
+
* the npm package that owns the topic
|
|
62
|
+
*/
|
|
63
|
+
package: string;
|
|
60
64
|
data: DocsIndex;
|
|
61
65
|
};
|
|
62
66
|
/**
|
|
@@ -65,9 +69,15 @@ export type DocsIndexResponse = {
|
|
|
65
69
|
export type DocsDetailResponse = {
|
|
66
70
|
type: "docs.detail";
|
|
67
71
|
/**
|
|
68
|
-
*
|
|
72
|
+
* the npm package that owns the topic
|
|
69
73
|
*/
|
|
70
|
-
|
|
74
|
+
package: string;
|
|
75
|
+
/**
|
|
76
|
+
* the whole doc, each section naming the package that wrote it, and the
|
|
77
|
+
* moves from it
|
|
78
|
+
*/
|
|
79
|
+
data: Omit<DocsReadDoc, "sections"> & {
|
|
80
|
+
sections: DocsDetailSection[];
|
|
71
81
|
links: DocsLinks;
|
|
72
82
|
};
|
|
73
83
|
};
|
|
@@ -79,6 +89,13 @@ export type DocsDetailResponse = {
|
|
|
79
89
|
export type DocsReadSection = Omit<import("@astryxdesign/cli/authoring").ReferenceSection, "content"> & {
|
|
80
90
|
content: import("@astryxdesign/cli/authoring").ReferenceContentBlock[];
|
|
81
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* A section of a whole-topic read: the read section, naming the package that
|
|
94
|
+
* wrote it.
|
|
95
|
+
*/
|
|
96
|
+
export type DocsDetailSection = DocsReadSection & {
|
|
97
|
+
package: string;
|
|
98
|
+
};
|
|
82
99
|
/**
|
|
83
100
|
* A topic as a read returns it: every section a {@link DocsReadSection}.
|
|
84
101
|
*/
|
|
@@ -141,7 +158,10 @@ export type DocsIndex = {
|
|
|
141
158
|
*/
|
|
142
159
|
links: DocsLinks;
|
|
143
160
|
};
|
|
144
|
-
|
|
161
|
+
/**
|
|
162
|
+
* One section of a topic's index, before it names its package.
|
|
163
|
+
*/
|
|
164
|
+
export type DocsIndexEntry = {
|
|
145
165
|
/**
|
|
146
166
|
* stable key; pass it as the section argument
|
|
147
167
|
*/
|
|
@@ -153,11 +173,23 @@ export type DocsIndexSection = {
|
|
|
153
173
|
*/
|
|
154
174
|
summary: string;
|
|
155
175
|
};
|
|
176
|
+
/**
|
|
177
|
+
* One section of a topic's index, naming the package that wrote it: the
|
|
178
|
+
* topic's own, or the extension's that contributed it.
|
|
179
|
+
*/
|
|
180
|
+
export type DocsIndexSection = DocsIndexEntry & {
|
|
181
|
+
package: string;
|
|
182
|
+
};
|
|
156
183
|
/**
|
|
157
184
|
* astryx --json docs <topic> <section>
|
|
158
185
|
*/
|
|
159
186
|
export type DocsDetailSectionResponse = {
|
|
160
187
|
type: "docs.detail.section";
|
|
188
|
+
/**
|
|
189
|
+
* the npm package that wrote the section: the
|
|
190
|
+
* topic's own, or the extension's that contributed it
|
|
191
|
+
*/
|
|
192
|
+
package: string;
|
|
161
193
|
/**
|
|
162
194
|
* the section, and the moves from it: up to its topic's index, and across to
|
|
163
195
|
* the sections before and after it
|
|
@@ -171,6 +203,10 @@ export type DocsDetailSectionResponse = {
|
|
|
171
203
|
*/
|
|
172
204
|
export type DocsNodeResponse = {
|
|
173
205
|
type: "docs.node";
|
|
206
|
+
/**
|
|
207
|
+
* the package that owns the node
|
|
208
|
+
*/
|
|
209
|
+
package: string;
|
|
174
210
|
data: DocsNode;
|
|
175
211
|
};
|
|
176
212
|
/**
|
|
@@ -248,6 +284,10 @@ export type DocsNodeChild = {
|
|
|
248
284
|
* the last segment of its route
|
|
249
285
|
*/
|
|
250
286
|
name: string;
|
|
287
|
+
/**
|
|
288
|
+
* the package that owns the child
|
|
289
|
+
*/
|
|
290
|
+
package: string;
|
|
251
291
|
kind: string;
|
|
252
292
|
title: string;
|
|
253
293
|
summary: string;
|
package/api/docs/docs.type.mjs
CHANGED
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
* astryx --json docs <topic> --index
|
|
50
50
|
* @typedef {object} DocsIndexResponse
|
|
51
51
|
* @property {'docs.index'} type
|
|
52
|
+
* @property {string} package the npm package that owns the topic
|
|
52
53
|
* @property {DocsIndex} data
|
|
53
54
|
*/
|
|
54
55
|
|
|
@@ -56,8 +57,10 @@
|
|
|
56
57
|
* astryx --json docs <topic>
|
|
57
58
|
* @typedef {object} DocsDetailResponse
|
|
58
59
|
* @property {'docs.detail'} type
|
|
59
|
-
* @property {
|
|
60
|
-
*
|
|
60
|
+
* @property {string} package the npm package that owns the topic
|
|
61
|
+
* @property {Omit<DocsReadDoc, 'sections'> & {sections: DocsDetailSection[], links: DocsLinks}} data
|
|
62
|
+
* the whole doc, each section naming the package that wrote it, and the
|
|
63
|
+
* moves from it
|
|
61
64
|
*/
|
|
62
65
|
|
|
63
66
|
/**
|
|
@@ -68,6 +71,12 @@
|
|
|
68
71
|
* & {content: import('@astryxdesign/cli/authoring').ReferenceContentBlock[]}} DocsReadSection
|
|
69
72
|
*/
|
|
70
73
|
|
|
74
|
+
/**
|
|
75
|
+
* A section of a whole-topic read: the read section, naming the package that
|
|
76
|
+
* wrote it.
|
|
77
|
+
* @typedef {DocsReadSection & {package: string}} DocsDetailSection
|
|
78
|
+
*/
|
|
79
|
+
|
|
71
80
|
/**
|
|
72
81
|
* A topic as a read returns it: every section a {@link DocsReadSection}.
|
|
73
82
|
* @typedef {Omit<import('@astryxdesign/cli/authoring').ReferenceDoc, 'sections'>
|
|
@@ -115,17 +124,26 @@
|
|
|
115
124
|
*/
|
|
116
125
|
|
|
117
126
|
/**
|
|
118
|
-
*
|
|
127
|
+
* One section of a topic's index, before it names its package.
|
|
128
|
+
* @typedef {object} DocsIndexEntry
|
|
119
129
|
* @property {string} id stable key; pass it as the section argument
|
|
120
130
|
* @property {string} title
|
|
121
131
|
* @property {string} summary the section's first line of text, at most 240
|
|
122
132
|
* characters
|
|
123
133
|
*/
|
|
124
134
|
|
|
135
|
+
/**
|
|
136
|
+
* One section of a topic's index, naming the package that wrote it: the
|
|
137
|
+
* topic's own, or the extension's that contributed it.
|
|
138
|
+
* @typedef {DocsIndexEntry & {package: string}} DocsIndexSection
|
|
139
|
+
*/
|
|
140
|
+
|
|
125
141
|
/**
|
|
126
142
|
* astryx --json docs <topic> <section>
|
|
127
143
|
* @typedef {object} DocsDetailSectionResponse
|
|
128
144
|
* @property {'docs.detail.section'} type
|
|
145
|
+
* @property {string} package the npm package that wrote the section: the
|
|
146
|
+
* topic's own, or the extension's that contributed it
|
|
129
147
|
* @property {DocsReadSection & {links: DocsLinks}} data
|
|
130
148
|
* the section, and the moves from it: up to its topic's index, and across to
|
|
131
149
|
* the sections before and after it
|
|
@@ -135,6 +153,7 @@
|
|
|
135
153
|
* astryx --json docs <route>, for a namespace or a typed doc in the docs tree
|
|
136
154
|
* @typedef {object} DocsNodeResponse
|
|
137
155
|
* @property {'docs.node'} type
|
|
156
|
+
* @property {string} package the package that owns the node
|
|
138
157
|
* @property {DocsNode} data
|
|
139
158
|
*/
|
|
140
159
|
|
|
@@ -180,6 +199,7 @@
|
|
|
180
199
|
* @typedef {object} DocsNodeChild
|
|
181
200
|
* @property {string} route pass it to `astryx docs` to go one level down
|
|
182
201
|
* @property {string} name the last segment of its route
|
|
202
|
+
* @property {string} package the package that owns the child
|
|
183
203
|
* @property {string} kind
|
|
184
204
|
* @property {string} title
|
|
185
205
|
* @property {string} summary
|