@textmode/docs 0.4.2 → 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 (207) hide show
  1. package/LICENSE +21 -121
  2. package/README.md +24 -25
  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 -37
  169. package/src/cli/textmode-docs.mjs +0 -219
  170. package/src/index.js +0 -23
  171. package/src/internal/config.js +0 -387
  172. package/src/internal/lib/api-doc-checks.mjs +0 -147
  173. package/src/internal/lib/api-doc-routes.mjs +0 -93
  174. package/src/internal/lib/example-checks.mjs +0 -405
  175. package/src/internal/lib/jsdoc-comments.mjs +0 -78
  176. package/src/internal/lib/reflection-policy.mjs +0 -113
  177. package/src/internal/lib/reporting.mjs +0 -23
  178. package/src/internal/operations.js +0 -275
  179. package/src/internal/reconcile-dates.js +0 -72
  180. package/src/internal/reflection-kinds.js +0 -21
  181. package/src/internal/typedoc-plugins/accessor-docs-normalizer/README.md +0 -45
  182. package/src/internal/typedoc-plugins/accessor-docs-normalizer/accessor-comments.js +0 -53
  183. package/src/internal/typedoc-plugins/accessor-docs-normalizer/index.js +0 -32
  184. package/src/internal/typedoc-plugins/accessor-docs-normalizer/render-accessor.js +0 -144
  185. package/src/internal/typedoc-plugins/accessor-docs-normalizer/theme-patch.js +0 -28
  186. package/src/internal/typedoc-plugins/all-member-pages-router/README.md +0 -57
  187. package/src/internal/typedoc-plugins/all-member-pages-router/child-pages.js +0 -65
  188. package/src/internal/typedoc-plugins/all-member-pages-router/constants.js +0 -58
  189. package/src/internal/typedoc-plugins/all-member-pages-router/index.js +0 -18
  190. package/src/internal/typedoc-plugins/all-member-pages-router/member-paths.js +0 -48
  191. package/src/internal/typedoc-plugins/all-member-pages-router/member-reflections.js +0 -164
  192. package/src/internal/typedoc-plugins/all-member-pages-router/namespace-paths.js +0 -44
  193. package/src/internal/typedoc-plugins/all-member-pages-router/router.js +0 -58
  194. package/src/internal/typedoc-plugins/api-frontmatter/README.md +0 -66
  195. package/src/internal/typedoc-plugins/api-frontmatter/constants.js +0 -52
  196. package/src/internal/typedoc-plugins/api-frontmatter/descriptions.js +0 -87
  197. package/src/internal/typedoc-plugins/api-frontmatter/frontmatter.js +0 -57
  198. package/src/internal/typedoc-plugins/api-frontmatter/index.js +0 -39
  199. package/src/internal/typedoc-plugins/api-frontmatter/library-context.js +0 -38
  200. package/src/internal/typedoc-plugins/api-frontmatter/reflection-metadata.js +0 -95
  201. package/src/internal/typedoc-plugins/include-code-examples/README.md +0 -40
  202. package/src/internal/typedoc-plugins/include-code-examples/code-fences.js +0 -55
  203. package/src/internal/typedoc-plugins/include-code-examples/example-metadata.js +0 -41
  204. package/src/internal/typedoc-plugins/include-code-examples/index.js +0 -23
  205. package/src/internal/typedoc-plugins/include-code-examples/transform-markdown.js +0 -33
  206. package/src/internal/typedoc-plugins/strip-api-self-links/index.js +0 -117
  207. package/src/internal/typedoc-runner.js +0 -200
