@textmode/docs 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,121 @@
1
+ Creative Commons Legal Code
2
+
3
+ CC0 1.0 Universal
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
package/README.md CHANGED
@@ -1,18 +1,26 @@
1
1
  # @textmode/docs
2
2
 
3
- Shared documentation generation and validation for public textmode.js
4
- libraries. The package owns the TypeDoc stack, Markdown plugins, public API
5
- checks, example validation, and API-link maintenance behind one command.
3
+ <div align="center">
6
4
 
7
- ## Ownership
5
+ <img alt="@textmode/docs — doc textmode with typedoc" src=".github/assets/readme-og.png" />
8
6
 
9
- - `package.json` owns the package name, description, and TypeScript dependency.
10
- - `textmode.docs.config.mjs` owns project-specific documentation policy.
11
- - `@textmode/docs` owns TypeDoc and its plugins, shared defaults, rendering,
12
- validation, link editing, and command behavior.
7
+ | [![JavaScript](https://img.shields.io/badge/JavaScript-F7DF1E?logo=javascript&logoColor=black)](https://developer.mozilla.org/en-US/docs/Web/JavaScript) [![TypeDoc](https://img.shields.io/badge/TypeDoc-3D9970)](https://typedoc.org/) | [![docs](https://img.shields.io/badge/docs-vitepress-646cff?logo=vitepress&logoColor=white)](https://code.textmode.art/) [![Discord](https://img.shields.io/discord/1357070706181017691?color=5865F2&label=Discord&logo=discord&logoColor=white)](https://discord.gg/sjrw8QXNks) | [![ko-fi](https://shields.io/badge/ko--fi-donate-ff5f5f?logo=ko-fi)](https://ko-fi.com/V7V8JG2FY) [![GitHub-sponsors](https://img.shields.io/badge/sponsor-30363D?logo=GitHub-Sponsors&logoColor=#EA4AAA)](https://github.com/sponsors/humanbydefinition) |
8
+ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
13
9
 
14
- Consumers should not define `package.json#typedocOptions`, maintain another
15
- tooling config, invoke TypeDoc directly, or import package internals.
10
+ </div>
11
+
12
+ `@textmode/docs` provides shared documentation generation and validation for public [`textmode.js`](https://github.com/humanbydefinition/textmode.js) libraries. The package owns the [TypeDoc](https://typedoc.org/) stack, Markdown plugins, public API checks, example validation, and API-link maintenance behind one command.
13
+
14
+ Use it to generate, validate, and maintain API documentation for every library without maintaining a per-repository TypeDoc setup.
15
+
16
+ ## Features
17
+
18
+ - **One-command documentation** - Generate, check, watch, and maintain API links through `textmode-docs`.
19
+ - **Shared TypeDoc stack** - TypeDoc plus plugins with registered defaults and project-owned policy via `textmode.docs.config.mjs`.
20
+ - **Public API validation** - Requires docstrings and examples on every public API reflection.
21
+ - **Example policy checks** - Gallery, manifest, and sketch checks with hardcoded source bases rejected.
22
+ - **API-link maintenance** - Idempotent JSDoc link insertion across configured source roots.
23
+ - **Strict by default** - Warnings become errors; exit codes distinguish success, validation failure, and invocation failure.
16
24
 
17
25
  ## Installation
18
26
 
@@ -20,7 +28,7 @@ tooling config, invoke TypeDoc directly, or import package internals.
20
28
  npm install --save-dev @textmode/docs typescript
21
29
  ```
22
30
 
23
- ## Configuration
31
+ ## Usage
24
32
 
25
33
  Conventional projects need no configuration file. Create
26
34
  `textmode.docs.config.mjs` at the project root only for policy that differs
@@ -76,12 +84,23 @@ without examples.
76
84
  The `typedoc` object can override registered TypeDoc options except
77
85
  `entryPoints`, `out`, `tsconfig`, `plugin`, `router`, `emit`, `watch`,
78
86
  `treatWarningsAsErrors`, `treatValidationWarningsAsErrors`, and options whose
79
- names begin with `textmode`.
87
+ names begin with `textmode`. TypeDoc options are configured here, not through
88
+ `package.json#typedocOptions`.
80
89
 
81
90
  `editLink: true` enables the "Edit this page on GitHub" link on generated
82
91
  API pages for the package. The default (`false`) omits the link because API
83
92
  reference is generated and should not be edited in place via the docs site.
84
93
 
94
+ ## Related packages
95
+
96
+ `@textmode/docs` works with the following textmode-tooling packages:
97
+
98
+ | Package | Relationship |
99
+ | --------------------------------------------- | ------------------------------------- |
100
+ | [`@textmode/tsconfig`](../tsconfig/README.md) | TypeDoc reads the consumer `tsconfig` |
101
+
102
+ ## Configuration
103
+
85
104
  ### Defaults
86
105
 
87
106
  | Setting | Default |
@@ -138,3 +157,27 @@ missing values, and extra positional arguments are rejected.
138
157
  Normal results are written to stdout and diagnostics to stderr. Exit status `0`
139
158
  means success, `1` means documentation or content validation failed, and `2`
140
159
  means invocation, configuration, dependency, input, or internal-tool failure.
160
+
161
+ ## License
162
+
163
+ The `@textmode/docs` package is licensed under the [CC0 1.0 Universal](./LICENSE).
164
+
165
+ ## Acknowledgements
166
+
167
+ - **[TypeDoc](https://typedoc.org/)**
168
+ - The documentation generator this package orchestrates.
169
+ - License: [Apache-2.0](https://github.com/TypeStrong/typedoc/blob/master/LICENSE).
170
+
171
+ - **[`typedoc-plugin-markdown`](https://typedoc-plugin-markdown.org/)**
172
+ - Markdown output and the frontmatter and VitePress theme plugins used for API pages.
173
+ - License: [MIT License](https://github.com/typedoc2md/typedoc-plugin-markdown/blob/main/LICENSE).
174
+
175
+ ### Preserve published page dates
176
+
177
+ After generating documentation and applying all publishing transformations, reconcile the final Markdown against the previous published pages:
178
+
179
+ ```sh
180
+ textmode-docs dates reconcile --baseline ./previous-api --target ./new-api
181
+ ```
182
+
183
+ The command preserves `lastModified` when a page is unchanged, ignoring the date field itself. It assigns the current UTC date to changed pages, new pages, and unchanged pages without a previous date. Deleted pages are ignored. `--date YYYY-MM-DD` can supply a date for reproducible builds. Keep the baseline outside the target directory: TypeDoc cleans its output during generation.
package/package.json CHANGED
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "name": "@textmode/docs",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
+ "type": "module",
5
+ "license": "CC0-1.0",
4
6
  "description": "Shared documentation generation and validation for the textmode.js ecosystem",
5
7
  "keywords": [
6
8
  "textmode",
@@ -9,14 +11,12 @@
9
11
  "validation"
10
12
  ],
11
13
  "author": "humanbydefinition <hello@textmode.art> (https://code.textmode.art)",
12
- "license": "MIT",
13
14
  "homepage": "https://code.textmode.art",
14
15
  "repository": {
15
16
  "type": "git",
16
- "url": "git+https://github.com/humanbydefinition/textmode-tooling.git",
17
+ "url": "git+https://github.com/textmode-art/tooling.git",
17
18
  "directory": "packages/docs"
18
19
  },
19
- "type": "module",
20
20
  "engines": {
21
21
  "node": ">=24 <25"
22
22
  },
@@ -36,9 +36,9 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "typedoc": "^0.28.20",
39
- "typedoc-plugin-frontmatter": "^1.3.1",
39
+ "typedoc-plugin-frontmatter": "^1.3.3",
40
40
  "typedoc-plugin-markdown": "^4.12.0",
41
- "typedoc-vitepress-theme": "^1.1.3"
41
+ "typedoc-vitepress-theme": "^1.1.4"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "typescript": ">=5.9 <7"
@@ -4,6 +4,7 @@ import fs from 'node:fs';
4
4
  import process from 'node:process';
5
5
  import { parseArgs } from 'node:util';
6
6
 
7
+ import { reconcileDates } from '../internal/reconcile-dates.js';
7
8
  import { formatResolvedConfig, resolveDocsConfig } from '../internal/config.js';
8
9
  import {
9
10
  addApiLinks,
@@ -25,6 +26,7 @@ function printGeneralHelp() {
25
26
  console.log(' check Validate generated docs, public API docs, and examples');
26
27
  console.log(' build [--out <directory>] Generate documentation');
27
28
  console.log(' watch [--out <directory>] Generate documentation and watch for changes');
29
+ console.log(' dates reconcile --baseline <directory> --target <directory> [--date YYYY-MM-DD]');
28
30
  console.log(' links add Insert or update public API links in source JSDoc');
29
31
  console.log(' api-check [--include-accessors]');
30
32
  console.log(' Run the focused public API documentation check');
@@ -123,6 +125,25 @@ function commandDetails(command) {
123
125
  }
124
126
 
125
127
  async function run(argv) {
128
+ if (argv[0] === 'dates' && argv[1] === 'reconcile') {
129
+ try {
130
+ const { values, positionals } = parseArgs({
131
+ args: argv.slice(2),
132
+ strict: true,
133
+ options: { baseline: { type: 'string' }, target: { type: 'string' }, date: { type: 'string' } },
134
+ });
135
+ if (positionals.length || !values.baseline || !values.target)
136
+ throw new Error(
137
+ 'Usage: textmode-docs dates reconcile --baseline <directory> --target <directory> [--date YYYY-MM-DD]'
138
+ );
139
+ const count = await reconcileDates(values);
140
+ console.log(`Reconciled dates for ${count} pages.`);
141
+ } catch (error) {
142
+ console.error(error instanceof Error ? error.message : String(error));
143
+ process.exitCode = 1;
144
+ }
145
+ return;
146
+ }
126
147
  let cli;
127
148
  try {
128
149
  cli = parseCli(argv);
@@ -53,25 +53,28 @@ function exampleScopeLabel(targetKinds) {
53
53
  : 'exported functions and methods';
54
54
  }
55
55
 
56
- async function loadPrimaryCheckProject(config) {
57
- const primaryEntryPoint = config.linkEntryPoints[0] ?? {
58
- path: config.entryPoints[0],
59
- tsconfig: config.tsconfig,
60
- };
61
- return loadEntryPointProject({
62
- entryPoint: primaryEntryPoint.path,
63
- tsconfig: primaryEntryPoint.tsconfig,
64
- packageName: config.packageName,
65
- projectRoot: config.projectRoot,
66
- });
56
+ async function loadCheckProjects(config) {
57
+ const entryPoints = config.linkEntryPoints.length
58
+ ? config.linkEntryPoints
59
+ : [{ path: config.entryPoints[0], tsconfig: config.tsconfig }];
60
+ return Promise.all(
61
+ entryPoints.map((entryPoint) =>
62
+ loadEntryPointProject({
63
+ entryPoint: entryPoint.path,
64
+ tsconfig: entryPoint.tsconfig,
65
+ packageName: config.packageName,
66
+ projectRoot: config.projectRoot,
67
+ })
68
+ )
69
+ );
67
70
  }
68
71
 
69
72
  export async function apiCheck(config, routes, { includeAccessors = false } = {}) {
70
- const project = await loadPrimaryCheckProject(config);
73
+ const projects = await loadCheckProjects(config);
71
74
  const kinds = checkKinds(config, includeAccessors);
72
- const apiLinkReflections = getIncludedReflections(project, kinds.apiLinks);
73
- const docstringReflections = getIncludedReflections(project, kinds.docstrings);
74
- const exampleReflections = getIncludedReflections(project, kinds.examples);
75
+ const apiLinkReflections = projects.flatMap((project) => getIncludedReflections(project, kinds.apiLinks));
76
+ const docstringReflections = projects.flatMap((project) => getIncludedReflections(project, kinds.docstrings));
77
+ const exampleReflections = projects.flatMap((project) => getIncludedReflections(project, kinds.examples));
75
78
  const issues = collectApiDocIssues({
76
79
  apiBaseUrl: config.apiBaseUrl,
77
80
  apiLinkReflections,
@@ -80,12 +83,15 @@ export async function apiCheck(config, routes, { includeAccessors = false } = {}
80
83
  routes,
81
84
  });
82
85
  const issueCount = countApiDocIssues(issues);
83
- const entryPoint = path.relative(config.projectRoot, config.linkEntryPoints[0].path);
86
+ const entryPoints = config.linkEntryPoints.map((entryPoint) => path.relative(config.projectRoot, entryPoint.path));
87
+ const entryPointLabel = entryPoints.join(', ');
84
88
  const scopeLabel = exampleScopeLabel(kinds.examples);
85
89
 
86
90
  if (issueCount === 0) {
87
91
  console.log('Public API documentation check passed.');
88
- console.log(`Scanned ${docstringReflections.length} documented public API reflections from ${entryPoint}.`);
92
+ console.log(
93
+ `Scanned ${docstringReflections.length} documented public API reflections from ${entryPointLabel}.`
94
+ );
89
95
  console.log('Policy: skip private/protected/inherited members and any API path segment starting with "_".');
90
96
  console.log('Every included API item has a JSDoc docstring and a valid code.textmode.art API link.');
91
97
  console.log(`Every included ${scopeLabel} has at least one @example tag.`);
@@ -96,7 +102,7 @@ export async function apiCheck(config, routes, { includeAccessors = false } = {}
96
102
  }
97
103
 
98
104
  console.error('Public API documentation check failed.');
99
- console.error(`Scanned ${docstringReflections.length} documented public API reflections from ${entryPoint}.`);
105
+ console.error(`Scanned ${docstringReflections.length} documented public API reflections from ${entryPointLabel}.`);
100
106
  console.error('Policy: skip private/protected/inherited members and any API path segment starting with "_".');
101
107
  console.error(
102
108
  `Found ${issueCount} issue(s): ${issues.missingDocstrings.length} missing docstring, ${issues.missingExamples.length} missing @example, ${issues.missingApiLinks.length} missing API link, ${issues.invalidApiLinks.length} invalid API link.`
@@ -0,0 +1,71 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+
4
+ // Work on the YAML block as text so other fields and the page body stay byte-for-byte intact.
5
+ function splitDate(markdown) {
6
+ const match = /^(---\r?\n)([\s\S]*?)(^---[ \t]*\r?\n|^---[ \t]*$)/m.exec(markdown);
7
+ if (!match || match.index !== 0) throw new Error('Markdown page is missing YAML frontmatter.');
8
+ let date;
9
+ const fields = match[2].replace(/^lastModified:[ \t]*([^\r\n]*)\r?\n/gm, (_, value) => {
10
+ if (date !== undefined) throw new Error('Duplicate lastModified field.');
11
+ date = value.trim().replace(/^['"]|['"]$/g, '');
12
+ return '';
13
+ });
14
+ return { date, content: match[1] + fields + match[3] + markdown.slice(match[0].length) };
15
+ }
16
+
17
+ async function markdownFiles(directory, prefix = '') {
18
+ const entries = await fs.readdir(path.join(directory, prefix), { withFileTypes: true });
19
+ const files = [];
20
+ for (const entry of entries) {
21
+ const relative = path.join(prefix, entry.name);
22
+ if (entry.isDirectory()) files.push(...(await markdownFiles(directory, relative)));
23
+ else if (entry.isFile() && entry.name.endsWith('.md')) files.push(relative);
24
+ }
25
+ return files.sort();
26
+ }
27
+
28
+ export async function reconcileDates({ baseline, target, date = new Date().toISOString().slice(0, 10) }) {
29
+ baseline = path.resolve(baseline);
30
+ target = path.resolve(target);
31
+ if (baseline === target || baseline.startsWith(target + path.sep) || target.startsWith(baseline + path.sep)) {
32
+ throw new Error('Baseline and target must be separate directories.');
33
+ }
34
+ const timestamp = Date.parse(`${date}T00:00:00Z`);
35
+ if (
36
+ !/^\d{4}-\d{2}-\d{2}$/.test(date) ||
37
+ Number.isNaN(timestamp) ||
38
+ new Date(timestamp).toISOString().slice(0, 10) !== date
39
+ ) {
40
+ throw new Error('Date must be in YYYY-MM-DD format.');
41
+ }
42
+ await fs.access(baseline);
43
+ const files = await markdownFiles(target);
44
+ for (const file of files) {
45
+ const targetPath = path.join(target, file);
46
+ const current = splitDate(await fs.readFile(targetPath, 'utf8'));
47
+ let previous;
48
+ try {
49
+ previous = splitDate(await fs.readFile(path.join(baseline, file), 'utf8'));
50
+ } catch (error) {
51
+ if (error.code !== 'ENOENT') throw error;
52
+ }
53
+ const lastModified = previous && previous.content === current.content && previous.date ? previous.date : date;
54
+ const output = current.content.replace(
55
+ /^(---\r?\n)([\s\S]*?)(^---[ \t]*\r?\n|^---[ \t]*$)/m,
56
+ (_, opening, fields, closing) => {
57
+ const marker = /^(?:hasConstructor|isInterface):/m.exec(fields);
58
+ const position = marker ? marker.index : fields.length;
59
+ return (
60
+ opening +
61
+ fields.slice(0, position) +
62
+ `lastModified: ${lastModified}\n` +
63
+ fields.slice(position) +
64
+ closing
65
+ );
66
+ }
67
+ );
68
+ await fs.writeFile(targetPath, output);
69
+ }
70
+ return files.length;
71
+ }
@@ -32,7 +32,7 @@ Descriptions come from the first useful TypeDoc comment summary on the reflectio
32
32
  setter signature. The summary is reduced to the first paragraph, sanitized for YAML frontmatter, and truncated to a
33
33
  short SEO-friendly length. If no summary exists, the plugin generates a kind-specific fallback description.
34
34
 
35
- `lastModified` intentionally uses the docs build date to preserve the existing generated output contract.
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
36
 
37
37
  Packages whose names start with `textmode` are assigned to the `textmode.js` ecosystem. Other package names use their
38
38
  own name as the ecosystem.
@@ -45,13 +45,13 @@ own name as the ecosystem.
45
45
  templates.
46
46
  - Descriptions use the first paragraph, strip markdown links/raw URLs/backticks, collapse whitespace, and truncate to
47
47
  160 characters.
48
- - `lastModified` remains the docs build date.
48
+ - `lastModified` remains the supplied source date when present, and is omitted otherwise.
49
49
 
50
50
  ## Contributor Notes
51
51
 
52
52
  - Safe to edit: constants, helper names, fallback tests, and README wording.
53
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 build-date output.
54
+ - Do not casually change: frontmatter key names, merge precedence, textmode ecosystem detection, or source-date semantics.
55
55
 
56
56
  ## Maintenance
57
57
 
@@ -49,7 +49,8 @@ export function buildApiFrontmatter(model, existingFrontmatter, library) {
49
49
  namespace: isInNamespace(model) ? getNamespacePath(model) : undefined,
50
50
  kind: ReflectionKind[kind],
51
51
  ecosystem: library.ecosystem !== library.name ? library.ecosystem : undefined,
52
- lastModified: new Date().toISOString().split('T')[0],
52
+ // A regeneration is not a content edit. Preserve an explicitly supplied date.
53
+ lastModified: existingFrontmatter.lastModified,
53
54
  hasConstructor: getHasConstructor(model),
54
55
  isInterface: getIsInterface(model),
55
56
  });