@astryxdesign/cli 0.6.4-canary.06c8fa3 → 0.6.4-canary.0e1fbdb

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.
Files changed (254) hide show
  1. package/README.md +49 -40
  2. package/api/build/build.doc.mjs +6 -1
  3. package/api/build/build.test.mjs +22 -0
  4. package/api/build/kit/kit.mjs +44 -5
  5. package/api/component/component.doc.mjs +14 -7
  6. package/api/docs/_adapter.d.mts +8 -3
  7. package/api/docs/_adapter.mjs +14 -6
  8. package/api/docs/docOverlays.test.mjs +27 -1
  9. package/api/docs/docs.doc.mjs +2 -2
  10. package/api/doctor/doctor.doc.mjs +17 -8
  11. package/api/doctor/doctor.type.d.mts +1 -1
  12. package/api/doctor/doctor.type.mjs +1 -1
  13. package/api/gap-report/gap-report.doc.mjs +19 -10
  14. package/api/hook/hook.doc.mjs +6 -3
  15. package/api/index.d.mts +2 -0
  16. package/api/index.mjs +3 -1
  17. package/api/init/init.doc.mjs +17 -12
  18. package/api/integration/add-theme.mjs +22 -1
  19. package/api/integration/add-theme.test.mjs +34 -0
  20. package/api/integration/authoring-checks.mjs +2 -2
  21. package/api/integration/integrationPackCheck.doc.mjs +3 -3
  22. package/api/integration/pack-check.lifecycle-output.test.mjs +2 -0
  23. package/api/integration/pack-check.mjs +54 -6
  24. package/api/integration/pack-check.test.mjs +90 -0
  25. package/api/integration/pack-check.type.mjs +1 -1
  26. package/api/json/assertResponse.doc.mjs +1 -1
  27. package/api/json/index.ts +1 -0
  28. package/api/json/isError.doc.mjs +1 -1
  29. package/api/layout/_adapter.d.mts +34 -0
  30. package/api/layout/_adapter.mjs +148 -0
  31. package/api/layout/check/check.d.mts +16 -0
  32. package/api/layout/check/check.mjs +40 -0
  33. package/api/layout/expand/expand.d.mts +22 -0
  34. package/api/layout/expand/expand.mjs +155 -0
  35. package/api/layout/expand/expand.path-safety.test.mjs +53 -0
  36. package/api/layout/grammar/grammar.d.mts +13 -0
  37. package/api/layout/grammar/grammar.mjs +87 -0
  38. package/api/layout/layout.d.mts +6 -0
  39. package/api/layout/layout.mjs +17 -0
  40. package/api/layout/layout.test.mjs +297 -0
  41. package/api/layout/layout.type.d.mts +89 -0
  42. package/api/layout/layout.type.mjs +103 -0
  43. package/api/layout/layoutCheck.doc.d.mts +11 -0
  44. package/api/layout/layoutCheck.doc.mjs +85 -0
  45. package/api/layout/layoutExpand.doc.d.mts +11 -0
  46. package/api/layout/layoutExpand.doc.mjs +107 -0
  47. package/api/layout/layoutGrammar.doc.d.mts +11 -0
  48. package/api/layout/layoutGrammar.doc.mjs +57 -0
  49. package/api/search/search.d.mts +27 -1
  50. package/api/search/search.doc.mjs +2 -2
  51. package/api/search/search.mjs +228 -16
  52. package/api/swizzle/swizzle.doc.mjs +7 -5
  53. package/api/template/copy/copy.mjs +1 -1
  54. package/api/template/copy/copy.test.mjs +9 -0
  55. package/api/template/template-integration.test.mjs +65 -1
  56. package/api/template/template.doc.mjs +2 -1
  57. package/api/template/template.mjs +1 -1
  58. package/api/theme/generateTonalPalette.doc.mjs +1 -2
  59. package/api/theme/listThemes.doc.mjs +1 -1
  60. package/api/theme/themeAdd.doc.mjs +9 -10
  61. package/api/theme/themeBuild.doc.mjs +13 -13
  62. package/api/theme/themeList.doc.mjs +1 -1
  63. package/api/theme/themeListAvailable.doc.mjs +2 -1
  64. package/api/theme/themePaletteGenerate.doc.mjs +15 -8
  65. package/api/theme/themeTargets.doc.mjs +3 -2
  66. package/api/theme/themeTemplate.doc.mjs +2 -1
  67. package/api/upgrade/run/run.mjs +1 -1
  68. package/api/upgrade/upgrade.doc.mjs +24 -22
  69. package/assets/docs/README.md +4 -2
  70. package/assets/docs/browser-support.doc.mjs +11 -11
  71. package/assets/docs/color.doc.mjs +8 -2
  72. package/assets/docs/elevation.doc.mjs +6 -4
  73. package/assets/docs/getting-started.doc.mjs +5 -16
  74. package/assets/docs/icons.doc.mjs +2 -21
  75. package/assets/docs/illustrations.doc.mjs +7 -15
  76. package/assets/docs/layout.doc.dense.mjs +130 -82
  77. package/assets/docs/layout.doc.mjs +133 -77
  78. package/assets/docs/migration.doc.mjs +19 -21
  79. package/assets/docs/motion.doc.mjs +16 -3
  80. package/assets/docs/principles.doc.dense.mjs +5 -5
  81. package/assets/docs/principles.doc.mjs +8 -0
  82. package/assets/docs/principles.doc.zh.mjs +6 -6
  83. package/assets/docs/shape.doc.mjs +8 -3
  84. package/assets/docs/spacing.doc.mjs +7 -2
  85. package/assets/docs/styling-libraries.doc.mjs +6 -2
  86. package/assets/docs/styling.doc.mjs +19 -23
  87. package/assets/docs/theme.doc.dense.mjs +58 -18
  88. package/assets/docs/theme.doc.mjs +56 -46
  89. package/assets/docs/theme.doc.zh.mjs +9 -8
  90. package/assets/docs/tokens.doc.dense.mjs +2 -2
  91. package/assets/docs/tokens.doc.mjs +389 -8
  92. package/assets/docs/tokens.doc.zh.mjs +2 -2
  93. package/assets/docs/tree/add-a-component.doc.mjs +75 -0
  94. package/assets/docs/tree/add-a-theme.doc.mjs +85 -0
  95. package/assets/docs/tree/add-a-topic.doc.mjs +144 -0
  96. package/assets/docs/tree/agent-guidance.doc.mjs +138 -0
  97. package/assets/docs/tree/block-template.doc.mjs +130 -0
  98. package/assets/docs/tree/build-the-template.doc.mjs +28 -0
  99. package/assets/docs/tree/building-blocks.doc.mjs +46 -0
  100. package/assets/docs/tree/check-your-docs.doc.mjs +137 -0
  101. package/assets/docs/tree/checks.doc.mjs +119 -0
  102. package/assets/docs/tree/codemods.doc.mjs +147 -0
  103. package/assets/docs/tree/component-family.doc.mjs +113 -0
  104. package/assets/docs/tree/component-imports.doc.mjs +69 -0
  105. package/assets/docs/tree/components.doc.mjs +23 -0
  106. package/assets/docs/tree/configuration.doc.mjs +23 -0
  107. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +182 -0
  108. package/assets/docs/tree/define-the-theme.doc.mjs +118 -0
  109. package/assets/docs/tree/describe-the-component.doc.mjs +57 -0
  110. package/assets/docs/tree/docs.doc.mjs +21 -0
  111. package/assets/docs/tree/document-the-template.doc.mjs +28 -0
  112. package/assets/docs/tree/document-the-theme.doc.mjs +68 -0
  113. package/assets/docs/tree/export-template-assets.doc.mjs +147 -0
  114. package/assets/docs/tree/extend-or-replace.doc.mjs +103 -0
  115. package/assets/docs/tree/fonts-and-assets.doc.mjs +106 -0
  116. package/assets/docs/tree/generate-a-palette.doc.mjs +66 -0
  117. package/assets/docs/tree/grade-template-with-agent.doc.mjs +105 -0
  118. package/assets/docs/tree/help.doc.mjs +16 -0
  119. package/assets/docs/tree/integrations.doc.mjs +25 -470
  120. package/assets/docs/tree/links.doc.mjs +98 -0
  121. package/assets/docs/tree/package-and-test.doc.mjs +32 -0
  122. package/assets/docs/tree/page-template.doc.mjs +71 -0
  123. package/assets/docs/tree/publishing.doc.mjs +111 -0
  124. package/assets/docs/tree/quick-start.doc.mjs +272 -0
  125. package/assets/docs/tree/replace-a-core-component.doc.mjs +104 -0
  126. package/assets/docs/tree/replace-a-core-template.doc.mjs +172 -0
  127. package/assets/docs/tree/sections-and-placement.doc.mjs +108 -0
  128. package/assets/docs/tree/see-it-in-an-app.doc.mjs +59 -0
  129. package/assets/docs/tree/ship.doc.mjs +16 -0
  130. package/assets/docs/tree/short-and-findable.doc.mjs +108 -0
  131. package/assets/docs/tree/single-component.doc.mjs +165 -0
  132. package/assets/docs/tree/start-a-template.doc.mjs +143 -0
  133. package/assets/docs/tree/subcomponent.doc.mjs +115 -0
  134. package/assets/docs/tree/template-assets.doc.mjs +64 -0
  135. package/assets/docs/tree/template-doc-overview.doc.mjs +109 -0
  136. package/assets/docs/tree/template-fonts.doc.mjs +102 -0
  137. package/assets/docs/tree/template-grading-rubric.doc.mjs +452 -0
  138. package/assets/docs/tree/template-icons.doc.mjs +97 -0
  139. package/assets/docs/tree/template-images-media.doc.mjs +127 -0
  140. package/assets/docs/tree/template-styles.doc.mjs +93 -0
  141. package/assets/docs/tree/templates.doc.mjs +34 -0
  142. package/assets/docs/tree/test-in-an-app.doc.mjs +115 -0
  143. package/assets/docs/tree/test-template-in-app.doc.mjs +128 -0
  144. package/assets/docs/tree/themes.doc.mjs +39 -0
  145. package/assets/docs/tree/troubleshooting.doc.mjs +149 -0
  146. package/assets/docs/tree/upgrading.doc.mjs +103 -0
  147. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +51 -0
  148. package/assets/docs/tree/verify-packed-template.doc.mjs +77 -0
  149. package/assets/docs/tree/versioning.doc.mjs +161 -0
  150. package/assets/docs/tree/write-good-templates.doc.mjs +64 -0
  151. package/assets/docs/tree/write-the-template-file.doc.mjs +154 -0
  152. package/assets/docs/typography.doc.mjs +24 -4
  153. package/assets/docs/working-with-ai.doc.mjs +30 -22
  154. package/authoring/config/config.doc.mjs +2 -2
  155. package/authoring/config/type.ts +2 -2
  156. package/authoring/doctypes/_schema.d.mts +3 -2
  157. package/authoring/doctypes/_schema.mjs +6 -0
  158. package/authoring/doctypes/base/graph-fields.doc.mjs +3 -3
  159. package/authoring/doctypes/base/type.ts +4 -2
  160. package/authoring/doctypes/command/command.doc.mjs +1 -1
  161. package/authoring/doctypes/command/type.ts +1 -1
  162. package/authoring/doctypes/component/component.doc.mjs +6 -0
  163. package/authoring/doctypes/component/type.ts +8 -0
  164. package/authoring/doctypes/reference/reference.doc.mjs +7 -0
  165. package/authoring/doctypes/reference/type.ts +5 -0
  166. package/authoring/doctypes/schema/schema.doc.mjs +2 -2
  167. package/authoring/doctypes/template/template.doc.mjs +1 -1
  168. package/authoring/doctypes/template/type.ts +2 -2
  169. package/authoring/integration/integration.doc.mjs +12 -10
  170. package/clients/cli/command-result-coverage.test.mjs +7 -7
  171. package/clients/cli/commands/component.doc.mjs +4 -3
  172. package/clients/cli/commands/debug-result-summary.test.mjs +2 -2
  173. package/clients/cli/commands/docs.doc.mjs +1 -1
  174. package/clients/cli/commands/docs.mjs +60 -17
  175. package/clients/cli/commands/doctor-integration-docs.doc.mjs +3 -2
  176. package/clients/cli/commands/doctor-integration.test.mjs +53 -0
  177. package/clients/cli/commands/doctor.doc.mjs +3 -1
  178. package/clients/cli/commands/doctor.mjs +49 -5
  179. package/clients/cli/commands/gap-report.doc.mjs +10 -9
  180. package/clients/cli/commands/init.doc.mjs +9 -6
  181. package/clients/cli/commands/integration-add.doc.mjs +9 -9
  182. package/clients/cli/commands/integration-authoring.test.mjs +61 -10
  183. package/clients/cli/commands/integration-pack.doc.mjs +5 -9
  184. package/clients/cli/commands/integration-real-world.test.mjs +1 -1
  185. package/clients/cli/commands/integration-verify.doc.mjs +22 -0
  186. package/clients/cli/commands/integration.doc.mjs +4 -4
  187. package/clients/cli/commands/integration.mjs +74 -43
  188. package/clients/cli/commands/layout-check.doc.mjs +65 -0
  189. package/clients/cli/commands/layout-expand.doc.mjs +83 -0
  190. package/clients/cli/commands/layout-grammar.doc.mjs +30 -0
  191. package/clients/cli/commands/layout.doc.mjs +34 -0
  192. package/clients/cli/commands/layout.error-codes.test.mjs +66 -0
  193. package/clients/cli/commands/layout.exit-parity.test.mjs +41 -0
  194. package/clients/cli/commands/layout.mjs +275 -0
  195. package/clients/cli/commands/layout.path-help.test.mjs +33 -0
  196. package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
  197. package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
  198. package/clients/cli/commands/manifest.doc.mjs +1 -1
  199. package/clients/cli/commands/search.doc.mjs +10 -3
  200. package/clients/cli/commands/search.mjs +21 -2
  201. package/clients/cli/commands/search.test.mjs +21 -4
  202. package/clients/cli/commands/swizzle.doc.mjs +1 -1
  203. package/clients/cli/commands/template.doc.mjs +1 -1
  204. package/clients/cli/commands/text-json-parity.test.mjs +24 -1
  205. package/clients/cli/commands/theme-add.doc.mjs +1 -1
  206. package/clients/cli/commands/theme-palette-generate.doc.mjs +3 -2
  207. package/clients/cli/commands/theme-palette.doc.mjs +1 -2
  208. package/clients/cli/commands/theme-targets.doc.mjs +2 -2
  209. package/clients/cli/commands/theme.doc.mjs +2 -1
  210. package/clients/cli/commands/upgrade.doc.mjs +62 -3
  211. package/clients/cli/index.mjs +32 -6
  212. package/clients/cli/lib/define-command.mjs +28 -4
  213. package/clients/cli/lib/define-command.test.mjs +54 -0
  214. package/clients/cli/lib/exit-codes.test.mjs +25 -2
  215. package/clients/cli/lib/json-shim.test.mjs +20 -6
  216. package/clients/cli/lib/manifest.mjs +23 -5
  217. package/foundation/agent-docs/agent-docs.mjs +1 -1
  218. package/foundation/discovery/authoring-self-docs.test.mjs +6 -2
  219. package/foundation/discovery/cli-self-docs.mjs +16 -2
  220. package/foundation/discovery/cli-self-docs.test.mjs +20 -0
  221. package/foundation/discovery/docs-discovery.mjs +5 -1
  222. package/foundation/discovery/docs-discovery.test.mjs +21 -0
  223. package/foundation/discovery/docs-section-key.d.mts +1 -1
  224. package/foundation/discovery/docs-section-key.mjs +1 -1
  225. package/foundation/discovery/template-adapter.mjs +1 -1
  226. package/foundation/doc-compiler/doc-loads.test.mjs +15 -2
  227. package/foundation/doc-compiler/inputs.test.mjs +0 -1
  228. package/foundation/doc-compiler/tree.d.mts +4 -0
  229. package/foundation/doc-compiler/tree.mjs +6 -1
  230. package/foundation/integrations/cli-requirement.d.mts +26 -6
  231. package/foundation/integrations/cli-requirement.mjs +46 -11
  232. package/foundation/integrations/cli-requirement.test.mjs +7 -2
  233. package/foundation/integrations/contribution-inventory.mjs +1 -1
  234. package/foundation/response/error-codes.doc.mjs +6 -8
  235. package/foundation/response/error-codes.test.mjs +30 -5
  236. package/foundation/response/response-types.doc.d.mts +4 -3
  237. package/foundation/response/response-types.doc.mjs +42 -6
  238. package/foundation/response/response.doc.mjs +11 -10
  239. package/foundation/xle/browser.d.mts +3 -3
  240. package/foundation/xle/browser.mjs +3 -3
  241. package/foundation/xle/expand.mjs +2 -2
  242. package/foundation/xle/parse.mjs +1 -1
  243. package/foundation/xle/print.mjs +2 -2
  244. package/foundation/xle/splice.mjs +1 -1
  245. package/package.json +9 -9
  246. package/api/docs/docs.test.mjs +0 -245
  247. package/api/docs/integration-tree.test.mjs +0 -555
  248. package/api/docs/integrationDocs.test.mjs +0 -314
  249. package/api/search/search.test.mjs +0 -530
  250. package/assets/docs/tree/integrations.test.mjs +0 -62
  251. package/assets/docs/tree/writing-docs.doc.mjs +0 -286
  252. package/clients/cli/commands/docs.test.mjs +0 -323
  253. package/foundation/agent-docs/agent-docs.test.mjs +0 -1159
  254. package/foundation/doc-compiler/tree.test.mjs +0 -606