@@ -1,57 +0,0 @@
1
- # All Member Pages Router
2
-
3
- ## Purpose
4
-
5
- This TypeDoc router makes direct public methods render as focused Markdown pages when an owner page would otherwise
6
- render too many Sandpack examples.
7
-
8
- `typedoc-plugin-markdown` can render top-level API structures as pages, but textmode.js also needs compact class and
9
- interface overview pages that link to individual methods once their inline examples would make the page heavy. This
10
- router keeps those owner pages small and gives each direct method a stable page.
11
-
12
- ## Member Pages
13
-
14
- The router creates pages for direct class/interface methods when rendering the owner page inline would exceed three
15
- Sandpack examples:
16
-
17
- - methods
18
-
19
- Nested type-literal fields intentionally remain inline or anchor-based so structural types do not explode into many
20
- small pages.
21
-
22
- ## Paths
23
-
24
- Examples:
25
-
26
- - `classes/Textmodifier/methods/background.md`
27
- - `namespaces/layering/classes/TextmodeLayer/methods/draw.md`
28
-
29
- ## Preserved Output Contract
30
-
31
- - The router name remains `all-member-pages`.
32
- - Direct methods get pages only when their class/interface owner would otherwise exceed three Sandpack examples.
33
- - Properties, accessors, constructors, variables, type aliases, functions, and nested type-literal members do not get
34
- extra pages from this router.
35
- - Existing `MemberRouter` behavior for modules, namespaces, documents, and configured `membersWithOwnFile` kinds is
36
- preserved.
37
- - Project-root namespaces use the flattened textmode.js path shape, for example `namespaces/color/classes/TextmodeColor.md`.
38
- - Sidebar entries include generated member pages under their owners.
39
-
40
- ## Contributor Notes
41
-
42
- - Safe to edit: constants, helper names, tests, and README wording.
43
- - Be careful with: `child-pages.js`, which intentionally mirrors upstream `MemberRouter` traversal.
44
- - Do not casually change: path segment names, namespace path flattening, example-count thresholds, or direct-method page
45
- eligibility.
46
-
47
- ## Maintenance
48
-
49
- This plugin extends `typedoc-plugin-markdown`'s `MemberRouter` and copies its child-page traversal policy so direct
50
- members can participate in TypeDoc's `hasOwnDocument` behavior. Re-check this router after upgrading TypeDoc or
51
- `typedoc-plugin-markdown`, especially around router APIs, `membersWithOwnFile`, and namespace path handling.
52
-
53
- Upgrade checklist:
54
-
55
- - Compare `child-pages.js` against the current upstream `MemberRouter.buildChildPages`.
56
- - Confirm `PageKind.Reflection`, `Slugger`, `fullUrls`, and `sluggers` are still the correct router APIs.
57
- - Run `npm run build:docs` and verify generated method links still resolve.
@@ -1,65 +0,0 @@
1
- // @ts-check
2
-
3
- import { Reflection, Slugger } from 'typedoc';
4
-
5
- import { isDirectMemberPageReflection, shouldRenderOwnPage } from './member-reflections.js';
6
-
7
- /**
8
- * @typedef {{
9
- * extension: string;
10
- * fullUrls: Map<import('typedoc').Reflection, string>;
11
- * sluggerConfiguration: unknown;
12
- * sluggers: Map<import('typedoc').Reflection, Slugger>;
13
- * getFileName(idealName: string): string;
14
- * getIdealBaseName(reflection: import('typedoc').Reflection): string;
15
- * getPageKind(reflection: import('typedoc').Reflection): import('typedoc').PageKind | undefined;
16
- * shouldWritePage(reflection: import('typedoc').Reflection): boolean;
17
- * buildAnchors(reflection: import('typedoc').Reflection, parent?: import('typedoc').Reflection): void;
18
- * membersWithOwnFile: string[];
19
- * kindsToString: Map<import('typedoc').ReflectionKind, string>;
20
- * }} ChildPageRouter
21
- */
22
-
23
- /**
24
- * Build child pages using typedoc-plugin-markdown's MemberRouter traversal
25
- * shape, while delegating textmode.js' expanded own-page policy to local
26
- * helpers. This mirrors upstream traversal intentionally; when upgrading
27
- * typedoc-plugin-markdown, compare this function against MemberRouter.
28
- *
29
- * @param {ChildPageRouter} router
30
- * @param {import('typedoc').Reflection} reflection
31
- * @param {import('typedoc').PageDefinition[]} outPages
32
- * @returns {void}
33
- */
34
- export function buildMemberRouterChildPages(router, reflection, outPages) {
35
- const kind = router.getPageKind(reflection);
36
- if (!kind) {
37
- router.buildAnchors(reflection, reflection.parent);
38
- return;
39
- }
40
-
41
- const shouldWritePage = isDirectMemberPageReflection(reflection) || router.shouldWritePage(reflection);
42
- const idealName = router.getIdealBaseName(reflection);
43
- const actualName = shouldWritePage ? router.getFileName(idealName) : `${idealName}${router.extension}`;
44
- router.fullUrls.set(reflection, actualName);
45
-
46
- if (shouldRenderOwnPage(reflection, router)) {
47
- if (shouldWritePage) {
48
- router.sluggers.set(reflection, new Slugger(router.sluggerConfiguration));
49
- outPages.push({
50
- kind,
51
- model: reflection,
52
- url: actualName,
53
- });
54
- }
55
- } else {
56
- router.buildAnchors(reflection, reflection.parent);
57
- }
58
-
59
- if (reflection instanceof Reflection) {
60
- reflection.traverse((child) => {
61
- buildMemberRouterChildPages(router, child, outPages);
62
- return true;
63
- });
64
- }
65
- }
@@ -1,58 +0,0 @@
1
- // @ts-check
2
-
3
- import { ReflectionKind } from 'typedoc';
4
-
5
- export const ROUTER_NAME = 'all-member-pages';
6
-
7
- export const ALWAYS_OWN_PAGE_KIND_NAMES = ['Module', 'Namespace', 'Document'];
8
-
9
- export const MAX_INLINE_SANDPACK_EXAMPLES = 3;
10
-
11
- export const MEMBER_PAGE_OWNER_KINDS = new Set([ReflectionKind.Class, ReflectionKind.Interface]);
12
-
13
- export const MEMBER_PAGE_KINDS = new Set([ReflectionKind.Method, ReflectionKind.Property, ReflectionKind.Accessor]);
14
-
15
- export const MEMBER_DIRECTORIES = new Map([
16
- [ReflectionKind.Method, 'methods'],
17
- [ReflectionKind.Property, 'properties'],
18
- [ReflectionKind.Accessor, 'accessors'],
19
- ]);
20
-
21
- const MEMBER_KIND_BY_NAME = new Map([
22
- ['method', ReflectionKind.Method],
23
- ['property', ReflectionKind.Property],
24
- ['accessor', ReflectionKind.Accessor],
25
- ]);
26
-
27
- /**
28
- * @param {string[]} memberPageKindNames
29
- * @returns {void}
30
- */
31
- export function configureMemberPages(memberPageKindNames) {
32
- MEMBER_PAGE_KINDS.clear();
33
- MEMBER_DIRECTORIES.clear();
34
-
35
- const normalizedMemberPageKindNames = Array.isArray(memberPageKindNames)
36
- ? memberPageKindNames
37
- : String(memberPageKindNames).split(',');
38
-
39
- for (const memberPageKindName of normalizedMemberPageKindNames) {
40
- const kind = MEMBER_KIND_BY_NAME.get(String(memberPageKindName).toLowerCase());
41
-
42
- if (kind === undefined) {
43
- continue;
44
- }
45
-
46
- MEMBER_PAGE_KINDS.add(kind);
47
- }
48
-
49
- if (MEMBER_PAGE_KINDS.has(ReflectionKind.Method)) {
50
- MEMBER_DIRECTORIES.set(ReflectionKind.Method, 'methods');
51
- }
52
- if (MEMBER_PAGE_KINDS.has(ReflectionKind.Property)) {
53
- MEMBER_DIRECTORIES.set(ReflectionKind.Property, 'properties');
54
- }
55
- if (MEMBER_PAGE_KINDS.has(ReflectionKind.Accessor)) {
56
- MEMBER_DIRECTORIES.set(ReflectionKind.Accessor, 'accessors');
57
- }
58
- }
@@ -1,18 +0,0 @@
1
- // @ts-check
2
-
3
- import { configureMemberPages, ROUTER_NAME } from './constants.js';
4
- import { AllMemberPagesRouter } from './router.js';
5
-
6
- /**
7
- * TypeDoc plugin load function.
8
- *
9
- * @param {import('typedoc').Application} app
10
- * @param {{ memberPageKinds?: string[] }} [options]
11
- * @returns {void}
12
- */
13
- export function load(app, options = {}) {
14
- configureMemberPages(options.memberPageKinds ?? ['method', 'property', 'accessor']);
15
-
16
- app.renderer.defineRouter(ROUTER_NAME, AllMemberPagesRouter);
17
- app.logger.verbose('[typedoc] Registered all member pages router');
18
- }
@@ -1,48 +0,0 @@
1
- // @ts-check
2
-
3
- import { MEMBER_DIRECTORIES } from './constants.js';
4
-
5
- /**
6
- * @typedef {{
7
- * getIdealBaseName(reflection: import('typedoc').Reflection): string;
8
- * }} MemberDirectoryRouter
9
- */
10
-
11
- /**
12
- * @typedef {{
13
- * getReflectionAlias(reflection: import('typedoc').Reflection): string;
14
- * }} ReflectionAliasRouter
15
- */
16
-
17
- /**
18
- * Get the directory name for a direct Sandpack member kind.
19
- *
20
- * @param {import('typedoc').ReflectionKind} kind
21
- * @returns {string | undefined}
22
- */
23
- export function getMemberDirectoryName(kind) {
24
- return MEMBER_DIRECTORIES.get(kind);
25
- }
26
-
27
- /**
28
- * Build the directory path for a direct Sandpack member page.
29
- *
30
- * @param {MemberDirectoryRouter} router
31
- * @param {import('typedoc').Reflection} reflection
32
- * @returns {string}
33
- */
34
- export function getDirectMemberDirectory(router, reflection) {
35
- const directory = getMemberDirectoryName(reflection.kind);
36
- return `${router.getIdealBaseName(reflection.parent)}/${directory}`;
37
- }
38
-
39
- /**
40
- * Build a reflection filename for a direct Sandpack member page.
41
- *
42
- * @param {ReflectionAliasRouter} router
43
- * @param {import('typedoc').Reflection} reflection
44
- * @returns {string}
45
- */
46
- export function getReflectionFileName(router, reflection) {
47
- return router.getReflectionAlias(reflection);
48
- }
@@ -1,164 +0,0 @@
1
- // @ts-check
2
-
3
- import { ReflectionKind } from 'typedoc';
4
-
5
- import {
6
- ALWAYS_OWN_PAGE_KIND_NAMES,
7
- MEMBER_PAGE_KINDS,
8
- MEMBER_PAGE_OWNER_KINDS,
9
- MAX_INLINE_SANDPACK_EXAMPLES,
10
- } from './constants.js';
11
-
12
- /**
13
- * @typedef {{
14
- * membersWithOwnFile: string[];
15
- * kindsToString: Map<import('typedoc').ReflectionKind, string>;
16
- * }} OwnPagePolicyRouter
17
- */
18
-
19
- /**
20
- * @param {import('typedoc').Reflection | undefined} reflection
21
- * @returns {string[]}
22
- */
23
- function getOwnSandpackExamples(reflection) {
24
- return (reflection?.comment?.blockTags || []).flatMap((tag) => {
25
- if (tag.tag !== '@example') {
26
- return [];
27
- }
28
-
29
- const content = (tag.content || []).map((part) => part.text).join('');
30
- return /```(?:js|javascript|jsx|ts|typescript|tsx)\b/i.test(content) && /@title\b/.test(content)
31
- ? [content]
32
- : [];
33
- });
34
- }
35
-
36
- /**
37
- * @param {import('typedoc').Reflection} reflection
38
- * @returns {number}
39
- */
40
- function countReflectionSandpackExamples(reflection) {
41
- const examples = new Set([
42
- ...getOwnSandpackExamples(reflection),
43
- ...(reflection.signatures || []).flatMap((signature) => getOwnSandpackExamples(signature)),
44
- ...getOwnSandpackExamples(reflection.getSignature),
45
- ...getOwnSandpackExamples(reflection.setSignature),
46
- ]);
47
-
48
- return examples.size;
49
- }
50
-
51
- /**
52
- * @param {import('typedoc').Reflection} reflection
53
- * @returns {boolean}
54
- */
55
- function isPropertyLikeReflection(reflection) {
56
- return reflection.kind === ReflectionKind.Property || reflection.kind === ReflectionKind.Accessor;
57
- }
58
-
59
- /**
60
- * @param {import('typedoc').Reflection} reflection
61
- * @returns {boolean}
62
- */
63
- function isSandpackThresholdMemberReflection(reflection) {
64
- return (
65
- (reflection.kind === ReflectionKind.Method || isPropertyLikeReflection(reflection)) &&
66
- countReflectionSandpackExamples(reflection) > 0
67
- );
68
- }
69
-
70
- /**
71
- * @param {import('typedoc').Reflection} owner
72
- * @returns {number}
73
- */
74
- function countInlineMemberSandpackExamples(owner) {
75
- return (owner.children || [])
76
- .filter((child) => isSandpackThresholdMemberReflection(child))
77
- .reduce((count, member) => count + countReflectionSandpackExamples(member), 0);
78
- }
79
-
80
- /**
81
- * Check whether direct members should become focused pages for this owner.
82
- *
83
- * @param {import('typedoc').Reflection} owner
84
- * @returns {boolean}
85
- */
86
- function shouldRenderMemberPages(owner) {
87
- if (!MEMBER_PAGE_OWNER_KINDS.has(owner.kind)) {
88
- return false;
89
- }
90
-
91
- const inlineExampleCount = countReflectionSandpackExamples(owner) + countInlineMemberSandpackExamples(owner);
92
- return inlineExampleCount > MAX_INLINE_SANDPACK_EXAMPLES;
93
- }
94
-
95
- /**
96
- * @param {import('typedoc').Reflection | undefined} reflection
97
- * @returns {boolean}
98
- */
99
- function isDirectManagedMemberReflection(reflection) {
100
- return Boolean(
101
- reflection?.parent &&
102
- MEMBER_PAGE_OWNER_KINDS.has(reflection.parent.kind) &&
103
- MEMBER_PAGE_KINDS.has(reflection.kind)
104
- );
105
- }
106
-
107
- function shouldSuppressDefaultDirectMemberPagePolicy() {
108
- return MEMBER_PAGE_KINDS.has(ReflectionKind.Property) || MEMBER_PAGE_KINDS.has(ReflectionKind.Accessor);
109
- }
110
-
111
- function shouldRenderAllDirectMethodPages() {
112
- return MEMBER_PAGE_KINDS.size === 1 && MEMBER_PAGE_KINDS.has(ReflectionKind.Method);
113
- }
114
-
115
- /**
116
- * Check whether a reflection is a direct method or example-bearing property
117
- * that should become a focused page.
118
- *
119
- * @param {import('typedoc').Reflection | undefined} reflection
120
- * @returns {boolean}
121
- */
122
- export function isDirectMemberPageReflection(reflection) {
123
- if (
124
- shouldRenderAllDirectMethodPages() &&
125
- reflection?.parent &&
126
- MEMBER_PAGE_OWNER_KINDS.has(reflection.parent.kind) &&
127
- reflection.kind === ReflectionKind.Method
128
- ) {
129
- return true;
130
- }
131
-
132
- if (!isDirectManagedMemberReflection(reflection) || !shouldRenderMemberPages(reflection.parent)) {
133
- return false;
134
- }
135
-
136
- if (reflection.kind === ReflectionKind.Method) {
137
- return true;
138
- }
139
-
140
- return isSandpackThresholdMemberReflection(reflection);
141
- }
142
-
143
- /**
144
- * Preserve the markdown MemberRouter own-page policy while extending it to
145
- * direct methods and example-bearing properties when the owner page would
146
- * otherwise render too many Sandpack examples.
147
- *
148
- * @param {import('typedoc').Reflection} reflection
149
- * @param {OwnPagePolicyRouter} router
150
- * @returns {boolean}
151
- */
152
- export function shouldRenderOwnPage(reflection, router) {
153
- if (isDirectMemberPageReflection(reflection)) {
154
- return true;
155
- }
156
-
157
- if (shouldSuppressDefaultDirectMemberPagePolicy() && isDirectManagedMemberReflection(reflection)) {
158
- return false;
159
- }
160
-
161
- return [...ALWAYS_OWN_PAGE_KIND_NAMES, ...router.membersWithOwnFile].includes(
162
- router.kindsToString.get(reflection.kind)
163
- );
164
- }
@@ -1,44 +0,0 @@
1
- // @ts-check
2
-
3
- import { ReflectionKind } from 'typedoc';
4
-
5
- /**
6
- * Check whether a namespace is directly rooted in the TypeDoc project after
7
- * walking through any nested namespace ancestors.
8
- *
9
- * @param {import('typedoc').Reflection} reflection
10
- * @returns {boolean}
11
- */
12
- export function isProjectNamespace(reflection) {
13
- let ancestor = reflection.parent;
14
- while (ancestor && ancestor.kind === ReflectionKind.Namespace) {
15
- ancestor = ancestor.parent;
16
- }
17
- return ancestor?.kind === ReflectionKind.Project;
18
- }
19
-
20
- /**
21
- * Build the flattened project namespace path used by the textmode.js docs.
22
- *
23
- * @param {{
24
- * directories: Map<import('typedoc').ReflectionKind, string>;
25
- * getReflectionAlias(reflection: import('typedoc').Reflection): string;
26
- * }} router
27
- * @param {import('typedoc').Reflection} reflection
28
- * @returns {string}
29
- */
30
- export function buildNamespacePath(router, reflection) {
31
- const stack = [];
32
- let current = reflection;
33
- while (current && current.kind === ReflectionKind.Namespace) {
34
- stack.unshift(current);
35
- current = current.parent;
36
- }
37
-
38
- const segments = [];
39
- for (const namespace of stack) {
40
- segments.push(router.directories.get(ReflectionKind.Namespace), router.getReflectionAlias(namespace));
41
- }
42
-
43
- return segments.join('/');
44
- }
@@ -1,58 +0,0 @@
1
- // @ts-check
2
-
3
- import { PageKind } from 'typedoc';
4
- import { MemberRouter } from 'typedoc-plugin-markdown';
5
-
6
- import { buildMemberRouterChildPages } from './child-pages.js';
7
- import { getDirectMemberDirectory, getReflectionFileName as getMemberReflectionFileName } from './member-paths.js';
8
- import { isDirectMemberPageReflection } from './member-reflections.js';
9
- import { buildNamespacePath, isProjectNamespace } from './namespace-paths.js';
10
-
11
- export class AllMemberPagesRouter extends MemberRouter {
12
- /** @param {import('typedoc').Reflection} reflection */
13
- getPageKind(reflection) {
14
- if (isDirectMemberPageReflection(reflection)) {
15
- return PageKind.Reflection;
16
- }
17
-
18
- return super.getPageKind(reflection);
19
- }
20
-
21
- /**
22
- * This mirrors typedoc-plugin-markdown's MemberRouter child traversal while
23
- * delegating the "own page" policy to this plugin's helpers.
24
- *
25
- * @param {import('typedoc').Reflection} reflection
26
- * @param {import('typedoc').PageDefinition[]} outPages
27
- */
28
- buildChildPages(reflection, outPages) {
29
- buildMemberRouterChildPages(this, reflection, outPages);
30
- }
31
-
32
- /** @param {import('typedoc').Reflection} reflection */
33
- getNamespaceDirectory(reflection) {
34
- if (isProjectNamespace(reflection)) {
35
- return buildNamespacePath(this, reflection);
36
- }
37
-
38
- return super.getNamespaceDirectory(reflection);
39
- }
40
-
41
- /** @param {import('typedoc').Reflection} reflection */
42
- getReflectionDirectory(reflection) {
43
- if (isDirectMemberPageReflection(reflection)) {
44
- return getDirectMemberDirectory(this, reflection);
45
- }
46
-
47
- return super.getReflectionDirectory(reflection);
48
- }
49
-
50
- /** @param {import('typedoc').Reflection} reflection */
51
- getReflectionFileName(reflection) {
52
- if (isDirectMemberPageReflection(reflection)) {
53
- return getMemberReflectionFileName(this, reflection);
54
- }
55
-
56
- return super.getReflectionFileName(reflection);
57
- }
58
- }
@@ -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';