@hia-doc/dotnetdoc-runner 0.1.2 → 0.1.4
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 +30 -2
- package/package.json +5 -5
- package/src/index.mjs +238 -21
- package/src/schema.mjs +18 -2
package/README.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# @hia-doc/dotnetdoc-runner
|
|
2
2
|
|
|
3
3
|
Standalone runner and CLI for compiler-generated .NET XML documentation files,
|
|
4
|
-
C# source inputs, ASP.NET endpoint surface inputs
|
|
5
|
-
structure discovery.
|
|
4
|
+
C# source inputs, ASP.NET endpoint surface inputs, ASP.NET/Razor markup comment
|
|
5
|
+
inputs and `.sln`/`.csproj` structure discovery.
|
|
6
|
+
|
|
7
|
+
DotNetDoc 独立 runner 与 CLI,支持编译器 XML documentation、C# 源码、
|
|
8
|
+
ASP.NET endpoint surface、ASP.NET/Razor 标记层注释,以及 `.sln`/`.csproj`
|
|
9
|
+
结构发现。
|
|
6
10
|
|
|
7
11
|
```sh
|
|
8
12
|
hia-dotnetdoc --config dotnetdoc.config.json
|
|
@@ -11,3 +15,27 @@ hia-dotnetdoc --config dotnetdoc.config.json
|
|
|
11
15
|
This package emits DotNetDoc extraction artifacts, HIA document artifacts,
|
|
12
16
|
optional source relation artifacts, ASP.NET endpoint extraction artifacts and a
|
|
13
17
|
documentation producer result manifest without embedding private source text.
|
|
18
|
+
|
|
19
|
+
`dotnet-markup-comments` inputs emit `dotnetdoc-markup-comment-extraction` and
|
|
20
|
+
matching HIA document artifacts for `.aspx`, `.ascx`, `.cshtml` and `.razor`
|
|
21
|
+
files.
|
|
22
|
+
|
|
23
|
+
`dotnet-markup-comments` input 会为 `.aspx`、`.ascx`、`.cshtml`、`.razor`
|
|
24
|
+
文件输出 `dotnetdoc-markup-comment-extraction` 与对应 HIA document。
|
|
25
|
+
|
|
26
|
+
Config inputs support the original single `path`, explicit `paths`, and
|
|
27
|
+
workspace-relative `glob` / `globs` patterns. Glob expansion is performed inside
|
|
28
|
+
the workspace and never accepts absolute paths or `..` traversal.
|
|
29
|
+
|
|
30
|
+
配置输入支持原有单个 `path`、显式 `paths`,以及工作区相对的 `glob` /
|
|
31
|
+
`globs`。glob 展开只在工作区内执行,不接受绝对路径或 `..` 路径穿越。
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"kind": "dotnet-markup-comments",
|
|
36
|
+
"globs": ["src/Web/**/*.{aspx,ascx,master,cshtml,razor}"],
|
|
37
|
+
"excludeGlobs": ["src/Web/**/bin/**", "src/Web/**/obj/**"],
|
|
38
|
+
"artifactBasePath": "web/markup-comments",
|
|
39
|
+
"title": "Web Markup Comments"
|
|
40
|
+
}
|
|
41
|
+
```
|
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.4",
|
|
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.4",
|
|
40
|
+
"@hia-doc/dotnet-xml-doc-extractor": "0.1.4",
|
|
41
|
+
"@hia-doc/dotnetdoc-adapter": "0.1.4",
|
|
42
|
+
"@hia-doc/dotnetdoc-spec": "0.1.4"
|
|
43
43
|
}
|
|
44
44
|
}
|
package/src/index.mjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { readFile, mkdir, writeFile } from "node:fs/promises";
|
|
1
|
+
import { readFile, mkdir, readdir, writeFile } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
|
-
import { extractAspNetEndpoints, extractDotnetProjectDiscovery, extractDotnetSourceFiles } from "@hia-doc/dotnet-source-extractor";
|
|
4
|
+
import { extractAspNetEndpoints, extractDotnetMarkupComments, extractDotnetProjectDiscovery, extractDotnetSourceFiles } from "@hia-doc/dotnet-source-extractor";
|
|
5
5
|
import { extractDotnetXmlDocs } from "@hia-doc/dotnet-xml-doc-extractor";
|
|
6
|
-
import { dotnetAspNetEndpointsToHiaDocument, dotnetProjectDiscoveryToHiaDocument, dotnetXmlDocsToHiaDocument } from "@hia-doc/dotnetdoc-adapter";
|
|
6
|
+
import { dotnetAspNetEndpointsToHiaDocument, dotnetMarkupCommentsToHiaDocument, dotnetProjectDiscoveryToHiaDocument, dotnetXmlDocsToHiaDocument } from "@hia-doc/dotnetdoc-adapter";
|
|
7
7
|
import {
|
|
8
8
|
DOTNETDOC_ASPNET_ENDPOINT_EXTRACTION_CONTRACT,
|
|
9
9
|
DOTNETDOC_CSHARP_SOURCE_EXTRACTION_CONTRACT,
|
|
10
|
+
DOTNETDOC_MARKUP_COMMENT_EXTRACTION_CONTRACT,
|
|
10
11
|
DOTNETDOC_PROJECT_DISCOVERY_CONTRACT,
|
|
11
12
|
DOTNETDOC_SOURCE_RELATION_CONTRACT,
|
|
12
13
|
DOTNETDOC_SOURCE_RELATION_CONTRACT_VERSION,
|
|
@@ -20,9 +21,9 @@ export {
|
|
|
20
21
|
} from "./schema.mjs";
|
|
21
22
|
import { DOTNETDOC_CONFIG_SCHEMA_ID, DOTNETDOC_CONFIG_SCHEMA_VERSION } from "./schema.mjs";
|
|
22
23
|
|
|
23
|
-
export const DOTNETDOC_RUNNER_VERSION = "0.1.
|
|
24
|
-
export const DOTNETDOC_INPUT_KINDS = Object.freeze(["dotnet-xml-doc", "dotnet-csharp-source", "dotnet-aspnet-surface", "dotnet-project"]);
|
|
25
|
-
export const DOTNETDOC_OUTPUT_KINDS = Object.freeze(["dotnetdoc-extraction", "hia-document", "dotnetdoc-source-relation", "dotnetdoc-aspnet-endpoint-extraction", "dotnetdoc-project-discovery"]);
|
|
24
|
+
export const DOTNETDOC_RUNNER_VERSION = "0.1.4";
|
|
25
|
+
export const DOTNETDOC_INPUT_KINDS = Object.freeze(["dotnet-xml-doc", "dotnet-csharp-source", "dotnet-aspnet-surface", "dotnet-markup-comments", "dotnet-project"]);
|
|
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"]);
|
|
26
27
|
|
|
27
28
|
const RESULT_CONTRACT = "documentation-producer-result";
|
|
28
29
|
const RESULT_CONTRACT_VERSION = "0.1.0-draft";
|
|
@@ -39,7 +40,11 @@ const SAFE_ID_PATTERN = /^[a-z0-9][a-z0-9._-]*$/;
|
|
|
39
40
|
* @lang zh-CN 执行 .NET XML documentation 构建。
|
|
40
41
|
*/
|
|
41
42
|
export async function runDotnetDoc(request, context = {}) {
|
|
42
|
-
const
|
|
43
|
+
const normalizedRequest = normalizeRequest(request);
|
|
44
|
+
const normalized = {
|
|
45
|
+
...normalizedRequest,
|
|
46
|
+
inputs: await expandInputs(normalizedRequest)
|
|
47
|
+
};
|
|
43
48
|
await mkdir(normalized.outputDirectory, { recursive: true });
|
|
44
49
|
|
|
45
50
|
const artifacts = [];
|
|
@@ -177,19 +182,35 @@ function normalizeRequest(request) {
|
|
|
177
182
|
|
|
178
183
|
function normalizeInput(input, index) {
|
|
179
184
|
assertRecord(input, `inputs[${index}] must be an object.`);
|
|
180
|
-
assertKnownKeys(input, ["kind", "path", "applicationRoot", "artifactBasePath", "hiaDocumentId", "title"], `inputs[${index}]`);
|
|
185
|
+
assertKnownKeys(input, ["kind", "path", "paths", "glob", "globs", "excludeGlobs", "globPatterns", "excludeGlobPatterns", "applicationRoot", "artifactBasePath", "hiaDocumentId", "title"], `inputs[${index}]`);
|
|
181
186
|
if (!DOTNETDOC_INPUT_KINDS.includes(input.kind)) {
|
|
182
187
|
throw new TypeError(`inputs[${index}].kind must be one of: ${DOTNETDOC_INPUT_KINDS.join(", ")}.`);
|
|
183
188
|
}
|
|
184
189
|
|
|
185
|
-
const
|
|
190
|
+
const explicitPaths = normalizeInputPathList(input, index);
|
|
191
|
+
const globPatterns = uniqueStrings([
|
|
192
|
+
...normalizeInputGlobList(input, index, "glob", "globs"),
|
|
193
|
+
...normalizeInternalGlobList(input.globPatterns, index, "globPatterns")
|
|
194
|
+
]);
|
|
195
|
+
const excludeGlobPatterns = uniqueStrings([
|
|
196
|
+
...normalizeInputGlobList(input, index, null, "excludeGlobs"),
|
|
197
|
+
...normalizeInternalGlobList(input.excludeGlobPatterns, index, "excludeGlobPatterns")
|
|
198
|
+
]);
|
|
199
|
+
if (explicitPaths.length === 0 && globPatterns.length === 0) {
|
|
200
|
+
throw new TypeError(`inputs[${index}] must define path, paths, glob or globs.`);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const inputPath = explicitPaths[0] ?? `${input.kind}-group`;
|
|
186
204
|
const artifactBasePath = input.artifactBasePath
|
|
187
205
|
? normalizeSafeRelativePath(input.artifactBasePath, `inputs[${index}].artifactBasePath`)
|
|
188
|
-
: stripKnownInputExtension(
|
|
206
|
+
: (explicitPaths[0] ? stripKnownInputExtension(explicitPaths[0]) : `${input.kind}-group`);
|
|
189
207
|
|
|
190
208
|
return {
|
|
191
209
|
kind: input.kind,
|
|
192
210
|
path: inputPath,
|
|
211
|
+
paths: explicitPaths,
|
|
212
|
+
globPatterns,
|
|
213
|
+
excludeGlobPatterns,
|
|
193
214
|
applicationRoot: input.applicationRoot ? normalizeSafeRelativePath(input.applicationRoot, `inputs[${index}].applicationRoot`) : ".",
|
|
194
215
|
artifactBasePath,
|
|
195
216
|
hiaDocumentId: input.hiaDocumentId,
|
|
@@ -204,21 +225,28 @@ async function processInput(input, request) {
|
|
|
204
225
|
? await processCSharpSourceInput(input, request)
|
|
205
226
|
: input.kind === "dotnet-aspnet-surface"
|
|
206
227
|
? await processAspNetEndpointInput(input, request)
|
|
207
|
-
:
|
|
228
|
+
: input.kind === "dotnet-markup-comments"
|
|
229
|
+
? await processMarkupCommentInput(input, request)
|
|
230
|
+
: await processProjectDiscoveryInput(input, request);
|
|
208
231
|
const hiaDocument = dotnetdoc.contract === DOTNETDOC_ASPNET_ENDPOINT_EXTRACTION_CONTRACT
|
|
209
232
|
? dotnetAspNetEndpointsToHiaDocument(dotnetdoc, {
|
|
210
233
|
id: input.hiaDocumentId,
|
|
211
234
|
title: input.title
|
|
212
235
|
})
|
|
213
|
-
: dotnetdoc.contract ===
|
|
214
|
-
?
|
|
236
|
+
: dotnetdoc.contract === DOTNETDOC_MARKUP_COMMENT_EXTRACTION_CONTRACT
|
|
237
|
+
? dotnetMarkupCommentsToHiaDocument(dotnetdoc, {
|
|
215
238
|
id: input.hiaDocumentId,
|
|
216
239
|
title: input.title
|
|
217
240
|
})
|
|
218
|
-
:
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
241
|
+
: dotnetdoc.contract === DOTNETDOC_PROJECT_DISCOVERY_CONTRACT
|
|
242
|
+
? dotnetProjectDiscoveryToHiaDocument(dotnetdoc, {
|
|
243
|
+
id: input.hiaDocumentId,
|
|
244
|
+
title: input.title
|
|
245
|
+
})
|
|
246
|
+
: dotnetXmlDocsToHiaDocument(dotnetdoc, {
|
|
247
|
+
id: input.hiaDocumentId,
|
|
248
|
+
title: input.title
|
|
249
|
+
});
|
|
222
250
|
|
|
223
251
|
const dotnetdocPath = `${input.artifactBasePath}.dotnetdoc.json`;
|
|
224
252
|
const hiaPath = `${input.artifactBasePath}.hia.json`;
|
|
@@ -415,7 +443,7 @@ async function processXmlDocInput(input, request) {
|
|
|
415
443
|
async function processCSharpSourceInput(input, request) {
|
|
416
444
|
return extractDotnetSourceFiles({
|
|
417
445
|
workspaceRoot: request.workspaceRoot,
|
|
418
|
-
paths:
|
|
446
|
+
paths: input.paths
|
|
419
447
|
});
|
|
420
448
|
}
|
|
421
449
|
|
|
@@ -423,14 +451,21 @@ async function processAspNetEndpointInput(input, request) {
|
|
|
423
451
|
return extractAspNetEndpoints({
|
|
424
452
|
workspaceRoot: request.workspaceRoot,
|
|
425
453
|
applicationRoot: input.applicationRoot,
|
|
426
|
-
paths:
|
|
454
|
+
paths: input.paths
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
async function processMarkupCommentInput(input, request) {
|
|
459
|
+
return extractDotnetMarkupComments({
|
|
460
|
+
workspaceRoot: request.workspaceRoot,
|
|
461
|
+
paths: input.paths
|
|
427
462
|
});
|
|
428
463
|
}
|
|
429
464
|
|
|
430
465
|
async function processProjectDiscoveryInput(input, request) {
|
|
431
466
|
return extractDotnetProjectDiscovery({
|
|
432
467
|
workspaceRoot: request.workspaceRoot,
|
|
433
|
-
|
|
468
|
+
paths: input.paths
|
|
434
469
|
});
|
|
435
470
|
}
|
|
436
471
|
|
|
@@ -461,6 +496,118 @@ function normalizeConfigDirectory(value, label) {
|
|
|
461
496
|
return normalizeSafeRelativePath(value, label);
|
|
462
497
|
}
|
|
463
498
|
|
|
499
|
+
async function expandInputs(request) {
|
|
500
|
+
const expandedInputs = [];
|
|
501
|
+
for (const input of request.inputs) {
|
|
502
|
+
const expandedPaths = await expandInputPaths(request.workspaceRoot, input);
|
|
503
|
+
expandedInputs.push({
|
|
504
|
+
...input,
|
|
505
|
+
path: expandedPaths[0],
|
|
506
|
+
paths: expandedPaths,
|
|
507
|
+
globPatterns: undefined,
|
|
508
|
+
excludeGlobPatterns: undefined
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
return expandedInputs;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
async function expandInputPaths(workspaceRoot, input) {
|
|
515
|
+
const matchedPaths = input.globPatterns.length === 0
|
|
516
|
+
? []
|
|
517
|
+
: await expandGlobPatterns(workspaceRoot, input.globPatterns, input.excludeGlobPatterns);
|
|
518
|
+
const paths = uniqueStrings([...input.paths, ...matchedPaths]);
|
|
519
|
+
if (paths.length === 0) {
|
|
520
|
+
throw new TypeError(`Input ${input.kind} did not resolve any paths.`);
|
|
521
|
+
}
|
|
522
|
+
if (input.kind === "dotnet-xml-doc" && paths.length !== 1) {
|
|
523
|
+
throw new TypeError("dotnet-xml-doc inputs currently require exactly one XML documentation path.");
|
|
524
|
+
}
|
|
525
|
+
return paths;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
async function expandGlobPatterns(workspaceRoot, patterns, excludePatterns) {
|
|
529
|
+
const includeRegexes = expandBracePatterns(patterns).map(globPatternToRegExp);
|
|
530
|
+
const excludeRegexes = expandBracePatterns(excludePatterns).map(globPatternToRegExp);
|
|
531
|
+
const matched = new Set();
|
|
532
|
+
for (const pattern of patterns) {
|
|
533
|
+
const searchRoot = globSearchRoot(pattern);
|
|
534
|
+
const files = await listWorkspaceFiles(workspaceRoot, searchRoot);
|
|
535
|
+
for (const filePath of files) {
|
|
536
|
+
if (includeRegexes.some((regex) => regex.test(filePath)) && !excludeRegexes.some((regex) => regex.test(filePath))) {
|
|
537
|
+
matched.add(filePath);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
return [...matched].sort((left, right) => left.localeCompare(right));
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
async function listWorkspaceFiles(workspaceRoot, relativeDirectory) {
|
|
545
|
+
const root = path.join(workspaceRoot, relativeDirectory);
|
|
546
|
+
const result = [];
|
|
547
|
+
|
|
548
|
+
async function visit(absoluteDirectory, relativeDirectoryPath) {
|
|
549
|
+
let entries;
|
|
550
|
+
try {
|
|
551
|
+
entries = await readdir(absoluteDirectory, { withFileTypes: true });
|
|
552
|
+
} catch (error) {
|
|
553
|
+
if (error?.code === "ENOENT") {
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
throw error;
|
|
557
|
+
}
|
|
558
|
+
for (const entry of entries) {
|
|
559
|
+
const relativePath = relativeDirectoryPath === "." ? entry.name : `${relativeDirectoryPath}/${entry.name}`;
|
|
560
|
+
const absolutePath = path.join(absoluteDirectory, entry.name);
|
|
561
|
+
if (entry.isDirectory()) {
|
|
562
|
+
await visit(absolutePath, relativePath);
|
|
563
|
+
} else if (entry.isFile()) {
|
|
564
|
+
result.push(relativePath.replaceAll("\\", "/"));
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
await visit(root, relativeDirectory);
|
|
570
|
+
return result;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function normalizeInputPathList(input, index) {
|
|
574
|
+
const paths = [];
|
|
575
|
+
if (input.path !== undefined) {
|
|
576
|
+
paths.push(normalizeSafeRelativePath(input.path, `inputs[${index}].path`));
|
|
577
|
+
}
|
|
578
|
+
if (input.paths !== undefined) {
|
|
579
|
+
if (!Array.isArray(input.paths) || input.paths.length === 0) {
|
|
580
|
+
throw new TypeError(`inputs[${index}].paths must be a non-empty array.`);
|
|
581
|
+
}
|
|
582
|
+
paths.push(...input.paths.map((value, pathIndex) => normalizeSafeRelativePath(value, `inputs[${index}].paths[${pathIndex}]`)));
|
|
583
|
+
}
|
|
584
|
+
return uniqueStrings(paths);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
function normalizeInputGlobList(input, index, singularKey, pluralKey) {
|
|
588
|
+
const patterns = [];
|
|
589
|
+
if (singularKey && input[singularKey] !== undefined) {
|
|
590
|
+
patterns.push(normalizeSafeGlobPattern(input[singularKey], `inputs[${index}].${singularKey}`));
|
|
591
|
+
}
|
|
592
|
+
if (input[pluralKey] !== undefined) {
|
|
593
|
+
if (!Array.isArray(input[pluralKey]) || input[pluralKey].length === 0) {
|
|
594
|
+
throw new TypeError(`inputs[${index}].${pluralKey} must be a non-empty array.`);
|
|
595
|
+
}
|
|
596
|
+
patterns.push(...input[pluralKey].map((value, patternIndex) => normalizeSafeGlobPattern(value, `inputs[${index}].${pluralKey}[${patternIndex}]`)));
|
|
597
|
+
}
|
|
598
|
+
return uniqueStrings(patterns);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
function normalizeInternalGlobList(values, index, key) {
|
|
602
|
+
if (values === undefined) {
|
|
603
|
+
return [];
|
|
604
|
+
}
|
|
605
|
+
if (!Array.isArray(values)) {
|
|
606
|
+
throw new TypeError(`inputs[${index}].${key} must be an array.`);
|
|
607
|
+
}
|
|
608
|
+
return values.map((value, patternIndex) => normalizeSafeGlobPattern(value, `inputs[${index}].${key}[${patternIndex}]`));
|
|
609
|
+
}
|
|
610
|
+
|
|
464
611
|
function normalizeSafeRelativePath(value, label) {
|
|
465
612
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
466
613
|
throw new TypeError(`${label} must be a non-empty relative path.`);
|
|
@@ -472,8 +619,78 @@ function normalizeSafeRelativePath(value, label) {
|
|
|
472
619
|
return normalized;
|
|
473
620
|
}
|
|
474
621
|
|
|
622
|
+
function normalizeSafeGlobPattern(value, label) {
|
|
623
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
624
|
+
throw new TypeError(`${label} must be a non-empty relative glob pattern.`);
|
|
625
|
+
}
|
|
626
|
+
const normalized = value.replaceAll("\\", "/").replace(/^\.\//, "");
|
|
627
|
+
if (!normalized || normalized.startsWith("/") || /^[a-zA-Z]:\//.test(normalized) || normalized.split("/").includes("..")) {
|
|
628
|
+
throw new TypeError(`${label} must be a safe relative glob pattern.`);
|
|
629
|
+
}
|
|
630
|
+
return normalized;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
function uniqueStrings(values) {
|
|
634
|
+
return [...new Set(values)];
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
function expandBracePatterns(patterns) {
|
|
638
|
+
return patterns.flatMap(expandBracePattern);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
function expandBracePattern(pattern) {
|
|
642
|
+
const match = /\{([^{}]+)\}/.exec(pattern);
|
|
643
|
+
if (!match) {
|
|
644
|
+
return [pattern];
|
|
645
|
+
}
|
|
646
|
+
const before = pattern.slice(0, match.index);
|
|
647
|
+
const after = pattern.slice(match.index + match[0].length);
|
|
648
|
+
return match[1].split(",").flatMap((part) => expandBracePattern(`${before}${part.trim()}${after}`));
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
function globSearchRoot(pattern) {
|
|
652
|
+
const segments = pattern.split("/");
|
|
653
|
+
const staticSegments = [];
|
|
654
|
+
for (const segment of segments) {
|
|
655
|
+
if (/[*{}]/.test(segment)) {
|
|
656
|
+
break;
|
|
657
|
+
}
|
|
658
|
+
staticSegments.push(segment);
|
|
659
|
+
}
|
|
660
|
+
return staticSegments.length === 0 ? "." : staticSegments.join("/");
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
function globPatternToRegExp(pattern) {
|
|
664
|
+
let source = "^";
|
|
665
|
+
for (let index = 0; index < pattern.length;) {
|
|
666
|
+
const char = pattern[index];
|
|
667
|
+
if (char === "*") {
|
|
668
|
+
if (pattern[index + 1] === "*") {
|
|
669
|
+
if (pattern[index + 2] === "/") {
|
|
670
|
+
source += "(?:.*/)?";
|
|
671
|
+
index += 3;
|
|
672
|
+
} else {
|
|
673
|
+
source += ".*";
|
|
674
|
+
index += 2;
|
|
675
|
+
}
|
|
676
|
+
} else {
|
|
677
|
+
source += "[^/]*";
|
|
678
|
+
index += 1;
|
|
679
|
+
}
|
|
680
|
+
continue;
|
|
681
|
+
}
|
|
682
|
+
source += escapeRegExp(char);
|
|
683
|
+
index += 1;
|
|
684
|
+
}
|
|
685
|
+
return new RegExp(`${source}$`);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
function escapeRegExp(value) {
|
|
689
|
+
return value.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
|
|
690
|
+
}
|
|
691
|
+
|
|
475
692
|
function stripKnownInputExtension(value) {
|
|
476
|
-
return value.replace(/\.(?:xml|cs|csproj|sln)$/i, "");
|
|
693
|
+
return value.replace(/\.(?:xml|cs|csproj|sln|aspx|ascx|master|cshtml|razor)$/i, "");
|
|
477
694
|
}
|
|
478
695
|
|
|
479
696
|
function safeArtifactId(value) {
|
package/src/schema.mjs
CHANGED
|
@@ -12,6 +12,12 @@ const relativePath = {
|
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
const relativePathArray = {
|
|
16
|
+
type: "array",
|
|
17
|
+
minItems: 1,
|
|
18
|
+
items: relativePath
|
|
19
|
+
};
|
|
20
|
+
|
|
15
21
|
export const DOTNETDOC_CONFIG_JSON_SCHEMA = Object.freeze({
|
|
16
22
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
17
23
|
$id: DOTNETDOC_CONFIG_SCHEMA_ID,
|
|
@@ -30,10 +36,20 @@ export const DOTNETDOC_CONFIG_JSON_SCHEMA = Object.freeze({
|
|
|
30
36
|
items: {
|
|
31
37
|
type: "object",
|
|
32
38
|
additionalProperties: false,
|
|
33
|
-
required: ["kind"
|
|
39
|
+
required: ["kind"],
|
|
40
|
+
anyOf: [
|
|
41
|
+
{ required: ["path"] },
|
|
42
|
+
{ required: ["paths"] },
|
|
43
|
+
{ required: ["glob"] },
|
|
44
|
+
{ required: ["globs"] }
|
|
45
|
+
],
|
|
34
46
|
properties: {
|
|
35
|
-
kind: { enum: ["dotnet-xml-doc", "dotnet-csharp-source", "dotnet-aspnet-surface", "dotnet-project"] },
|
|
47
|
+
kind: { enum: ["dotnet-xml-doc", "dotnet-csharp-source", "dotnet-aspnet-surface", "dotnet-markup-comments", "dotnet-project"] },
|
|
36
48
|
path: relativePath,
|
|
49
|
+
paths: relativePathArray,
|
|
50
|
+
glob: relativePath,
|
|
51
|
+
globs: relativePathArray,
|
|
52
|
+
excludeGlobs: relativePathArray,
|
|
37
53
|
applicationRoot: relativePath,
|
|
38
54
|
artifactBasePath: relativePath,
|
|
39
55
|
hiaDocumentId: { type: "string", minLength: 1 },
|