@textmode/docs 0.4.3 → 0.5.0

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 (210) hide show
  1. package/LICENSE +21 -121
  2. package/README.md +24 -33
  3. package/dist/cli/textmode-docs.d.ts +3 -0
  4. package/dist/cli/textmode-docs.d.ts.map +1 -0
  5. package/dist/cli/textmode-docs.js +227 -0
  6. package/dist/cli/textmode-docs.js.map +1 -0
  7. package/dist/example-quality.d.ts +59 -0
  8. package/dist/example-quality.d.ts.map +1 -0
  9. package/dist/example-quality.js +256 -0
  10. package/dist/example-quality.js.map +1 -0
  11. package/dist/index.d.ts +33 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +43 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/internal/check-api-documentation.d.ts +5 -0
  16. package/dist/internal/check-api-documentation.d.ts.map +1 -0
  17. package/dist/internal/check-api-documentation.js +74 -0
  18. package/dist/internal/check-api-documentation.js.map +1 -0
  19. package/dist/internal/check-example-sketches.d.ts +3 -0
  20. package/dist/internal/check-example-sketches.d.ts.map +1 -0
  21. package/dist/internal/check-example-sketches.js +76 -0
  22. package/dist/internal/check-example-sketches.js.map +1 -0
  23. package/dist/internal/config.d.ts +104 -0
  24. package/dist/internal/config.d.ts.map +1 -0
  25. package/dist/internal/config.js +324 -0
  26. package/dist/internal/config.js.map +1 -0
  27. package/dist/internal/documentation-commands.d.ts +24 -0
  28. package/dist/internal/documentation-commands.d.ts.map +1 -0
  29. package/dist/internal/documentation-commands.js +43 -0
  30. package/dist/internal/documentation-commands.js.map +1 -0
  31. package/dist/internal/lib/api-doc-checks.d.ts +46 -0
  32. package/dist/internal/lib/api-doc-checks.d.ts.map +1 -0
  33. package/dist/internal/lib/api-doc-checks.js +111 -0
  34. package/dist/internal/lib/api-doc-checks.js.map +1 -0
  35. package/dist/internal/lib/api-doc-routes.d.ts +7 -0
  36. package/dist/internal/lib/api-doc-routes.d.ts.map +1 -0
  37. package/dist/internal/lib/api-doc-routes.js +74 -0
  38. package/dist/internal/lib/api-doc-routes.js.map +1 -0
  39. package/dist/internal/lib/example-checks.d.ts +58 -0
  40. package/dist/internal/lib/example-checks.d.ts.map +1 -0
  41. package/dist/internal/lib/example-checks.js +230 -0
  42. package/dist/internal/lib/example-checks.js.map +1 -0
  43. package/dist/internal/lib/jsdoc-comments.d.ts +8 -0
  44. package/dist/internal/lib/jsdoc-comments.d.ts.map +1 -0
  45. package/dist/internal/lib/jsdoc-comments.js +67 -0
  46. package/dist/internal/lib/jsdoc-comments.js.map +1 -0
  47. package/dist/internal/lib/label-schema.d.ts +18 -0
  48. package/dist/internal/lib/label-schema.d.ts.map +1 -0
  49. package/dist/internal/lib/label-schema.js +17 -0
  50. package/dist/internal/lib/label-schema.js.map +1 -0
  51. package/dist/internal/lib/reflection-policy.d.ts +21 -0
  52. package/dist/internal/lib/reflection-policy.d.ts.map +1 -0
  53. package/dist/internal/lib/reflection-policy.js +96 -0
  54. package/dist/internal/lib/reflection-policy.js.map +1 -0
  55. package/dist/internal/lib/reporting.d.ts +8 -0
  56. package/dist/internal/lib/reporting.d.ts.map +1 -0
  57. package/dist/internal/lib/reporting.js +21 -0
  58. package/dist/internal/lib/reporting.js.map +1 -0
  59. package/dist/internal/lib/sketch-title.d.ts +14 -0
  60. package/dist/internal/lib/sketch-title.d.ts.map +1 -0
  61. package/dist/internal/lib/sketch-title.js +13 -0
  62. package/dist/internal/lib/sketch-title.js.map +1 -0
  63. package/dist/internal/reconcile-dates.d.ts +19 -0
  64. package/dist/internal/reconcile-dates.d.ts.map +1 -0
  65. package/dist/internal/reconcile-dates.js +77 -0
  66. package/dist/internal/reconcile-dates.js.map +1 -0
  67. package/dist/internal/reflection-kinds.d.ts +12 -0
  68. package/dist/internal/reflection-kinds.d.ts.map +1 -0
  69. package/dist/internal/reflection-kinds.js +19 -0
  70. package/dist/internal/reflection-kinds.js.map +1 -0
  71. package/dist/internal/typedoc-plugins/accessor-docs-normalizer/accessor-comments.d.ts +10 -0
  72. package/dist/internal/typedoc-plugins/accessor-docs-normalizer/accessor-comments.d.ts.map +1 -0
  73. package/dist/internal/typedoc-plugins/accessor-docs-normalizer/accessor-comments.js +31 -0
  74. package/dist/internal/typedoc-plugins/accessor-docs-normalizer/accessor-comments.js.map +1 -0
  75. package/dist/internal/typedoc-plugins/accessor-docs-normalizer/index.d.ts +3 -0
  76. package/dist/internal/typedoc-plugins/accessor-docs-normalizer/index.d.ts.map +1 -0
  77. package/dist/internal/typedoc-plugins/accessor-docs-normalizer/index.js +16 -0
  78. package/dist/internal/typedoc-plugins/accessor-docs-normalizer/index.js.map +1 -0
  79. package/dist/internal/typedoc-plugins/accessor-docs-normalizer/render-accessor.d.ts +9 -0
  80. package/dist/internal/typedoc-plugins/accessor-docs-normalizer/render-accessor.d.ts.map +1 -0
  81. package/dist/internal/typedoc-plugins/accessor-docs-normalizer/render-accessor.js +85 -0
  82. package/dist/internal/typedoc-plugins/accessor-docs-normalizer/render-accessor.js.map +1 -0
  83. package/dist/internal/typedoc-plugins/accessor-docs-normalizer/theme-patch.d.ts +7 -0
  84. package/dist/internal/typedoc-plugins/accessor-docs-normalizer/theme-patch.d.ts.map +1 -0
  85. package/dist/internal/typedoc-plugins/accessor-docs-normalizer/theme-patch.js +16 -0
  86. package/dist/internal/typedoc-plugins/accessor-docs-normalizer/theme-patch.js.map +1 -0
  87. package/dist/internal/typedoc-plugins/all-member-pages-router/child-pages.d.ts +16 -0
  88. package/dist/internal/typedoc-plugins/all-member-pages-router/child-pages.d.ts.map +1 -0
  89. package/dist/internal/typedoc-plugins/all-member-pages-router/child-pages.js +33 -0
  90. package/dist/internal/typedoc-plugins/all-member-pages-router/child-pages.js.map +1 -0
  91. package/dist/internal/typedoc-plugins/all-member-pages-router/constants.d.ts +9 -0
  92. package/dist/internal/typedoc-plugins/all-member-pages-router/constants.d.ts.map +1 -0
  93. package/dist/internal/typedoc-plugins/all-member-pages-router/constants.js +44 -0
  94. package/dist/internal/typedoc-plugins/all-member-pages-router/constants.js.map +1 -0
  95. package/dist/internal/typedoc-plugins/all-member-pages-router/index.d.ts +2 -0
  96. package/dist/internal/typedoc-plugins/all-member-pages-router/index.d.ts.map +1 -0
  97. package/dist/internal/typedoc-plugins/all-member-pages-router/index.js +2 -0
  98. package/dist/internal/typedoc-plugins/all-member-pages-router/index.js.map +1 -0
  99. package/dist/internal/typedoc-plugins/all-member-pages-router/member-paths.d.ts +11 -0
  100. package/dist/internal/typedoc-plugins/all-member-pages-router/member-paths.d.ts.map +1 -0
  101. package/dist/internal/typedoc-plugins/all-member-pages-router/member-paths.js +12 -0
  102. package/dist/internal/typedoc-plugins/all-member-pages-router/member-paths.js.map +1 -0
  103. package/dist/internal/typedoc-plugins/all-member-pages-router/member-reflections.d.ts +8 -0
  104. package/dist/internal/typedoc-plugins/all-member-pages-router/member-reflections.d.ts.map +1 -0
  105. package/dist/internal/typedoc-plugins/all-member-pages-router/member-reflections.js +78 -0
  106. package/dist/internal/typedoc-plugins/all-member-pages-router/member-reflections.js.map +1 -0
  107. package/dist/internal/typedoc-plugins/all-member-pages-router/namespace-paths.d.ts +8 -0
  108. package/dist/internal/typedoc-plugins/all-member-pages-router/namespace-paths.d.ts.map +1 -0
  109. package/dist/internal/typedoc-plugins/all-member-pages-router/namespace-paths.js +22 -0
  110. package/dist/internal/typedoc-plugins/all-member-pages-router/namespace-paths.js.map +1 -0
  111. package/dist/internal/typedoc-plugins/all-member-pages-router/router.d.ts +22 -0
  112. package/dist/internal/typedoc-plugins/all-member-pages-router/router.d.ts.map +1 -0
  113. package/dist/internal/typedoc-plugins/all-member-pages-router/router.js +44 -0
  114. package/dist/internal/typedoc-plugins/all-member-pages-router/router.js.map +1 -0
  115. package/dist/internal/typedoc-plugins/api-frontmatter/constants.d.ts +11 -0
  116. package/dist/internal/typedoc-plugins/api-frontmatter/constants.d.ts.map +1 -0
  117. package/dist/internal/typedoc-plugins/api-frontmatter/constants.js +38 -0
  118. package/dist/internal/typedoc-plugins/api-frontmatter/constants.js.map +1 -0
  119. package/dist/internal/typedoc-plugins/api-frontmatter/descriptions.d.ts +18 -0
  120. package/dist/internal/typedoc-plugins/api-frontmatter/descriptions.d.ts.map +1 -0
  121. package/dist/internal/typedoc-plugins/api-frontmatter/descriptions.js +43 -0
  122. package/dist/internal/typedoc-plugins/api-frontmatter/descriptions.js.map +1 -0
  123. package/dist/internal/typedoc-plugins/api-frontmatter/frontmatter.d.ts +5 -0
  124. package/dist/internal/typedoc-plugins/api-frontmatter/frontmatter.d.ts.map +1 -0
  125. package/dist/internal/typedoc-plugins/api-frontmatter/frontmatter.js +29 -0
  126. package/dist/internal/typedoc-plugins/api-frontmatter/frontmatter.js.map +1 -0
  127. package/dist/internal/typedoc-plugins/api-frontmatter/index.d.ts +6 -0
  128. package/dist/internal/typedoc-plugins/api-frontmatter/index.d.ts.map +1 -0
  129. package/dist/internal/typedoc-plugins/api-frontmatter/index.js +19 -0
  130. package/dist/internal/typedoc-plugins/api-frontmatter/index.js.map +1 -0
  131. package/dist/internal/typedoc-plugins/api-frontmatter/library-context.d.ts +9 -0
  132. package/dist/internal/typedoc-plugins/api-frontmatter/library-context.d.ts.map +1 -0
  133. package/dist/internal/typedoc-plugins/api-frontmatter/library-context.js +11 -0
  134. package/dist/internal/typedoc-plugins/api-frontmatter/library-context.js.map +1 -0
  135. package/dist/internal/typedoc-plugins/api-frontmatter/reflection-metadata.d.ts +15 -0
  136. package/dist/internal/typedoc-plugins/api-frontmatter/reflection-metadata.d.ts.map +1 -0
  137. package/dist/internal/typedoc-plugins/api-frontmatter/reflection-metadata.js +46 -0
  138. package/dist/internal/typedoc-plugins/api-frontmatter/reflection-metadata.js.map +1 -0
  139. package/dist/internal/typedoc-plugins/include-code-examples/code-fences.d.ts +7 -0
  140. package/dist/internal/typedoc-plugins/include-code-examples/code-fences.d.ts.map +1 -0
  141. package/dist/internal/typedoc-plugins/include-code-examples/code-fences.js +23 -0
  142. package/dist/internal/typedoc-plugins/include-code-examples/code-fences.js.map +1 -0
  143. package/dist/internal/typedoc-plugins/include-code-examples/example-metadata.d.ts +7 -0
  144. package/dist/internal/typedoc-plugins/include-code-examples/example-metadata.d.ts.map +1 -0
  145. package/dist/internal/typedoc-plugins/include-code-examples/example-metadata.js +18 -0
  146. package/dist/internal/typedoc-plugins/include-code-examples/example-metadata.js.map +1 -0
  147. package/dist/internal/typedoc-plugins/include-code-examples/index.d.ts +4 -0
  148. package/dist/internal/typedoc-plugins/include-code-examples/index.d.ts.map +1 -0
  149. package/dist/internal/typedoc-plugins/include-code-examples/index.js +12 -0
  150. package/dist/internal/typedoc-plugins/include-code-examples/index.js.map +1 -0
  151. package/dist/internal/typedoc-plugins/include-code-examples/transform-markdown.d.ts +2 -0
  152. package/dist/internal/typedoc-plugins/include-code-examples/transform-markdown.d.ts.map +1 -0
  153. package/dist/internal/typedoc-plugins/include-code-examples/transform-markdown.js +17 -0
  154. package/dist/internal/typedoc-plugins/include-code-examples/transform-markdown.js.map +1 -0
  155. package/dist/internal/typedoc-plugins/strip-api-self-links/index.d.ts +8 -0
  156. package/dist/internal/typedoc-plugins/strip-api-self-links/index.d.ts.map +1 -0
  157. package/dist/internal/typedoc-plugins/strip-api-self-links/index.js +62 -0
  158. package/dist/internal/typedoc-plugins/strip-api-self-links/index.js.map +1 -0
  159. package/dist/internal/typedoc-runner.d.ts +31 -0
  160. package/dist/internal/typedoc-runner.d.ts.map +1 -0
  161. package/dist/internal/typedoc-runner.js +179 -0
  162. package/dist/internal/typedoc-runner.js.map +1 -0
  163. package/dist/internal/update-api-links.d.ts +7 -0
  164. package/dist/internal/update-api-links.d.ts.map +1 -0
  165. package/dist/internal/update-api-links.js +65 -0
  166. package/dist/internal/update-api-links.js.map +1 -0
  167. package/package.json +57 -59
  168. package/index.d.ts +0 -64
  169. package/src/cli/textmode-docs.mjs +0 -219
  170. package/src/example-quality.mjs +0 -227
  171. package/src/index.js +0 -27
  172. package/src/internal/config.js +0 -387
  173. package/src/internal/lib/api-doc-checks.mjs +0 -147
  174. package/src/internal/lib/api-doc-routes.mjs +0 -93
  175. package/src/internal/lib/example-checks.mjs +0 -315
  176. package/src/internal/lib/jsdoc-comments.mjs +0 -78
  177. package/src/internal/lib/label-schema.mjs +0 -13
  178. package/src/internal/lib/reflection-policy.mjs +0 -113
  179. package/src/internal/lib/reporting.mjs +0 -23
  180. package/src/internal/lib/sketch-title.mjs +0 -8
  181. package/src/internal/operations.js +0 -282
  182. package/src/internal/reconcile-dates.js +0 -72
  183. package/src/internal/reflection-kinds.js +0 -21
  184. package/src/internal/typedoc-plugins/accessor-docs-normalizer/README.md +0 -45
  185. package/src/internal/typedoc-plugins/accessor-docs-normalizer/accessor-comments.js +0 -53
  186. package/src/internal/typedoc-plugins/accessor-docs-normalizer/index.js +0 -32
  187. package/src/internal/typedoc-plugins/accessor-docs-normalizer/render-accessor.js +0 -144
  188. package/src/internal/typedoc-plugins/accessor-docs-normalizer/theme-patch.js +0 -28
  189. package/src/internal/typedoc-plugins/all-member-pages-router/README.md +0 -57
  190. package/src/internal/typedoc-plugins/all-member-pages-router/child-pages.js +0 -65
  191. package/src/internal/typedoc-plugins/all-member-pages-router/constants.js +0 -58
  192. package/src/internal/typedoc-plugins/all-member-pages-router/index.js +0 -18
  193. package/src/internal/typedoc-plugins/all-member-pages-router/member-paths.js +0 -48
  194. package/src/internal/typedoc-plugins/all-member-pages-router/member-reflections.js +0 -164
  195. package/src/internal/typedoc-plugins/all-member-pages-router/namespace-paths.js +0 -44
  196. package/src/internal/typedoc-plugins/all-member-pages-router/router.js +0 -58
  197. package/src/internal/typedoc-plugins/api-frontmatter/README.md +0 -66
  198. package/src/internal/typedoc-plugins/api-frontmatter/constants.js +0 -52
  199. package/src/internal/typedoc-plugins/api-frontmatter/descriptions.js +0 -87
  200. package/src/internal/typedoc-plugins/api-frontmatter/frontmatter.js +0 -57
  201. package/src/internal/typedoc-plugins/api-frontmatter/index.js +0 -39
  202. package/src/internal/typedoc-plugins/api-frontmatter/library-context.js +0 -38
  203. package/src/internal/typedoc-plugins/api-frontmatter/reflection-metadata.js +0 -95
  204. package/src/internal/typedoc-plugins/include-code-examples/README.md +0 -40
  205. package/src/internal/typedoc-plugins/include-code-examples/code-fences.js +0 -55
  206. package/src/internal/typedoc-plugins/include-code-examples/example-metadata.js +0 -41
  207. package/src/internal/typedoc-plugins/include-code-examples/index.js +0 -23
  208. package/src/internal/typedoc-plugins/include-code-examples/transform-markdown.js +0 -33
  209. package/src/internal/typedoc-plugins/strip-api-self-links/index.js +0 -117
  210. package/src/internal/typedoc-runner.js +0 -200