@@ -1,286 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file `astryx docs cli/writing-docs`: the guide to writing docs that readers,
5
- * people and agents alike, find by search or by moving one level at a time.
6
- * It lives in the docs tree under the `cli` namespace, so its only route is
7
- * `cli/writing-docs`.
8
- */
9
-
10
- /** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
11
- export const docs = {
12
- type: 'generic',
13
- name: 'writing-docs',
14
- placement: {parent: 'namespace:cli', slot: 'guides', order: 20},
15
- title: 'Writing docs',
16
- category: 'guide',
17
- description:
18
- 'Write docs that people and agents find by search or by reading one level at a time.',
19
-
20
- sections: [
21
- {
22
- title: 'How the docs work',
23
- category: 'guide',
24
- content: [
25
- {
26
- type: 'prose',
27
- text: 'Every doc is one node in one docs graph, with a stable identity and one home in a tree.',
28
- },
29
- {
30
- type: 'list',
31
- style: 'unordered',
32
- items: [
33
- "Identity: the doc's provider, its kind, and its name. Moving a doc never changes it.",
34
- 'Route: the names of the doc and its parents, such as `cli/api/functions/search`; `astryx docs <route>` reads it.',
35
- 'Moves: every read ends with Up, Previous, Next, and Related, each as a command you can run.',
36
- 'Search: a hit is the smallest part that answers, one section or one tree page. It gives the command that reads it and the command that opens the level above.',
37
- ],
38
- },
39
- {
40
- type: 'prose',
41
- text: "You never write moves or lists of children. The CLI derives them from each doc's home and its typed links.",
42
- },
43
- ],
44
- },
45
- {
46
- title: 'Add a doc',
47
- category: 'guide',
48
- content: [
49
- {
50
- type: 'prose',
51
- text: 'To add a doc, write one `.doc.mjs` file named after the doc, and stamp the type that matches what it describes.',
52
- },
53
- {
54
- type: 'table',
55
- headers: ['You document', 'Doc type', '`type`'],
56
- rows: [
57
- ['A topic or a guide', 'ReferenceDoc', "'generic'"],
58
- ['A CLI command', 'CommandDoc', "'command'"],
59
- ['A CLI API function', 'FunctionDoc', "'function'"],
60
- ['An object shape', 'SchemaDoc', "'schema'"],
61
- ['A fixed list of values', 'EnumDoc', "'enum'"],
62
- ['A component', 'ComponentDoc', "'component'"],
63
- ['A level of the tree', 'NamespaceDoc', "'namespace'"],
64
- ],
65
- },
66
- {
67
- type: 'prose',
68
- text: 'A topic or guide holds `sections`. Each section has a `title` and `content` blocks, and covers one idea. The `description` is one sentence that says what the doc covers.',
69
- },
70
- {
71
- type: 'code',
72
- lang: 'javascript',
73
- label: 'docs/deploying.doc.mjs',
74
- code: "export default {\n type: 'generic',\n name: 'deploying',\n title: 'Deploying',\n description: 'Ship an app built with Acme widgets.',\n sections: [\n {\n title: 'Build before you ship',\n content: [\n {type: 'prose', text: 'Build the app, then check it with {@link @astryxdesign/cli:command:doctor}.'},\n {type: 'code', lang: 'bash', code: 'npm run build'},\n {type: 'list', style: 'unordered', items: ['Check the output folder.']},\n {type: 'table', headers: ['Env', 'Value'], rows: [['NODE_ENV', 'production']]},\n ],\n },\n ],\n};",
75
- },
76
- {
77
- type: 'list',
78
- style: 'unordered',
79
- items: [
80
- 'A name is a command argument, so use only letters, digits, `_`, and `-`. Use lowercase kebab-case, such as `writing-docs`, so the name and its route segment match.',
81
- 'Keep the name stable. Links name a doc by its identity, and the name is part of it.',
82
- 'A name that collides with an existing topic is an error unless the doc declares `replaces` or `extends`.',
83
- 'Name the cases a doc does not cover, and link to where they are covered. A reader cannot tell a case you left out from a case that does not exist.',
84
- ],
85
- },
86
- {
87
- type: 'prose',
88
- text: 'Every field of every doc type is in {@link generic:authoring}.',
89
- },
90
- ],
91
- },
92
- {
93
- title: 'Place a doc',
94
- category: 'guide',
95
- content: [
96
- {
97
- type: 'prose',
98
- text: 'Each doc gets one home in one of three ways: a namespace adopts it, it places itself, or it stays a flat topic. Folders never decide a home.',
99
- },
100
- {
101
- type: 'prose',
102
- text: "Adopted: a CLI typed doc declares `namespace`, either `'cli/commands'` or `'cli/api'`. That namespace adopts it by kind, so its route is `cli/commands/<name>` or `cli/api/functions/<name>`.",
103
- },
104
- {
105
- type: 'code',
106
- lang: 'javascript',
107
- code: "{type: 'function', name: 'search', namespace: 'cli/api' /* ... */} // cli/api/functions/search",
108
- },
109
- {
110
- type: 'prose',
111
- text: "Placed: a guide declares `placement`. The `parent` names a namespace of your own package, the `slot` is one that namespace declares for the doc's kind, and `order` sorts the siblings in the slot. A placement that fails withdraws the doc with an error.",
112
- },
113
- {
114
- type: 'code',
115
- lang: 'javascript',
116
- code: "placement: {parent: 'namespace:cli', slot: 'guides', order: 20}, // cli/writing-docs",
117
- },
118
- {
119
- type: 'prose',
120
- text: 'Flat: a doc with neither is a flat topic, read with `astryx docs <name>`.',
121
- },
122
- {
123
- type: 'code',
124
- lang: 'javascript',
125
- code: "{type: 'generic', name: 'tokens', title: 'All Tokens' /* ... */} // astryx docs tokens",
126
- },
127
- ],
128
- },
129
- {
130
- title: 'Link docs',
131
- category: 'guide',
132
- content: [
133
- {
134
- type: 'prose',
135
- text: 'Link a doc with `{@link <target>}` or a typed field, never by writing its `astryx docs` route in prose: a route you write goes stale when the doc moves. Other commands, such as `astryx doctor`, you write as they are.',
136
- },
137
- {
138
- type: 'prose',
139
- text: "Typed fields: a FunctionDoc's `command` names the CLI command that runs it, and its `related` names functions. A CommandDoc's `fn` names the function it runs, and its `related` names commands.",
140
- },
141
- {
142
- type: 'code',
143
- lang: 'javascript',
144
- code: "{type: 'function', name: 'search', command: 'search', related: ['docs']}\n{type: 'command', name: 'search', fn: 'search', related: ['docs']}",
145
- },
146
- {
147
- type: 'prose',
148
- text: "Inside a section's text, write `{@link <target>}`, where the target is `[<provider>:]<kind>:<name>`; leave out the provider for a doc of your own provider. The CLI prints the command that opens the doc. It works in prose, list items, and table cells; link syntax inside code ticks is shown as written, and an older CLI prints the link as plain text. A namespace doc can also carry `reference` and `workflow` blocks in its `blocks`, though the CLI does not print them yet; a topic's sections cannot hold them.",
149
- },
150
- {
151
- type: 'code',
152
- lang: 'javascript',
153
- code: "{type: 'prose', text: 'Check it with {@link command:doctor}.'}\n{type: 'list', style: 'unordered', items: ['Search with {@link @astryxdesign/cli:function:search}.']}\n\n// In a namespace doc's blocks only:\n{type: 'workflow', steps: [\n {title: 'Write the doc', references: ['generic:authoring']},\n {title: 'Check it', references: ['command:doctor']},\n]}",
154
- },
155
- {
156
- type: 'prose',
157
- text: "The route in the printed command is derived when the doc is read, so a link follows its doc when the doc moves. A target that names no doc prints as written, and so does a typed-field name that matches more than one doc; `astryx doctor` warns on both.",
158
- },
159
- ],
160
- },
161
- {
162
- title: 'Keep reads short',
163
- category: 'guide',
164
- content: [
165
- {
166
- type: 'prose',
167
- text: 'Keep every read short so a reader gets one answer per command: one idea per section, a summary first, and a hard size limit.',
168
- },
169
- {
170
- type: 'list',
171
- style: 'unordered',
172
- items: [
173
- 'Give each section one idea. If it needs a second topic, split it into two sections.',
174
- "A section's summary, shown in the section list and in search, is its first prose block or first list item, cut at 240 characters. Lead with what the section answers.",
175
- 'In text, a topic with more than one section reads as its section list. The reader opens one section, or prints everything with `--full`. With `--json`, a topic returns the whole doc and `--index` its section list.',
176
- 'Every read should fit in 32 KB; `astryx doctor` warns on one that does not. Aim for sections under about 30 lines.',
177
- ],
178
- },
179
- {
180
- type: 'code',
181
- lang: 'bash',
182
- code: 'astryx docs cli/writing-docs\nastryx docs cli/writing-docs keep-reads-short\nastryx docs cli/writing-docs --full',
183
- },
184
- ],
185
- },
186
- {
187
- title: 'Make docs findable',
188
- category: 'guide',
189
- content: [
190
- {
191
- type: 'prose',
192
- text: 'Search finds a doc only by the words it indexes, so put the words a reader types where search looks.',
193
- },
194
- {
195
- type: 'prose',
196
- text: "Search matches titles, section titles, headings, each section's summary, and identifiers written in code ticks, such as `ERR_UNKNOWN_SECTION` or `token-ref`. It also matches a doc's own name and the `keywords` of a namespace or typed doc.",
197
- },
198
- {
199
- type: 'list',
200
- style: 'do',
201
- items: [
202
- 'Title a section with the task or question, such as "Place a doc".',
203
- 'Start each section with a sentence that names its subject and answers it.',
204
- 'Write exact identifiers in code ticks: field names, block types, and error codes.',
205
- 'Add `keywords` only for words that are not already in the title or summary.',
206
- ],
207
- },
208
- {
209
- type: 'list',
210
- style: 'dont',
211
- items: [
212
- 'Open a section with background. Its first block is its summary.',
213
- 'Use vague titles such as "Overview" or "Details" when a specific one fits.',
214
- ],
215
- },
216
- {
217
- type: 'prose',
218
- text: 'Test it the way a new reader arrives: search for the question, not the title, and check that the first hit answers it.',
219
- },
220
- {
221
- type: 'code',
222
- lang: 'bash',
223
- code: 'astryx search placement --type doc',
224
- },
225
- ],
226
- },
227
- {
228
- title: 'Docs from an integration',
229
- category: 'guide',
230
- content: [
231
- {
232
- type: 'prose',
233
- text: 'An integration joins the same graph with a namespace doc in its docs directory and guides placed in it. The namespace shows in `astryx docs` beside `cli`, with the same moves, search, and links. You can place a doc only in a namespace of your own package.',
234
- },
235
- {
236
- type: 'prose',
237
- text: 'Let the CLI write the files: inside the package, `astryx integration add doc deploying --parent acme` writes the guide with its placement, declares the docs root, and writes the `acme` namespace doc the first time. Run `astryx docs` in the package to see it.',
238
- },
239
- {
240
- type: 'prose',
241
- text: "A CLI release that does not read the docs tree can hide every doc topic your package ships when the package contains a namespace doc or a placed guide: none appear in `astryx docs`, in text or JSON, and `astryx doctor` may not say why. So `--parent` also declares the CLI release your docs need as an optional `@astryxdesign/cli` peer in package.json, which makes npm warn when an older CLI is installed, and `astryx integration pack --check` fails a package that ships either one without it.",
242
- },
243
- {
244
- type: 'code',
245
- lang: 'javascript',
246
- code: "// docs/acme.doc.mjs\n/** @type {import('@astryxdesign/cli/authoring').NamespaceDoc} */\nexport default {\n type: 'namespace', name: 'acme', title: 'Acme widgets',\n summary: 'Guides for building apps with Acme widgets.',\n slots: {guides: {title: 'Guides', accepts: {kinds: ['generic']}}},\n};\n\n// docs/deploying.doc.mjs (route: acme/deploying)\n/** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */\nexport default {\n type: 'generic', name: 'deploying', title: 'Deploying',\n description: 'Ship an app built with Acme widgets.',\n placement: {parent: 'namespace:acme', slot: 'guides', order: 10},\n sections: [{title: 'Check before you ship', content: [\n {type: 'prose', text: 'Run {@link @astryxdesign/cli:command:doctor} before every deploy.'},\n ]}],\n};",
247
- },
248
- {
249
- type: 'prose',
250
- text: "The link names the `@astryxdesign/cli` provider because its target lives in another package. A link without a provider resolves against yours: your manifest's `providerId`, or else your package name. That holds in a topic that `extends` another package's topic too: your sections link your docs, and a link to the other package's docs names its provider.",
251
- },
252
- {
253
- type: 'prose',
254
- text: 'Everything else an integration ships is in {@link generic:integrations}.',
255
- },
256
- ],
257
- },
258
- {
259
- title: 'Check your docs',
260
- category: 'guide',
261
- content: [
262
- {
263
- type: 'prose',
264
- text: 'Run the doctor commands to check every home, link, and read in your docs.',
265
- },
266
- {
267
- type: 'list',
268
- style: 'unordered',
269
- items: [
270
- '`astryx doctor`, in a project, checks the whole graph: the tree, the links, and the size of each read.',
271
- '`astryx doctor integration docs`, inside an integration package, runs the same checks on that package\'s docs before it ships.',
272
- '`astryx integration pack --check` fails a package that ships a namespace doc or a placed guide without a CLI peer that reads them.',
273
- ],
274
- },
275
- {
276
- type: 'prose',
277
- text: 'No check can tell whether a doc is still true. Describe what the CLI does now, and change the doc in the same change that changes the behavior.',
278
- },
279
- {
280
- type: 'prose',
281
- text: 'A problem in the tree or a link is a warning: it names what to fix, but the exit code stays 0, so read the report (or its `--json`) before you ship.',
282
- },
283
- ],
284
- },
285
- ],
286
- };
@@ -1,323 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
4
- import * as fs from 'node:fs';
5
- import * as path from 'node:path';
6
- import * as os from 'node:os';
7
- import {Command} from 'commander';
8
- import {registerDocs} from './docs.mjs';
9
- import {runCli} from '../../../test-utils/run-cli.mjs';
10
- import {displayWidth} from '../formatters/index.mjs';
11
-
12
- let tmpDir;
13
-
14
- beforeEach(() => {
15
- tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-docs-test-'));
16
- vi.spyOn(console, 'log').mockImplementation(() => {});
17
- vi.spyOn(console, 'error').mockImplementation(() => {});
18
- });
19
-
20
- afterEach(() => {
21
- fs.rmSync(tmpDir, {recursive: true, force: true});
22
- vi.restoreAllMocks();
23
- });
24
-
25
- function createProgram() {
26
- const program = new Command();
27
- program.exitOverride(); // Throw instead of calling process.exit
28
- registerDocs(program);
29
- return program;
30
- }
31
-
32
- describe('registerDocs', () => {
33
- it('lists available topics when no topic given', async () => {
34
- const program = createProgram();
35
- await program.parseAsync(['node', 'astryx', 'docs']);
36
-
37
- const output = console.log.mock.calls.map(c => c[0]).join('\n');
38
- expect(output).toContain('principles');
39
- expect(output).toContain('tokens');
40
- expect(output).not.toContain('shadcn-compatibility');
41
- });
42
-
43
- it('errors for unknown topic', async () => {
44
- const program = createProgram();
45
- vi.spyOn(process, 'exit').mockImplementation(code => {
46
- throw new Error(`exit ${code}`);
47
- });
48
-
49
- await expect(
50
- program.parseAsync(['node', 'astryx', 'docs', 'nonexistent']),
51
- ).rejects.toThrow('exit 1');
52
-
53
- const errorOutput = console.error.mock.calls.map(c => c[0]).join('\n');
54
- expect(errorOutput).toContain('Unknown topic');
55
- });
56
- });
57
-
58
- describe('hyphenated doc filenames', () => {
59
- it('lists hyphenated topics like getting-started', async () => {
60
- const program = createProgram();
61
- await program.parseAsync(['node', 'astryx', 'docs']);
62
-
63
- const output = console.log.mock.calls.map(c => c[0]).join('\n');
64
- expect(output).toContain('getting-started');
65
- });
66
-
67
- it('loads a hyphenated topic by name', async () => {
68
- const program = createProgram();
69
- await program.parseAsync(['node', 'astryx', 'docs', 'getting-started']);
70
-
71
- const output = console.log.mock.calls.map(c => c[0]).join('\n');
72
- expect(output.length).toBeGreaterThan(0);
73
- expect(console.error).not.toHaveBeenCalled();
74
- });
75
-
76
- it('returns docs.detail via API for hyphenated topic', async () => {
77
- const {docs: docsApi} = await import('../../../api/docs/docs.mjs');
78
- const result = await docsApi('getting-started', undefined, {full: true});
79
- expect(result.type).toBe('docs.detail');
80
- expect(result.data).toBeDefined();
81
- expect(result.data.description).toBeDefined();
82
- });
83
- });
84
-
85
- describe('migration docs', () => {
86
- it('lists the migration topic', async () => {
87
- const program = createProgram();
88
- await program.parseAsync(['node', 'astryx', 'docs']);
89
-
90
- const output = console.log.mock.calls.map(c => c[0]).join('\n');
91
- expect(output).toContain('migration');
92
- expect(output).toContain('Tailwind');
93
- });
94
-
95
- it('loads migration docs by topic name', async () => {
96
- const program = createProgram();
97
- await program.parseAsync(['node', 'astryx', 'docs', 'migration']);
98
-
99
- const output = console.log.mock.calls.map(c => c[0]).join('\n');
100
- expect(output).toContain('Migration Guide');
101
- expect(output).toContain('Recommended Order');
102
- expect(output).toContain('Map shadcn and Radix Primitives');
103
- });
104
- });
105
-
106
- describe('progressive reads', () => {
107
- const SLOW = 60_000;
108
- /** @param {string} out */
109
- const widest = out => Math.max(...out.split('\n').map(line => line.length));
110
-
111
- it('lists every topic on one line each', async () => {
112
- const {status, stdout} = await runCli(['docs']);
113
- expect(status).toBe(0);
114
- expect(stdout).toMatch(/^principles +\S/m);
115
- expect(widest(stdout)).toBeLessThanOrEqual(120);
116
- expect(stdout).toContain('Usage: pnpm exec astryx docs <topic>');
117
- }, SLOW);
118
-
119
- it("prints a topic's section index with the keys to read by", async () => {
120
- const {status, stdout} = await runCli(['docs', 'theme', '--index']);
121
- expect(status).toBe(0);
122
- expect(stdout).toMatch(/^quick-start +Quick Start/m);
123
- expect(stdout).toContain('docs theme <section>');
124
- expect(stdout).toMatch(/Read everything: +\S.* docs theme --full$/m);
125
- expect(widest(stdout)).toBeLessThanOrEqual(120);
126
- }, SLOW);
127
-
128
- it('prints one section by its key', async () => {
129
- const {status, stdout} = await runCli(['docs', 'theme', 'quick-start']);
130
- expect(status).toBe(0);
131
- expect(stdout).toMatch(/^## Quick Start/m);
132
- }, SLOW);
133
-
134
- it("lists a topic's sections by default; --full prints the whole topic", async () => {
135
- const index = await runCli(['docs', 'theme', '--index']);
136
- expect((await runCli(['docs', 'theme'])).stdout).toBe(index.stdout);
137
- const full = await runCli(['docs', 'theme', '--full']);
138
- expect(full.status).toBe(0);
139
- expect(full.stdout).toMatch(/^## Quick Start/m);
140
- expect(full.stdout.length).toBeGreaterThan(index.stdout.length * 3);
141
- expect((await runCli(['--detail', 'full', 'docs', 'theme', '--full'])).stdout).toBe(
142
- full.stdout,
143
- );
144
- }, SLOW);
145
-
146
- it('returns the matching envelopes as JSON', async () => {
147
- const envelope = async args => JSON.parse((await runCli([...args, '--json'])).stdout);
148
- // JSON keeps docs(): a bare read is the whole topic.
149
- expect((await envelope(['docs', 'theme'])).type).toBe('docs.detail');
150
- expect((await envelope(['docs', 'theme', '--full'])).type).toBe('docs.detail');
151
- expect((await envelope(['docs', 'theme', '--index'])).type).toBe(
152
- 'docs.index',
153
- );
154
- expect((await envelope(['docs', 'theme', 'quick-start'])).type).toBe(
155
- 'docs.detail.section',
156
- );
157
- }, SLOW);
158
- });
159
-
160
- describe('the docs tree, one level at a time', () => {
161
- const SLOW = 60_000;
162
- /** @param {string} out */
163
- const widest = out => Math.max(...out.split('\n').map(line => line.length));
164
-
165
- it('lists the docs tree first, under its own heading, then the topics', async () => {
166
- const {status, stdout} = await runCli(['docs']);
167
- expect(status).toBe(0);
168
- expect(stdout).toMatch(/^Docs tree$/m);
169
- expect(stdout).toMatch(/^Topics$/m);
170
- expect(stdout).toMatch(/^cli +Commands, programmatic APIs/m);
171
- expect(stdout.indexOf('\ncli ')).toBeLessThan(stdout.indexOf('\nprinciples '));
172
- expect(stdout).not.toMatch(/^cli-integrations /m);
173
- }, SLOW);
174
-
175
- it("shows a child's own name when its route name does not spell it", async () => {
176
- const {status, stdout} = await runCli(['docs', 'cli/api/functions']);
177
- expect(status).toBe(0);
178
- expect(stdout).toMatch(/^assert-response +assertResponse\(\): \S/m);
179
- expect(stdout).toMatch(/^search +search\(\): Unified ranked search/m);
180
- }, SLOW);
181
-
182
- it('prints a namespace: each slot, its children, and how to go down and up', async () => {
183
- const {status, stdout} = await runCli(['docs', 'cli/api']);
184
- expect(status).toBe(0);
185
- expect(stdout).toMatch(/^API$/m);
186
- expect(stdout).toMatch(/^Reference$/m);
187
- expect(stdout).toMatch(/^functions +Functions: Every function/m);
188
- expect(stdout).toMatch(/^schemas +/m);
189
- expect(stdout).toMatch(/^enums +/m);
190
- // One level only: no function is listed on the api page.
191
- expect(stdout).not.toMatch(/^search +/m);
192
- expect(stdout).toMatch(/Open one: .*docs cli\/api\/<name>$/m);
193
- expect(stdout).toMatch(/Up: .*docs cli$/m);
194
- expect(widest(stdout)).toBeLessThanOrEqual(120);
195
- }, SLOW);
196
-
197
- it('prints a typed doc and the way back up', async () => {
198
- const {status, stdout} = await runCli(['docs', 'cli/api/functions/search']);
199
- expect(status).toBe(0);
200
- expect(stdout).toMatch(/^## search\(\)/m);
201
- expect(stdout).toContain('Read it with `astryx docs cli/commands/search`.');
202
- expect(stdout).toMatch(/Up: .*docs cli\/api\/functions$/m);
203
- }, SLOW);
204
-
205
- it('reads the dense variant whole, asked with --dense or with --lang dense', async () => {
206
- for (const args of [['--dense', 'docs', 'theme'], ['--lang', 'dense', 'docs', 'theme']]) {
207
- const {status, stdout} = await runCli(args);
208
- expect(status).toBe(0);
209
- expect(stdout).not.toContain('Read one section:');
210
- }
211
- }, SLOW);
212
-
213
- it('refuses --index with --full', async () => {
214
- const both = await runCli(['docs', 'theme', '--index', '--full', '--json']);
215
- expect(both.status).toBe(1);
216
- expect(JSON.parse(both.stdout).code).toBe('ERR_INVALID_ARGUMENT');
217
- }, SLOW);
218
-
219
- it('reads the component lookup guide and its output/API examples', async () => {
220
- const index = await runCli([
221
- 'docs',
222
- 'cli/component-lookups',
223
- '--index',
224
- ]);
225
- expect(index.status).toBe(0);
226
- expect(index.stdout).toContain('several');
227
- expect(index.stdout).toContain('selectors');
228
- expect(index.stdout).toContain('output');
229
- expect(index.stdout).toContain('api');
230
-
231
- const output = await runCli([
232
- 'docs',
233
- 'cli/component-lookups',
234
- 'output',
235
- ]);
236
- expect(output.status).toBe(0);
237
- expect(output.stdout).toContain('component.batch');
238
- expect(output.stdout).toContain('ERR_UNKNOWN_COMPONENT');
239
- expect(output.stdout).toContain('exits 1');
240
-
241
- const api = await runCli(['docs', 'cli/component-lookups', 'api']);
242
- expect(api.status).toBe(0);
243
- expect(api.stdout).toContain('component([])');
244
- expect(api.stdout).toContain("component(['Button'])");
245
- }, SLOW);
246
-
247
- it('reads the integration guide by its route, and not by its old name', async () => {
248
- const guide = await runCli(['docs', 'cli/integrations', '--index']);
249
- expect(guide.status).toBe(0);
250
- expect(guide.stdout).toMatch(/Read one section: .*docs cli\/integrations <section>/);
251
- // A bare read is one level too: the sections, and how to read it all.
252
- const bare = await runCli(['docs', 'cli/integrations']);
253
- expect(bare.status).toBe(0);
254
- expect(bare.stdout).toBe(guide.stdout);
255
- expect(bare.stdout).toMatch(/Read everything: +.*docs cli\/integrations --full$/m);
256
- const one = await runCli(['docs', 'cli/integrations', 'codemods']);
257
- expect(one.status).toBe(0);
258
- expect(one.stdout).toMatch(/^## Codemods$/m);
259
- expect(one.stdout).toMatch(/^Up: .*docs cli\/integrations --index$/m);
260
- expect(one.stdout).toMatch(/^Previous: .*docs cli\/integrations agent-docs$/m);
261
- expect(one.stdout).toMatch(/^Next: .*docs cli\/integrations recording-runs$/m);
262
- const full = await runCli(['docs', 'cli/integrations', '--full']);
263
- expect(full.status).toBe(0);
264
- expect(full.stdout).toMatch(/^## Overview$/m);
265
- expect(full.stdout.length).toBeGreaterThan(bare.stdout.length * 4);
266
- const old = await runCli(['docs', 'cli-integrations']);
267
- expect(old.status).toBe(1);
268
- expect(old.stderr).toContain('Unknown topic "cli-integrations"');
269
- }, SLOW);
270
-
271
- it('returns docs.node as JSON, and fails a section of a namespace', async () => {
272
- const node = JSON.parse((await runCli(['docs', 'cli', '--json'])).stdout);
273
- expect(node).toMatchObject({
274
- type: 'docs.node',
275
- data: {route: 'cli', kind: 'namespace', breadcrumb: []},
276
- });
277
- expect(node.data.slots.map(slot => slot.name)).toEqual(['guides', 'reference']);
278
- const section = await runCli(['docs', 'cli', 'commands', '--json']);
279
- expect(section.status).toBe(1);
280
- const error = JSON.parse(section.stdout);
281
- expect(error).toMatchObject({code: 'ERR_UNKNOWN_SECTION'});
282
- expect(error.suggestions.map(s => s.name)).toEqual([
283
- 'cli/component-lookups',
284
- 'cli/integrations',
285
- 'cli/writing-docs',
286
- 'cli/commands',
287
- 'cli/api',
288
- ]);
289
- }, SLOW);
290
- });
291
-
292
- describe('text width in every language', () => {
293
- const SLOW = 60_000;
294
- /** Widest line outside code blocks, in terminal columns. */
295
- const widest = out => {
296
- let inCode = false;
297
- let max = 0;
298
- for (const line of out.split('\n')) {
299
- if (/^\s*```/.test(line)) {
300
- inCode = !inCode;
301
- continue;
302
- }
303
- // A single unbreakable token (a long URL) cannot wrap without breaking it.
304
- const oneToken = !/\s/.test(line.trim());
305
- if (!inCode && !line.startsWith('#') && !oneToken) {
306
- max = Math.max(max, displayWidth(line));
307
- }
308
- }
309
- return max;
310
- };
311
-
312
- it('keeps the additive section index within 120 columns', async () => {
313
- const {status, stdout} = await runCli([
314
- 'docs',
315
- 'theme',
316
- '--index',
317
- '--lang',
318
- 'zh',
319
- ]);
320
- expect(status).toBe(0);
321
- expect(widest(stdout)).toBeLessThanOrEqual(120);
322
- }, SLOW);
323
- });