@mandolin/jsdoc-plugin-hia-sys 0.1.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.
- package/CHANGELOG.md +36 -0
- package/LICENSE +21 -0
- package/README.md +222 -0
- package/RELEASE_CHECKLIST.md +41 -0
- package/THIRD_PARTY_NOTICES.md +23 -0
- package/examples/basic/README.md +22 -0
- package/examples/basic/i18n/docs.hia-i18n.json +12 -0
- package/examples/basic/jsdoc.conf.json +42 -0
- package/examples/basic/src/greet.js +26 -0
- package/examples/basic/src/shared.js +20 -0
- package/package.json +61 -0
- package/src/config/defaults.cjs +114 -0
- package/src/index.cjs +37 -0
- package/src/micro-plugins/code-fragment.cjs +374 -0
- package/src/micro-plugins/diagnostics.cjs +18 -0
- package/src/micro-plugins/doc-i18n.cjs +796 -0
- package/src/micro-plugins/doclet-normalizer.cjs +23 -0
- package/src/micro-plugins/hia-ir-exporter.cjs +68 -0
- package/src/micro-plugins/index.cjs +23 -0
- package/src/micro-plugins/source-link.cjs +19 -0
- package/src/micro-plugins/source-preview.cjs +18 -0
- package/src/runtime/create-plugin-system.cjs +120 -0
- package/src/runtime/diagnostics.cjs +45 -0
- package/src/runtime/i18n.cjs +221 -0
- package/src/runtime/metadata.cjs +52 -0
- package/src/runtime/output-contract.cjs +416 -0
- package/src/runtime/source.cjs +547 -0
- package/src/version.cjs +5 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Field-level text i18n metadata at `doclet.hia.i18n.fields`.
|
|
8
|
+
- `@lang` doclet description blocks and XML-like `<lang>` inline segments.
|
|
9
|
+
- Source metadata at `doclet.hia.source.definedIn` and `doclet.hia.source.primaryBlock`.
|
|
10
|
+
- Source metadata contract fields for `kind`, `referenceKind`, `model` and `modelVersion`.
|
|
11
|
+
- JavaScript declaration range parser for `doclet.hia.source.primaryBlock`, with heuristic fallback.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- `@hiaText` and `@hiaBlock` now act as compatibility inputs for the newer text i18n pipeline.
|
|
16
|
+
- `@coderef` output is modeled as extra source references rather than the only source metadata entry point.
|
|
17
|
+
- The default source preview range strategy is now `parser-js`.
|
|
18
|
+
- Release metadata now declares public scoped publishing and records the publish strategy/checklist.
|
|
19
|
+
- HIA Integration output now omits empty synthetic doclets, normalizes source link open modes and emits relative localization resource records.
|
|
20
|
+
|
|
21
|
+
## 0.1.0 - 2026-07-05
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- JSDoc plugin entry with internal micro-plugin runner.
|
|
26
|
+
- `@codeblock`, `@codeblockend` and `@coderef` source fragment flow.
|
|
27
|
+
- Source link and source preview metadata.
|
|
28
|
+
- `doc-i18n` metadata with inline text, external resources, fallback and generation modes.
|
|
29
|
+
- Standalone output contract for `jsdoc-theme-hia`.
|
|
30
|
+
- HIA Integration output contract and optional JSON file output.
|
|
31
|
+
- Diagnostics collection and fixture coverage.
|
|
32
|
+
|
|
33
|
+
### Notes
|
|
34
|
+
|
|
35
|
+
- This is an early public package for standalone JSDoc usage and HIA metadata experiments.
|
|
36
|
+
- Public API stability is not guaranteed yet.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 HIA
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# @mandolin/jsdoc-plugin-hia-sys
|
|
2
|
+
|
|
3
|
+
HIA metadata plugin for JSDoc.
|
|
4
|
+
|
|
5
|
+
`@mandolin/jsdoc-plugin-hia-sys` extends JSDoc with structured metadata for source references, source previews, multilingual documentation and optional HIA integration output. It can be used as a standalone JSDoc plugin in ordinary JavaScript projects, or as a JSDoc adapter in a larger HIA documentation pipeline.
|
|
6
|
+
|
|
7
|
+
GitHub: <https://github.com/mandolin/jsdoc-plugin-hia-sys>
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- Adds `doclet.hia` metadata to JSDoc doclets.
|
|
12
|
+
- Supports source fragment markers with `@codeblock`, `@codeblockend` and `@coderef`.
|
|
13
|
+
- Generates `definedIn`, `primaryBlock`, source link and source preview metadata for themes.
|
|
14
|
+
- Supports `@lang`, XML-like `<lang>` inline segments and resource-backed multilingual documentation metadata.
|
|
15
|
+
- Provides a small internal micro-plugin pipeline for feature composition.
|
|
16
|
+
- Can write an HIA Integration JSON file for downstream tooling.
|
|
17
|
+
- Includes diagnostics for missing fragments, missing translations and related metadata issues.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install --save-dev jsdoc @mandolin/jsdoc-plugin-hia-sys
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
For projects that also need the companion HTML theme:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install --save-dev jsdoc @mandolin/jsdoc-plugin-hia-sys @mandolin/jsdoc-theme-hia
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Basic Usage
|
|
32
|
+
|
|
33
|
+
Add the plugin to your JSDoc configuration:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"plugins": ["node_modules/@mandolin/jsdoc-plugin-hia-sys/src/index.cjs"],
|
|
38
|
+
"source": {
|
|
39
|
+
"include": ["src"]
|
|
40
|
+
},
|
|
41
|
+
"opts": {
|
|
42
|
+
"destination": "docs/api",
|
|
43
|
+
"recurse": true,
|
|
44
|
+
"hia": {
|
|
45
|
+
"mode": "standalone"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Configuration can be placed under `opts.hia`, `hia`, `opts["jsdoc-plugin-hia-sys"]`, `opts["@mandolin/jsdoc-plugin-hia-sys"]`, `jsdoc-plugin-hia-sys` or `@mandolin/jsdoc-plugin-hia-sys`.
|
|
52
|
+
|
|
53
|
+
## Source Metadata
|
|
54
|
+
|
|
55
|
+
Each doclet receives source metadata when JSDoc provides file and line information:
|
|
56
|
+
|
|
57
|
+
- `doclet.hia.source.definedIn`: relative path, line, language and source link metadata.
|
|
58
|
+
- `doclet.hia.source.primaryBlock`: a source preview block for the doclet itself. The default range strategy uses a JavaScript declaration parser with heuristic fallback.
|
|
59
|
+
- `doclet.hia.source.references`: extra source fragments referenced with `@coderef`.
|
|
60
|
+
|
|
61
|
+
Enable source links and previews in JSDoc configuration:
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"opts": {
|
|
66
|
+
"hia": {
|
|
67
|
+
"source": {
|
|
68
|
+
"basePath": ".",
|
|
69
|
+
"mode": "all",
|
|
70
|
+
"link": {
|
|
71
|
+
"enabled": true,
|
|
72
|
+
"rootUrl": "https://github.com/example/project/blob/main",
|
|
73
|
+
"openMode": "new-tab"
|
|
74
|
+
},
|
|
75
|
+
"preview": {
|
|
76
|
+
"enabled": true,
|
|
77
|
+
"defaultExpanded": false,
|
|
78
|
+
"rangeStrategy": "parser-js"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Source References
|
|
87
|
+
|
|
88
|
+
Mark reusable source fragments in code:
|
|
89
|
+
|
|
90
|
+
```js
|
|
91
|
+
function greet(name) {
|
|
92
|
+
/* @codeblock GREET_BODY */
|
|
93
|
+
const message = `Hello, ${name}`;
|
|
94
|
+
return message;
|
|
95
|
+
/* @codeblockend GREET_BODY */
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Reference the fragment from a JSDoc comment:
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
/**
|
|
103
|
+
* Greets a user.
|
|
104
|
+
*
|
|
105
|
+
* @example <caption>Basic greeting</caption>
|
|
106
|
+
* @coderef GREET_BODY
|
|
107
|
+
*/
|
|
108
|
+
function greet(name) {}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The plugin writes reference data to `doclet.hia.source.references`, including source link and preview metadata when enabled.
|
|
112
|
+
|
|
113
|
+
## Multilingual Metadata
|
|
114
|
+
|
|
115
|
+
Use `@lang` for localized doclet descriptions:
|
|
116
|
+
|
|
117
|
+
```js
|
|
118
|
+
/**
|
|
119
|
+
* @hiaKey user.greet
|
|
120
|
+
* @hiaPath api.user.greet
|
|
121
|
+
* @lang zh-CN 问候一个用户。
|
|
122
|
+
* @lang en Greets a user.
|
|
123
|
+
*/
|
|
124
|
+
function greet(name) {}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Use `<lang>` inside any description text field:
|
|
128
|
+
|
|
129
|
+
```js
|
|
130
|
+
/**
|
|
131
|
+
* Greets a <lang key="greet.target"><zh-CN>用户</zh-CN><en>user</en></lang>.
|
|
132
|
+
*
|
|
133
|
+
* @param {string} name User <lang key="greet.param.name"><zh-CN>名称</zh-CN><en>name</en></lang>.
|
|
134
|
+
*/
|
|
135
|
+
function greet(name) {}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
The plugin writes field-level data to `doclet.hia.i18n.fields`. For compatibility, it also keeps the older `doclet.hia.i18n.localized` and generation fields. `@hiaText` and `@hiaBlock` are still accepted as compatibility inputs.
|
|
139
|
+
|
|
140
|
+
External resource files are also supported:
|
|
141
|
+
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"opts": {
|
|
145
|
+
"hia": {
|
|
146
|
+
"i18n": {
|
|
147
|
+
"enabled": true,
|
|
148
|
+
"defaultLocale": "zh-CN",
|
|
149
|
+
"fallbackLocale": "en",
|
|
150
|
+
"locales": ["zh-CN", "en"],
|
|
151
|
+
"mode": "runtimeSwitch",
|
|
152
|
+
"resources": ["docs/i18n/docs.hia-i18n.json"]
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Resource files can be grouped by locale:
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"zh-CN": {
|
|
164
|
+
"user.greet": {
|
|
165
|
+
"text": "问候一个用户。"
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
"en": {
|
|
169
|
+
"user.greet": {
|
|
170
|
+
"text": "Greets a user."
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## HIA Integration Output
|
|
177
|
+
|
|
178
|
+
Standalone mode enriches JSDoc doclets for themes and local tooling. HIA Integration mode additionally writes a JSON artifact for downstream processing:
|
|
179
|
+
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"opts": {
|
|
183
|
+
"hia": {
|
|
184
|
+
"mode": "hiaIntegration",
|
|
185
|
+
"integration": {
|
|
186
|
+
"enabled": true,
|
|
187
|
+
"outputFile": "docs/api/hia-integration.json"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
The integration artifact currently contains IR nodes, source fragments, localization resources, diagnostics and a doclet-to-node map.
|
|
195
|
+
|
|
196
|
+
Current integration output keeps user-facing doclets only, omitting empty JSDoc synthetic nodes created by module/export inference. Source links use `same-tab` or `new-tab`; legacy `currentPage` input is normalized when metadata is produced. Resource records use relative `external-resource` entries, and generated integration JSON does not expose local `filePath` values.
|
|
197
|
+
|
|
198
|
+
## Scripts
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
npm run check:syntax
|
|
202
|
+
npm test
|
|
203
|
+
npm run test:jsdoc
|
|
204
|
+
npm run release:check
|
|
205
|
+
npm run test:all
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
`npm test` runs fixture coverage for the plugin pipeline and metadata output. `npm run test:jsdoc` loads the plugin through real JSDoc. `npm run release:check` validates package metadata and required release files.
|
|
209
|
+
|
|
210
|
+
## Compatibility
|
|
211
|
+
|
|
212
|
+
- Node.js 18 or newer.
|
|
213
|
+
- JSDoc 4.x.
|
|
214
|
+
- CommonJS runtime.
|
|
215
|
+
|
|
216
|
+
## Stability
|
|
217
|
+
|
|
218
|
+
Version `0.1.0` is an early public package. The Standalone metadata shape is intended for experimentation and companion-theme use. The HIA Integration IR is still a draft contract and may change before a stable release.
|
|
219
|
+
|
|
220
|
+
## License
|
|
221
|
+
|
|
222
|
+
MIT
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Release Checklist
|
|
2
|
+
|
|
3
|
+
## Scope
|
|
4
|
+
|
|
5
|
+
Package: `@mandolin/jsdoc-plugin-hia-sys`
|
|
6
|
+
|
|
7
|
+
Version: `0.1.0`
|
|
8
|
+
|
|
9
|
+
## Required Checks
|
|
10
|
+
|
|
11
|
+
- [ ] `npm run check:syntax`
|
|
12
|
+
- [ ] `npm test`
|
|
13
|
+
- [ ] `npm run test:jsdoc`
|
|
14
|
+
- [ ] `npm run clean:examples`
|
|
15
|
+
- [ ] `npm run release:check`
|
|
16
|
+
- [ ] `npm run test:all`
|
|
17
|
+
- [ ] `npm pack --dry-run --json`
|
|
18
|
+
|
|
19
|
+
## Manual Review
|
|
20
|
+
|
|
21
|
+
- [ ] README describes Standalone and HIA Integration use.
|
|
22
|
+
- [ ] `examples/basic/README.md` explains the example.
|
|
23
|
+
- [ ] `src/runtime/output-contract.cjs` matches current output shape.
|
|
24
|
+
- [ ] `THIRD_PARTY_NOTICES.md` is current.
|
|
25
|
+
- [ ] `CHANGELOG.md` has the target version.
|
|
26
|
+
- [ ] `package.json` keeps `publishConfig.access` as `public`.
|
|
27
|
+
- [ ] Dry-run artifact contents are limited to package sources, examples and release docs.
|
|
28
|
+
- [ ] `examples/basic/out` is not present.
|
|
29
|
+
- [ ] No `.tgz` dry-run tarball remains.
|
|
30
|
+
|
|
31
|
+
## Publish Strategy
|
|
32
|
+
|
|
33
|
+
- Keep version `0.1.0` for the first public package unless registry preflight shows it is already published.
|
|
34
|
+
- Use `npm publish --access public` for the scoped package.
|
|
35
|
+
- If publishing before W-P3.5 HIA Integration hardening, publish with `--tag next` and avoid promoting to `latest` until the integration producer contract is confirmed.
|
|
36
|
+
|
|
37
|
+
## Current Boundaries
|
|
38
|
+
|
|
39
|
+
- API stability is not final.
|
|
40
|
+
- The HIA Integration IR is a draft contract, not final core schema.
|
|
41
|
+
- This package supports JSDoc 4.x in the current cycle.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Third Party Notices
|
|
2
|
+
|
|
3
|
+
## Runtime Dependencies
|
|
4
|
+
|
|
5
|
+
This package has no bundled runtime dependency besides Node.js built-ins.
|
|
6
|
+
|
|
7
|
+
## Peer Dependencies
|
|
8
|
+
|
|
9
|
+
- `jsdoc` `^4.0.0` (`Apache-2.0`)
|
|
10
|
+
|
|
11
|
+
`jsdoc` is expected to be installed by the consuming project or used through this package's development environment.
|
|
12
|
+
|
|
13
|
+
## Development Dependencies
|
|
14
|
+
|
|
15
|
+
- `jsdoc` `^4.0.5` (`Apache-2.0`)
|
|
16
|
+
|
|
17
|
+
## Assets
|
|
18
|
+
|
|
19
|
+
No third-party visual assets, fonts, images, or copied theme code are bundled.
|
|
20
|
+
|
|
21
|
+
## Legacy Material
|
|
22
|
+
|
|
23
|
+
Older `jsdoc-plugin-hia` ideas were used as design reference only. This package is a new implementation and does not copy source files from the old repository.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Basic Example
|
|
2
|
+
|
|
3
|
+
This example shows the core plugin features:
|
|
4
|
+
|
|
5
|
+
- JSDoc plugin loading.
|
|
6
|
+
- `@codeblock`, `@codeblockend` and `@coderef`.
|
|
7
|
+
- Source `definedIn`, `primaryBlock`, link and preview metadata.
|
|
8
|
+
- `@lang`, `<lang>` inline segments and resource-backed `doc-i18n`.
|
|
9
|
+
- HIA Integration JSON output.
|
|
10
|
+
|
|
11
|
+
Run:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm run test:jsdoc
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Expected generated files under `examples/basic/out`:
|
|
18
|
+
|
|
19
|
+
- Standard JSDoc output files.
|
|
20
|
+
- `hia-integration.json` from `opts.hia.integration.outputFile`.
|
|
21
|
+
|
|
22
|
+
Generated files are test artifacts and should not be committed.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"plugins": ["./src/index.cjs"],
|
|
3
|
+
"source": {
|
|
4
|
+
"include": ["examples/basic/src"]
|
|
5
|
+
},
|
|
6
|
+
"opts": {
|
|
7
|
+
"destination": "examples/basic/out",
|
|
8
|
+
"recurse": true,
|
|
9
|
+
"hia": {
|
|
10
|
+
"mode": "standalone",
|
|
11
|
+
"source": {
|
|
12
|
+
"mode": "all",
|
|
13
|
+
"link": {
|
|
14
|
+
"enabled": true,
|
|
15
|
+
"rootUrl": "https://example.test/repo",
|
|
16
|
+
"openMode": "same-tab"
|
|
17
|
+
},
|
|
18
|
+
"preview": {
|
|
19
|
+
"enabled": true,
|
|
20
|
+
"defaultExpanded": false
|
|
21
|
+
},
|
|
22
|
+
"references": {
|
|
23
|
+
"enabled": true,
|
|
24
|
+
"defaultExpanded": false
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"i18n": {
|
|
28
|
+
"enabled": true,
|
|
29
|
+
"defaultLocale": "zh-CN",
|
|
30
|
+
"fallbackLocale": "en",
|
|
31
|
+
"locales": ["zh-CN", "en"],
|
|
32
|
+
"mode": "runtimeSwitch",
|
|
33
|
+
"resourceBasePath": ".",
|
|
34
|
+
"resources": ["examples/basic/i18n/docs.hia-i18n.json"]
|
|
35
|
+
},
|
|
36
|
+
"integration": {
|
|
37
|
+
"enabled": true,
|
|
38
|
+
"outputFile": "examples/basic/out/hia-integration.json"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Greets a <lang key="greet.target"><zh-CN>用户</zh-CN><en>user</en></lang>.
|
|
5
|
+
*
|
|
6
|
+
* @function greet
|
|
7
|
+
* @example
|
|
8
|
+
* // @coderef GREET_BODY
|
|
9
|
+
* @param {string} name User <lang key="greet.param.name"><zh-CN>名称</zh-CN><en>name</en></lang>.
|
|
10
|
+
* @returns {string} Greeting <lang key="greet.return.text"><zh-CN>文本</zh-CN><en>text</en></lang>.
|
|
11
|
+
* @coderef GREET_BODY
|
|
12
|
+
* @hiaKey greet.description
|
|
13
|
+
* @hiaPath api.greet
|
|
14
|
+
* @lang zh-CN 问候一个用户。
|
|
15
|
+
* @lang en Greets a user.
|
|
16
|
+
*/
|
|
17
|
+
function greet(name) {
|
|
18
|
+
/* @codeblock GREET_BODY */
|
|
19
|
+
const message = `Hello, ${name}`;
|
|
20
|
+
return message;
|
|
21
|
+
/* @codeblockend GREET_BODY */
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = {
|
|
25
|
+
greet
|
|
26
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared helper.
|
|
5
|
+
*
|
|
6
|
+
* @function normalizeName
|
|
7
|
+
* @param {string} name User name.
|
|
8
|
+
* @returns {string} Normalized name.
|
|
9
|
+
* @hiaKey shared.helper
|
|
10
|
+
* @hiaPath api.shared
|
|
11
|
+
*/
|
|
12
|
+
/* @codeblock SHARED_HELPER */
|
|
13
|
+
function normalizeName(name) {
|
|
14
|
+
return String(name).trim();
|
|
15
|
+
}
|
|
16
|
+
/* @codeblockend SHARED_HELPER */
|
|
17
|
+
|
|
18
|
+
module.exports = {
|
|
19
|
+
normalizeName
|
|
20
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mandolin/jsdoc-plugin-hia-sys",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "HIA JSDoc integration system with internal micro-plugin support.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/mandolin/jsdoc-plugin-hia-sys.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/mandolin/jsdoc-plugin-hia-sys/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/mandolin/jsdoc-plugin-hia-sys#readme",
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"main": "src/index.cjs",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": "./src/index.cjs"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"src",
|
|
24
|
+
"examples/basic/jsdoc.conf.json",
|
|
25
|
+
"examples/basic/README.md",
|
|
26
|
+
"examples/basic/i18n",
|
|
27
|
+
"examples/basic/src",
|
|
28
|
+
"README.md",
|
|
29
|
+
"CHANGELOG.md",
|
|
30
|
+
"RELEASE_CHECKLIST.md",
|
|
31
|
+
"THIRD_PARTY_NOTICES.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"check:syntax": "node --check src/index.cjs && node --check src/config/defaults.cjs && node --check src/runtime/create-plugin-system.cjs && node --check src/runtime/diagnostics.cjs && node --check src/runtime/i18n.cjs && node --check src/runtime/metadata.cjs && node --check src/runtime/output-contract.cjs && node --check src/runtime/source.cjs && node --check src/micro-plugins/code-fragment.cjs && node --check src/micro-plugins/diagnostics.cjs && node --check src/micro-plugins/doc-i18n.cjs && node --check src/micro-plugins/doclet-normalizer.cjs && node --check src/micro-plugins/hia-ir-exporter.cjs && node --check src/micro-plugins/index.cjs && node --check src/micro-plugins/source-link.cjs && node --check src/micro-plugins/source-preview.cjs && node --check test/run-fixtures.cjs && node --check scripts/clean-generated.cjs && node --check scripts/release-check.cjs",
|
|
36
|
+
"clean:examples": "node scripts/clean-generated.cjs",
|
|
37
|
+
"release:check": "node scripts/release-check.cjs && npm pack --dry-run",
|
|
38
|
+
"test": "node test/run-fixtures.cjs",
|
|
39
|
+
"test:fixtures": "node test/run-fixtures.cjs",
|
|
40
|
+
"test:jsdoc": "jsdoc -c examples/basic/jsdoc.conf.json",
|
|
41
|
+
"test:all": "npm run check:syntax && npm test && npm run test:jsdoc && npm run clean:examples && npm run release:check"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"jsdoc",
|
|
45
|
+
"jsdoc-plugin",
|
|
46
|
+
"hia",
|
|
47
|
+
"documentation",
|
|
48
|
+
"source-preview",
|
|
49
|
+
"i18n",
|
|
50
|
+
"plugin"
|
|
51
|
+
],
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"jsdoc": "^4.0.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"jsdoc": "^4.0.5"
|
|
57
|
+
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=18"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const DEFAULT_CONFIG = Object.freeze({
|
|
4
|
+
mode: "standalone",
|
|
5
|
+
metadataKey: "hia",
|
|
6
|
+
microPlugins: [
|
|
7
|
+
"code-fragment",
|
|
8
|
+
"source-link",
|
|
9
|
+
"source-preview",
|
|
10
|
+
"doc-i18n",
|
|
11
|
+
"doclet-normalizer",
|
|
12
|
+
"hia-ir-exporter",
|
|
13
|
+
"diagnostics"
|
|
14
|
+
],
|
|
15
|
+
source: {
|
|
16
|
+
basePath: "",
|
|
17
|
+
mode: "all",
|
|
18
|
+
link: {
|
|
19
|
+
enabled: false,
|
|
20
|
+
rootUrl: "",
|
|
21
|
+
openMode: "same-tab"
|
|
22
|
+
},
|
|
23
|
+
preview: {
|
|
24
|
+
enabled: false,
|
|
25
|
+
defaultExpanded: false,
|
|
26
|
+
rangeStrategy: "parser-js",
|
|
27
|
+
contextLines: 0,
|
|
28
|
+
maxLines: 80,
|
|
29
|
+
maxScanLines: 40
|
|
30
|
+
},
|
|
31
|
+
references: {
|
|
32
|
+
enabled: true,
|
|
33
|
+
defaultExpanded: false
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
i18n: {
|
|
37
|
+
enabled: true,
|
|
38
|
+
defaultLocale: "zh-CN",
|
|
39
|
+
fallbackLocale: "zh-CN",
|
|
40
|
+
locales: ["zh-CN"],
|
|
41
|
+
mode: "runtimeSwitch",
|
|
42
|
+
resourceBasePath: "",
|
|
43
|
+
resources: []
|
|
44
|
+
},
|
|
45
|
+
diagnostics: {
|
|
46
|
+
throwOnError: false
|
|
47
|
+
},
|
|
48
|
+
integration: {
|
|
49
|
+
enabled: true,
|
|
50
|
+
outputFile: ""
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
function isPlainObject(value) {
|
|
55
|
+
return (
|
|
56
|
+
value !== null &&
|
|
57
|
+
typeof value === "object" &&
|
|
58
|
+
!Array.isArray(value) &&
|
|
59
|
+
Object.getPrototypeOf(value) === Object.prototype
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function mergeConfig(...sources) {
|
|
64
|
+
const result = {};
|
|
65
|
+
|
|
66
|
+
for (const source of sources) {
|
|
67
|
+
if (!isPlainObject(source)) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
for (const [key, value] of Object.entries(source)) {
|
|
72
|
+
if (isPlainObject(value) && isPlainObject(result[key])) {
|
|
73
|
+
result[key] = mergeConfig(result[key], value);
|
|
74
|
+
} else if (isPlainObject(value)) {
|
|
75
|
+
result[key] = mergeConfig(value);
|
|
76
|
+
} else if (Array.isArray(value)) {
|
|
77
|
+
result[key] = value.slice();
|
|
78
|
+
} else {
|
|
79
|
+
result[key] = value;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function readJsdocEnvConfig() {
|
|
88
|
+
try {
|
|
89
|
+
const env = require("jsdoc/env");
|
|
90
|
+
const conf = env && env.conf ? env.conf : {};
|
|
91
|
+
const opts = conf.opts || {};
|
|
92
|
+
|
|
93
|
+
return mergeConfig(
|
|
94
|
+
conf.hia,
|
|
95
|
+
conf["jsdoc-plugin-hia-sys"],
|
|
96
|
+
conf["@mandolin/jsdoc-plugin-hia-sys"],
|
|
97
|
+
opts.hia,
|
|
98
|
+
opts["jsdoc-plugin-hia-sys"],
|
|
99
|
+
opts["@mandolin/jsdoc-plugin-hia-sys"]
|
|
100
|
+
);
|
|
101
|
+
} catch (_error) {
|
|
102
|
+
return {};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function loadConfig(overrides) {
|
|
107
|
+
return mergeConfig(DEFAULT_CONFIG, readJsdocEnvConfig(), overrides);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
module.exports = {
|
|
111
|
+
DEFAULT_CONFIG,
|
|
112
|
+
loadConfig,
|
|
113
|
+
mergeConfig
|
|
114
|
+
};
|
package/src/index.cjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { createPluginSystem } = require("./runtime/create-plugin-system.cjs");
|
|
4
|
+
const outputContract = require("./runtime/output-contract.cjs");
|
|
5
|
+
const { builtInMicroPlugins } = require("./micro-plugins/index.cjs");
|
|
6
|
+
|
|
7
|
+
const system = createPluginSystem({
|
|
8
|
+
microPlugins: builtInMicroPlugins
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
exports.defineTags = function defineTags(dictionary) {
|
|
12
|
+
system.defineTags(dictionary);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.handlers = {
|
|
16
|
+
beforeParse(event) {
|
|
17
|
+
system.handle("beforeParse", event);
|
|
18
|
+
},
|
|
19
|
+
newDoclet(event) {
|
|
20
|
+
system.handle("newDoclet", event);
|
|
21
|
+
},
|
|
22
|
+
parseComplete(event) {
|
|
23
|
+
system.handle("parseComplete", event);
|
|
24
|
+
},
|
|
25
|
+
processingComplete(event) {
|
|
26
|
+
system.handle("processingComplete", event);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports._hia = {
|
|
31
|
+
createPluginSystem,
|
|
32
|
+
builtInMicroPlugins,
|
|
33
|
+
outputContract,
|
|
34
|
+
getState() {
|
|
35
|
+
return system.getState();
|
|
36
|
+
}
|
|
37
|
+
};
|