@hia-doc/dotnetdoc-runner 0.1.4 → 0.1.5
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/README.md +16 -0
- package/package.json +5 -5
- package/src/index.mjs +28 -9
- package/src/schema.mjs +2 -0
package/README.md
CHANGED
|
@@ -30,6 +30,22 @@ the workspace and never accepts absolute paths or `..` traversal.
|
|
|
30
30
|
配置输入支持原有单个 `path`、显式 `paths`,以及工作区相对的 `glob` /
|
|
31
31
|
`globs`。glob 展开只在工作区内执行,不接受绝对路径或 `..` 路径穿越。
|
|
32
32
|
|
|
33
|
+
For `dotnet-csharp-source`, config inputs can also provide `projectPath` to let
|
|
34
|
+
the runner resolve `.cs` files from a `.csproj` before invoking the lightweight
|
|
35
|
+
Roslyn source extractor.
|
|
36
|
+
|
|
37
|
+
对 `dotnet-csharp-source`,配置也可以提供 `projectPath`,由 runner 先从
|
|
38
|
+
`.csproj` 推导源码文件集合,再调用轻量 Roslyn source extractor。
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"kind": "dotnet-csharp-source",
|
|
43
|
+
"projectPath": "src/Portal.Components/Portal.Components.csproj",
|
|
44
|
+
"artifactBasePath": "source/Portal.Components",
|
|
45
|
+
"title": "Portal Components Source API"
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
33
49
|
```json
|
|
34
50
|
{
|
|
35
51
|
"kind": "dotnet-markup-comments",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hia-doc/dotnetdoc-runner",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Standalone .NET XML documentation runner and CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"LICENSE"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@hia-doc/dotnet-source-extractor": "0.1.
|
|
40
|
-
"@hia-doc/dotnet-xml-doc-extractor": "0.1.
|
|
41
|
-
"@hia-doc/dotnetdoc-adapter": "0.1.
|
|
42
|
-
"@hia-doc/dotnetdoc-spec": "0.1.
|
|
39
|
+
"@hia-doc/dotnet-source-extractor": "0.1.5",
|
|
40
|
+
"@hia-doc/dotnet-xml-doc-extractor": "0.1.5",
|
|
41
|
+
"@hia-doc/dotnetdoc-adapter": "0.1.5",
|
|
42
|
+
"@hia-doc/dotnetdoc-spec": "0.1.5"
|
|
43
43
|
}
|
|
44
44
|
}
|
package/src/index.mjs
CHANGED
|
@@ -21,7 +21,7 @@ export {
|
|
|
21
21
|
} from "./schema.mjs";
|
|
22
22
|
import { DOTNETDOC_CONFIG_SCHEMA_ID, DOTNETDOC_CONFIG_SCHEMA_VERSION } from "./schema.mjs";
|
|
23
23
|
|
|
24
|
-
export const DOTNETDOC_RUNNER_VERSION = "0.1.
|
|
24
|
+
export const DOTNETDOC_RUNNER_VERSION = "0.1.5";
|
|
25
25
|
export const DOTNETDOC_INPUT_KINDS = Object.freeze(["dotnet-xml-doc", "dotnet-csharp-source", "dotnet-aspnet-surface", "dotnet-markup-comments", "dotnet-project"]);
|
|
26
26
|
export const DOTNETDOC_OUTPUT_KINDS = Object.freeze(["dotnetdoc-extraction", "hia-document", "dotnetdoc-source-relation", "dotnetdoc-aspnet-endpoint-extraction", "dotnetdoc-markup-comment-extraction", "dotnetdoc-project-discovery"]);
|
|
27
27
|
|
|
@@ -182,12 +182,15 @@ function normalizeRequest(request) {
|
|
|
182
182
|
|
|
183
183
|
function normalizeInput(input, index) {
|
|
184
184
|
assertRecord(input, `inputs[${index}] must be an object.`);
|
|
185
|
-
assertKnownKeys(input, ["kind", "path", "paths", "glob", "globs", "excludeGlobs", "globPatterns", "excludeGlobPatterns", "applicationRoot", "artifactBasePath", "hiaDocumentId", "title"], `inputs[${index}]`);
|
|
185
|
+
assertKnownKeys(input, ["kind", "path", "paths", "projectPath", "glob", "globs", "excludeGlobs", "globPatterns", "excludeGlobPatterns", "applicationRoot", "artifactBasePath", "hiaDocumentId", "title"], `inputs[${index}]`);
|
|
186
186
|
if (!DOTNETDOC_INPUT_KINDS.includes(input.kind)) {
|
|
187
187
|
throw new TypeError(`inputs[${index}].kind must be one of: ${DOTNETDOC_INPUT_KINDS.join(", ")}.`);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
const explicitPaths = normalizeInputPathList(input, index);
|
|
191
|
+
const projectPath = input.projectPath == null
|
|
192
|
+
? null
|
|
193
|
+
: normalizeSafeProjectPath(input.projectPath, `inputs[${index}].projectPath`);
|
|
191
194
|
const globPatterns = uniqueStrings([
|
|
192
195
|
...normalizeInputGlobList(input, index, "glob", "globs"),
|
|
193
196
|
...normalizeInternalGlobList(input.globPatterns, index, "globPatterns")
|
|
@@ -196,19 +199,20 @@ function normalizeInput(input, index) {
|
|
|
196
199
|
...normalizeInputGlobList(input, index, null, "excludeGlobs"),
|
|
197
200
|
...normalizeInternalGlobList(input.excludeGlobPatterns, index, "excludeGlobPatterns")
|
|
198
201
|
]);
|
|
199
|
-
if (explicitPaths.length === 0 && globPatterns.length === 0) {
|
|
200
|
-
throw new TypeError(`inputs[${index}] must define path, paths, glob or globs.`);
|
|
202
|
+
if (explicitPaths.length === 0 && globPatterns.length === 0 && !projectPath) {
|
|
203
|
+
throw new TypeError(`inputs[${index}] must define path, paths, projectPath, glob or globs.`);
|
|
201
204
|
}
|
|
202
205
|
|
|
203
|
-
const inputPath = explicitPaths[0] ?? `${input.kind}-group`;
|
|
206
|
+
const inputPath = explicitPaths[0] ?? projectPath ?? `${input.kind}-group`;
|
|
204
207
|
const artifactBasePath = input.artifactBasePath
|
|
205
208
|
? normalizeSafeRelativePath(input.artifactBasePath, `inputs[${index}].artifactBasePath`)
|
|
206
|
-
: (explicitPaths[0] ? stripKnownInputExtension(explicitPaths[0]) : `${input.kind}-group`);
|
|
209
|
+
: (explicitPaths[0] ? stripKnownInputExtension(explicitPaths[0]) : projectPath ? stripKnownInputExtension(projectPath) : `${input.kind}-group`);
|
|
207
210
|
|
|
208
211
|
return {
|
|
209
212
|
kind: input.kind,
|
|
210
213
|
path: inputPath,
|
|
211
214
|
paths: explicitPaths,
|
|
215
|
+
projectPath,
|
|
212
216
|
globPatterns,
|
|
213
217
|
excludeGlobPatterns,
|
|
214
218
|
applicationRoot: input.applicationRoot ? normalizeSafeRelativePath(input.applicationRoot, `inputs[${index}].applicationRoot`) : ".",
|
|
@@ -441,10 +445,14 @@ async function processXmlDocInput(input, request) {
|
|
|
441
445
|
}
|
|
442
446
|
|
|
443
447
|
async function processCSharpSourceInput(input, request) {
|
|
444
|
-
|
|
448
|
+
const sourceRequest = {
|
|
445
449
|
workspaceRoot: request.workspaceRoot,
|
|
446
450
|
paths: input.paths
|
|
447
|
-
}
|
|
451
|
+
};
|
|
452
|
+
if (input.projectPath) {
|
|
453
|
+
sourceRequest.projectPath = input.projectPath;
|
|
454
|
+
}
|
|
455
|
+
return extractDotnetSourceFiles(sourceRequest);
|
|
448
456
|
}
|
|
449
457
|
|
|
450
458
|
async function processAspNetEndpointInput(input, request) {
|
|
@@ -502,7 +510,7 @@ async function expandInputs(request) {
|
|
|
502
510
|
const expandedPaths = await expandInputPaths(request.workspaceRoot, input);
|
|
503
511
|
expandedInputs.push({
|
|
504
512
|
...input,
|
|
505
|
-
path: expandedPaths[0],
|
|
513
|
+
path: expandedPaths[0] ?? input.path,
|
|
506
514
|
paths: expandedPaths,
|
|
507
515
|
globPatterns: undefined,
|
|
508
516
|
excludeGlobPatterns: undefined
|
|
@@ -516,6 +524,9 @@ async function expandInputPaths(workspaceRoot, input) {
|
|
|
516
524
|
? []
|
|
517
525
|
: await expandGlobPatterns(workspaceRoot, input.globPatterns, input.excludeGlobPatterns);
|
|
518
526
|
const paths = uniqueStrings([...input.paths, ...matchedPaths]);
|
|
527
|
+
if (paths.length === 0 && input.projectPath) {
|
|
528
|
+
return [];
|
|
529
|
+
}
|
|
519
530
|
if (paths.length === 0) {
|
|
520
531
|
throw new TypeError(`Input ${input.kind} did not resolve any paths.`);
|
|
521
532
|
}
|
|
@@ -630,6 +641,14 @@ function normalizeSafeGlobPattern(value, label) {
|
|
|
630
641
|
return normalized;
|
|
631
642
|
}
|
|
632
643
|
|
|
644
|
+
function normalizeSafeProjectPath(value, label) {
|
|
645
|
+
const normalized = normalizeSafeRelativePath(value, label);
|
|
646
|
+
if (path.extname(normalized).toLowerCase() !== ".csproj") {
|
|
647
|
+
throw new TypeError(`${label} must reference a .csproj file.`);
|
|
648
|
+
}
|
|
649
|
+
return normalized;
|
|
650
|
+
}
|
|
651
|
+
|
|
633
652
|
function uniqueStrings(values) {
|
|
634
653
|
return [...new Set(values)];
|
|
635
654
|
}
|
package/src/schema.mjs
CHANGED
|
@@ -40,6 +40,7 @@ export const DOTNETDOC_CONFIG_JSON_SCHEMA = Object.freeze({
|
|
|
40
40
|
anyOf: [
|
|
41
41
|
{ required: ["path"] },
|
|
42
42
|
{ required: ["paths"] },
|
|
43
|
+
{ required: ["projectPath"] },
|
|
43
44
|
{ required: ["glob"] },
|
|
44
45
|
{ required: ["globs"] }
|
|
45
46
|
],
|
|
@@ -47,6 +48,7 @@ export const DOTNETDOC_CONFIG_JSON_SCHEMA = Object.freeze({
|
|
|
47
48
|
kind: { enum: ["dotnet-xml-doc", "dotnet-csharp-source", "dotnet-aspnet-surface", "dotnet-markup-comments", "dotnet-project"] },
|
|
48
49
|
path: relativePath,
|
|
49
50
|
paths: relativePathArray,
|
|
51
|
+
projectPath: relativePath,
|
|
50
52
|
glob: relativePath,
|
|
51
53
|
globs: relativePathArray,
|
|
52
54
|
excludeGlobs: relativePathArray,
|