@@ -1,66 +0,0 @@
1
- # API Frontmatter
2
-
3
- ## Purpose
4
-
5
- This TypeDoc plugin adds textmode.js API metadata to Markdown pages generated by `typedoc-plugin-markdown` and
6
- `typedoc-plugin-frontmatter`.
7
-
8
- `typedoc-plugin-frontmatter` creates the YAML block and handles configured globals such as `layout` and `editLink`.
9
- This plugin enriches that frontmatter with API-specific fields used by the VitePress documentation experience.
10
-
11
- ## Metadata
12
-
13
- The plugin preserves existing frontmatter and adds:
14
-
15
- - `title`
16
- - `description`
17
- - `category`
18
- - `api`
19
- - `owner`
20
- - `namespace`
21
- - `kind`
22
- - `ecosystem`
23
- - `lastModified`
24
- - `hasConstructor`
25
- - `isInterface`
26
-
27
- Undefined values are removed before the page is written.
28
-
29
- ## Behavior
30
-
31
- Descriptions come from the first useful TypeDoc comment summary on the reflection, call signature, getter signature, or
32
- setter signature. The summary is reduced to the first paragraph, sanitized for YAML frontmatter, and truncated to a
33
- short SEO-friendly length. If no summary exists, the plugin generates a kind-specific fallback description.
34
-
35
- `lastModified` preserves an explicitly supplied source date. A regeneration does not invent a new modification date. Run `textmode-docs dates reconcile` after all publishing transformations to retain and update published page dates. The documentation site separately uses Git history for last-updated and sitemap dates.
36
-
37
- Packages whose names start with `textmode` are assigned to the `textmode.js` ecosystem. Other package names use their
38
- own name as the ecosystem.
39
-
40
- ## Preserved Output Contract
41
-
42
- - Existing frontmatter is preserved first, then API fields override matching keys.
43
- - Undefined values are removed before output.
44
- - Descriptions prefer reflection comments, then call signatures, getter signatures, setter signatures, then fallback
45
- templates.
46
- - Descriptions use the first paragraph, strip markdown links/raw URLs/backticks, collapse whitespace, and truncate to
47
- 160 characters.
48
- - `lastModified` remains the supplied source date when present, and is omitted otherwise.
49
-
50
- ## Contributor Notes
51
-
52
- - Safe to edit: constants, helper names, fallback tests, and README wording.
53
- - Be careful with: YAML sanitization and description truncation, because those values feed SEO metadata.
54
- - Do not casually change: frontmatter key names, merge precedence, textmode ecosystem detection, or source-date semantics.
55
-
56
- ## Maintenance
57
-
58
- This plugin is project-specific glue between TypeDoc, `typedoc-plugin-markdown`, `typedoc-plugin-frontmatter`, and the
59
- textmode.js VitePress site. Re-check the event hook and frontmatter object shape after upgrading TypeDoc or
60
- `typedoc-plugin-markdown`.
61
-
62
- Upgrade checklist:
63
-
64
- - Confirm `MarkdownPageEvent.BEGIN` still exposes `page.model`, `page.project`, and mutable `page.frontmatter`.
65
- - Run `npm run test:tooling`.
66
- - Inspect generated frontmatter for a project page, namespace member, class, interface, accessor, and method.
@@ -1,52 +0,0 @@
1
- // @ts-check
2
-
3
- import { ReflectionKind } from 'typedoc';
4
-
5
- export const UNKNOWN_LIBRARY_NAME = 'Unknown Library';
6
- export const TEXTMODE_ECOSYSTEM_NAME = 'textmode.js';
7
- export const TEXTMODE_PACKAGE_PREFIX = 'textmode';
8
- export const DESCRIPTION_MAX_LENGTH = 160;
9
- export const DESCRIPTION_TRUNCATION_SUFFIX = '...';
10
-
11
- /**
12
- * @type {ReadonlyMap<import('typedoc').ReflectionKind, string>}
13
- */
14
- export const CATEGORY_BY_KIND = new Map([
15
- [ReflectionKind.Class, 'Classes'],
16
- [ReflectionKind.Interface, 'Interfaces'],
17
- [ReflectionKind.Enum, 'Enumerations'],
18
- [ReflectionKind.Function, 'Functions'],
19
- [ReflectionKind.TypeAlias, 'Type Aliases'],
20
- [ReflectionKind.Variable, 'Variables'],
21
- [ReflectionKind.Property, 'Properties'],
22
- [ReflectionKind.Accessor, 'Accessors'],
23
- [ReflectionKind.Method, 'Methods'],
24
- [ReflectionKind.Constructor, 'Constructors'],
25
- [ReflectionKind.Namespace, 'Namespaces'],
26
- [ReflectionKind.Module, 'Modules'],
27
- ]);
28
-
29
- /**
30
- * Fallback description templates for each reflection kind.
31
- * `{name}` is replaced with the reflection name and `{library}` with the library name.
32
- *
33
- * @type {ReadonlyMap<import('typedoc').ReflectionKind, string>}
34
- */
35
- export const DESCRIPTION_TEMPLATE_BY_KIND = new Map([
36
- [ReflectionKind.Class, 'API documentation for the {name} class in {library}.'],
37
- [ReflectionKind.Interface, 'API documentation for the {name} interface in {library}.'],
38
- [ReflectionKind.Enum, '{name} enumeration values and usage in {library}.'],
39
- [ReflectionKind.Function, '{name} function API reference for {library}.'],
40
- [ReflectionKind.TypeAlias, '{name} type definition and usage in {library}.'],
41
- [ReflectionKind.Variable, '{name} variable reference in {library}.'],
42
- [ReflectionKind.Property, '{name} property reference for {library}.'],
43
- [ReflectionKind.Accessor, '{name} accessor reference for {library}.'],
44
- [ReflectionKind.Method, '{name} method reference for {library}.'],
45
- [ReflectionKind.Constructor, '{name} constructor reference for {library}.'],
46
- [ReflectionKind.Namespace, '{name} namespace - types and utilities in {library}.'],
47
- [ReflectionKind.Project, 'Complete API reference for {library}.'],
48
- [ReflectionKind.Module, 'API reference documentation for {name}.'],
49
- ]);
50
-
51
- export const DEFAULT_DESCRIPTION_TEMPLATE = 'API reference for {name} in {library}.';
52
- export const API_REFERENCE_CATEGORY = 'API Reference';
@@ -1,87 +0,0 @@
1
- // @ts-check
2
-
3
- import { ReflectionKind } from 'typedoc';
4
-
5
- import {
6
- DEFAULT_DESCRIPTION_TEMPLATE,
7
- DESCRIPTION_MAX_LENGTH,
8
- DESCRIPTION_TEMPLATE_BY_KIND,
9
- DESCRIPTION_TRUNCATION_SUFFIX,
10
- } from './constants.js';
11
-
12
- /**
13
- * Sanitize text for YAML frontmatter.
14
- *
15
- * @param {string} text
16
- * @returns {string}
17
- */
18
- export function sanitizeForYaml(text) {
19
- return text
20
- .replace(/\[([^\]]+)\]\([^)]+\)/g, '$1')
21
- .replace(/https?:\/\/[^\s]+/g, '')
22
- .replace(/`([^`]+)`/g, '$1')
23
- .replace(/\s+/g, ' ')
24
- .trim();
25
- }
26
-
27
- /**
28
- * Generate a fallback description using reflection kind templates.
29
- *
30
- * @param {import('typedoc').Reflection} model
31
- * @param {import('./library-context.js').LibraryContext} library
32
- * @returns {string}
33
- */
34
- export function generateFallbackDescription(model, library) {
35
- const kind = model.kind;
36
- const name = model.name;
37
-
38
- if ((kind === ReflectionKind.Project || kind === ReflectionKind.Module) && name === library.name) {
39
- return library.description;
40
- }
41
-
42
- const template = DESCRIPTION_TEMPLATE_BY_KIND.get(kind) ?? DEFAULT_DESCRIPTION_TEMPLATE;
43
-
44
- return template.replace('{name}', name).replace('{library}', library.name);
45
- }
46
-
47
- /**
48
- * Extract a page description from TypeDoc comments, or generate a fallback.
49
- *
50
- * @param {import('typedoc').Reflection} model
51
- * @param {import('./library-context.js').LibraryContext} library
52
- * @returns {string}
53
- */
54
- export function extractDescription(model, library) {
55
- if (
56
- (model.kind === ReflectionKind.Project || model.kind === ReflectionKind.Module) &&
57
- model.name === library.name
58
- ) {
59
- return library.description;
60
- }
61
-
62
- const comment =
63
- model.comment ?? model.signatures?.[0]?.comment ?? model.getSignature?.comment ?? model.setSignature?.comment;
64
-
65
- if (comment?.summary) {
66
- const summary = comment.summary
67
- .map((part) => part.text || '')
68
- .join('')
69
- .trim();
70
-
71
- if (summary) {
72
- const firstParagraph = summary.split(/\n\s*\n/)[0].trim();
73
- const sanitized = sanitizeForYaml(firstParagraph);
74
-
75
- if (sanitized.length > DESCRIPTION_MAX_LENGTH) {
76
- return (
77
- sanitized.substring(0, DESCRIPTION_MAX_LENGTH - DESCRIPTION_TRUNCATION_SUFFIX.length) +
78
- DESCRIPTION_TRUNCATION_SUFFIX
79
- );
80
- }
81
-
82
- return sanitized;
83
- }
84
- }
85
-
86
- return generateFallbackDescription(model, library);
87
- }
@@ -1,57 +0,0 @@
1
- // @ts-check
2
-
3
- import { ReflectionKind } from 'typedoc';
4
-
5
- import { extractDescription } from './descriptions.js';
6
- import {
7
- getCategoryForKind,
8
- getHasConstructor,
9
- getIsInterface,
10
- getNamespacePath,
11
- getOwnerName,
12
- isInNamespace,
13
- } from './reflection-metadata.js';
14
-
15
- /**
16
- * Remove undefined values from a frontmatter object.
17
- *
18
- * @param {Record<string, unknown>} frontmatter
19
- * @returns {Record<string, unknown>}
20
- */
21
- export function removeUndefinedValues(frontmatter) {
22
- for (const key of Object.keys(frontmatter)) {
23
- if (frontmatter[key] === undefined) {
24
- delete frontmatter[key];
25
- }
26
- }
27
-
28
- return frontmatter;
29
- }
30
-
31
- /**
32
- * Build API frontmatter for a TypeDoc markdown page.
33
- *
34
- * @param {import('typedoc').Reflection} model
35
- * @param {Record<string, unknown>} existingFrontmatter
36
- * @param {import('./library-context.js').LibraryContext} library
37
- * @returns {Record<string, unknown>}
38
- */
39
- export function buildApiFrontmatter(model, existingFrontmatter, library) {
40
- const kind = model.kind;
41
-
42
- return removeUndefinedValues({
43
- ...existingFrontmatter,
44
- title: model.name,
45
- description: extractDescription(model, library),
46
- category: getCategoryForKind(kind),
47
- api: true,
48
- owner: getOwnerName(model),
49
- namespace: isInNamespace(model) ? getNamespacePath(model) : undefined,
50
- kind: ReflectionKind[kind],
51
- ecosystem: library.ecosystem !== library.name ? library.ecosystem : undefined,
52
- // A regeneration is not a content edit. Preserve an explicitly supplied date.
53
- lastModified: existingFrontmatter.lastModified,
54
- hasConstructor: getHasConstructor(model),
55
- isInterface: getIsInterface(model),
56
- });
57
- }
@@ -1,39 +0,0 @@
1
- // @ts-check
2
-
3
- import { MarkdownPageEvent } from 'typedoc-plugin-markdown';
4
-
5
- import { buildApiFrontmatter } from './frontmatter.js';
6
- import { extractLibraryContext } from './library-context.js';
7
-
8
- /**
9
- * TypeDoc plugin load function.
10
- *
11
- * @param {import('typedoc-plugin-markdown').MarkdownApplication} app
12
- * @param {{ packageDescription?: string }} [options]
13
- * @returns {void}
14
- */
15
- export function load(app, options = {}) {
16
- app.logger.verbose('[frontmatter] Registered textmode.js API frontmatter plugin');
17
-
18
- /** @type {import('./library-context.js').LibraryContext | null} */
19
- let libraryContext = null;
20
-
21
- app.renderer.on(
22
- MarkdownPageEvent.BEGIN,
23
- /** @param {import('typedoc-plugin-markdown').MarkdownPageEvent} page */
24
- (page) => {
25
- if (!page.model) {
26
- return;
27
- }
28
-
29
- if (!libraryContext) {
30
- libraryContext = extractLibraryContext(page.project, options.packageDescription);
31
- app.logger.verbose(
32
- `[frontmatter] Library: ${libraryContext.name} (ecosystem: ${libraryContext.ecosystem})`
33
- );
34
- }
35
-
36
- page.frontmatter = buildApiFrontmatter(page.model, page.frontmatter, libraryContext);
37
- }
38
- );
39
- }
@@ -1,38 +0,0 @@
1
- // @ts-check
2
-
3
- import { TEXTMODE_ECOSYSTEM_NAME, TEXTMODE_PACKAGE_PREFIX, UNKNOWN_LIBRARY_NAME } from './constants.js';
4
-
5
- /**
6
- * Library context extracted from package.json and the TypeDoc project.
7
- *
8
- * @typedef {Object} LibraryContext
9
- * @property {string} name
10
- * @property {string} description
11
- * @property {string} ecosystem
12
- */
13
-
14
- /**
15
- * Get the ecosystem name for a package.
16
- *
17
- * @param {string} packageName
18
- * @returns {string}
19
- */
20
- export function getEcosystemName(packageName) {
21
- return packageName.startsWith(TEXTMODE_PACKAGE_PREFIX) ? TEXTMODE_ECOSYSTEM_NAME : packageName;
22
- }
23
-
24
- /**
25
- * Extract library context from TypeDoc project metadata and package.json.
26
- *
27
- * @param {import('typedoc').ProjectReflection} project
28
- * @param {string | undefined} packageDescription
29
- * @returns {LibraryContext}
30
- */
31
- export function extractLibraryContext(project, packageDescription) {
32
- const name = project.packageName ?? project.name ?? UNKNOWN_LIBRARY_NAME;
33
- const description = packageDescription || `API reference for ${name}`;
34
-
35
- const ecosystem = getEcosystemName(name);
36
-
37
- return { name, description, ecosystem };
38
- }
@@ -1,95 +0,0 @@
1
- // @ts-check
2
-
3
- import { ReflectionKind } from 'typedoc';
4
-
5
- import { API_REFERENCE_CATEGORY, CATEGORY_BY_KIND } from './constants.js';
6
-
7
- /**
8
- * Get the frontmatter category for a reflection kind.
9
- *
10
- * @param {import('typedoc').ReflectionKind} kind
11
- * @returns {string}
12
- */
13
- export function getCategoryForKind(kind) {
14
- return CATEGORY_BY_KIND.get(kind) ?? API_REFERENCE_CATEGORY;
15
- }
16
-
17
- /**
18
- * Check if a reflection belongs to a namespace.
19
- *
20
- * @param {import('typedoc').Reflection} model
21
- * @returns {boolean}
22
- */
23
- export function isInNamespace(model) {
24
- let parent = model.parent;
25
- while (parent) {
26
- if (parent.kind === ReflectionKind.Namespace) {
27
- return true;
28
- }
29
- parent = parent.parent;
30
- }
31
- return false;
32
- }
33
-
34
- /**
35
- * Get the full namespace path for a reflection.
36
- *
37
- * @param {import('typedoc').Reflection} model
38
- * @returns {string | undefined}
39
- */
40
- export function getNamespacePath(model) {
41
- /** @type {string[]} */
42
- const parts = [];
43
- let parent = model.parent;
44
-
45
- while (parent) {
46
- if (parent.kind === ReflectionKind.Namespace) {
47
- parts.unshift(parent.name);
48
- }
49
- parent = parent.parent;
50
- }
51
-
52
- return parts.length > 0 ? parts.join('.') : undefined;
53
- }
54
-
55
- /**
56
- * Get the owning class or interface name for member reflections.
57
- *
58
- * @param {import('typedoc').Reflection} model
59
- * @returns {string | undefined}
60
- */
61
- export function getOwnerName(model) {
62
- let parent = model.parent;
63
- while (parent) {
64
- if (parent.kind === ReflectionKind.Class || parent.kind === ReflectionKind.Interface) {
65
- return parent.name;
66
- }
67
- parent = parent.parent;
68
- }
69
-
70
- return undefined;
71
- }
72
-
73
- /**
74
- * Check if a class reflection has a constructor child.
75
- *
76
- * @param {import('typedoc').Reflection} model
77
- * @returns {boolean | undefined}
78
- */
79
- export function getHasConstructor(model) {
80
- if (model.kind !== ReflectionKind.Class || !('children' in model)) {
81
- return undefined;
82
- }
83
-
84
- return model.children?.some((child) => child.kind === ReflectionKind.Constructor);
85
- }
86
-
87
- /**
88
- * Check if a reflection is an interface.
89
- *
90
- * @param {import('typedoc').Reflection} model
91
- * @returns {true | undefined}
92
- */
93
- export function getIsInterface(model) {
94
- return model.kind === ReflectionKind.Interface ? true : undefined;
95
- }
@@ -1,40 +0,0 @@
1
- # Include Code Examples
2
-
3
- ## Purpose
4
-
5
- This TypeDoc plugin cleans up example sketches included in API docs with `{@includeCode ...}`.
6
-
7
- Example sketches keep leading gallery metadata such as `@title` and `@author` so the examples gallery and validation
8
- scripts can read it. API reference pages should show only the runnable sketch code, so this plugin removes a leading
9
- JSDoc metadata block from supported fenced code blocks after TypeDoc has rendered markdown.
10
-
11
- The plugin also normalizes transformed `js` fences to `javascript` for VitePress syntax highlighting. That normalization
12
- is intentionally gated by metadata stripping: a plain `js` fence without a leading metadata block is left unchanged.
13
-
14
- This is a post-render markdown transform. It does not edit source examples, change TypeDoc reflections, or add new
15
- TypeDoc options.
16
-
17
- ## Preserved Output Contract
18
-
19
- - Only fenced `js`, `jsx`, `ts`, `tsx`, `javascript`, and `typescript` blocks are considered.
20
- - Only a leading JSDoc metadata block is stripped.
21
- - Plain code fences without stripped metadata are left byte-for-byte unchanged.
22
- - `js` fences are normalized to `javascript` only when metadata was stripped.
23
- - Unsupported and language-less fences are left unchanged.
24
-
25
- ## Contributor Notes
26
-
27
- - Safe to edit: helper names, supported-language tests, and comments.
28
- - Be careful with: `EXAMPLE_CODE_FENCE_PATTERN`, because it intentionally operates after TypeDoc renders markdown.
29
- - Do not casually change: supported language gating, `js` normalization timing, or the “leading docblock only” rule.
30
-
31
- ## Maintenance
32
-
33
- This plugin depends on TypeDoc rendering `{@includeCode ...}` examples as fenced code blocks before
34
- `MarkdownPageEvent.END`. Re-check the transform after upgrading TypeDoc or `typedoc-plugin-markdown`.
35
-
36
- Upgrade checklist:
37
-
38
- - Confirm included examples still arrive in `page.contents` as fenced markdown.
39
- - Run `npm run test:tooling`.
40
- - Inspect a generated API example and verify gallery metadata such as `@title` is absent.
@@ -1,55 +0,0 @@
1
- // @ts-check
2
-
3
- export const EXAMPLE_CODE_FENCE_PATTERN = /```([^\n]*)\n([\s\S]*?)```/g;
4
-
5
- export const SUPPORTED_INCLUDED_EXAMPLE_LANGUAGES = new Set(['js', 'jsx', 'ts', 'tsx', 'javascript', 'typescript']);
6
-
7
- /**
8
- * Get the language token from a fenced code block info string.
9
- *
10
- * @param {string} infoString
11
- * @returns {string}
12
- */
13
- export function getFenceLanguage(infoString) {
14
- return infoString.trim().split(/\s+/, 1)[0]?.toLowerCase() ?? '';
15
- }
16
-
17
- /**
18
- * Check whether the language can contain an included sketch.
19
- *
20
- * @param {string} language
21
- * @returns {boolean}
22
- */
23
- export function isSupportedExampleLanguage(language) {
24
- return SUPPORTED_INCLUDED_EXAMPLE_LANGUAGES.has(language);
25
- }
26
-
27
- /**
28
- * Normalize the fence language for transformed included examples.
29
- *
30
- * @param {string} infoString
31
- * @returns {string}
32
- */
33
- export function normalizeIncludedExampleFenceInfo(infoString) {
34
- const trimmedInfoString = infoString.trim();
35
- if (!trimmedInfoString) {
36
- return infoString;
37
- }
38
-
39
- const parts = trimmedInfoString.split(/\s+/);
40
- if (parts[0].toLowerCase() === 'js') {
41
- parts[0] = 'javascript';
42
- }
43
-
44
- return parts.join(' ');
45
- }
46
-
47
- /**
48
- * Ensure transformed code ends with one newline before the closing fence.
49
- *
50
- * @param {string} code
51
- * @returns {string}
52
- */
53
- export function ensureTrailingNewline(code) {
54
- return code.endsWith('\n') ? code : `${code}\n`;
55
- }
@@ -1,41 +0,0 @@
1
- // @ts-check
2
-
3
- const LEADING_EXAMPLE_METADATA_PATTERN = /^\s*\/\*\*([\s\S]*?)\*\/\s*\n?/;
4
-
5
- /**
6
- * Strip the leading gallery metadata docblock from an included example.
7
- *
8
- * @param {string} source
9
- * @returns {string}
10
- */
11
- export function stripLeadingExampleMetadataDocblock(source) {
12
- const match = source.match(LEADING_EXAMPLE_METADATA_PATTERN);
13
- if (!match) {
14
- return source;
15
- }
16
-
17
- return source.slice(match[0].length).replace(/^\n+/, '');
18
- }
19
-
20
- /**
21
- * Backwards-compatible helper name retained for copied add-on plugin stacks.
22
- *
23
- * @param {string} source
24
- * @returns {string}
25
- */
26
- export function stripLeadingExampleMetadata(source) {
27
- return stripLeadingExampleMetadataDocblock(source);
28
- }
29
-
30
- /**
31
- * Preserve the old helper shape while keeping metadata parsing intentionally minimal.
32
- *
33
- * @param {string} source
34
- * @returns {{ metadata: null; code: string }}
35
- */
36
- export function extractExampleMetadata(source) {
37
- return {
38
- metadata: null,
39
- code: stripLeadingExampleMetadataDocblock(source),
40
- };
41
- }
@@ -1,23 +0,0 @@
1
- // @ts-check
2
-
3
- import { MarkdownPageEvent } from 'typedoc-plugin-markdown';
4
-
5
- import { transformExampleCodeBlocks } from './transform-markdown.js';
6
-
7
- /**
8
- * TypeDoc plugin load function.
9
- *
10
- * @param {import('typedoc-plugin-markdown').MarkdownApplication} app
11
- * @returns {void}
12
- */
13
- export function load(app) {
14
- app.renderer.on(MarkdownPageEvent.END, (page) => {
15
- if (!page.contents) {
16
- return;
17
- }
18
-
19
- page.contents = transformExampleCodeBlocks(page.contents);
20
- });
21
-
22
- app.logger.verbose('[typedoc] Registered includeCode example normalizer');
23
- }
@@ -1,33 +0,0 @@
1
- // @ts-check
2
-
3
- import {
4
- ensureTrailingNewline,
5
- EXAMPLE_CODE_FENCE_PATTERN,
6
- getFenceLanguage,
7
- isSupportedExampleLanguage,
8
- normalizeIncludedExampleFenceInfo,
9
- } from './code-fences.js';
10
- import { stripLeadingExampleMetadataDocblock } from './example-metadata.js';
11
-
12
- /**
13
- * Remove gallery metadata from included example code blocks.
14
- *
15
- * @param {string} markdown
16
- * @returns {string}
17
- */
18
- export function transformExampleCodeBlocks(markdown) {
19
- return markdown.replace(EXAMPLE_CODE_FENCE_PATTERN, (fullMatch, infoString, code) => {
20
- const language = getFenceLanguage(infoString);
21
- if (!isSupportedExampleLanguage(language)) {
22
- return fullMatch;
23
- }
24
-
25
- const strippedCode = stripLeadingExampleMetadataDocblock(code);
26
- if (strippedCode === code) {
27
- return fullMatch;
28
- }
29
-
30
- const normalizedInfoString = normalizeIncludedExampleFenceInfo(infoString);
31
- return `\`\`\`${normalizedInfoString}\n${ensureTrailingNewline(strippedCode)}\`\`\``;
32
- });
33
- }