@hia-doc/dotnetdoc-runner 0.1.11 → 0.1.12
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 +7 -1
- package/package.json +5 -5
- package/src/index.mjs +1 -1
- package/src/source-locations.mjs +48 -16
package/README.md
CHANGED
|
@@ -78,7 +78,7 @@ For real C# locations, use a configured `dotnet-project` solution/project input
|
|
|
78
78
|
unique assembly and complete documentation-comment ID match. It does not add duplicate
|
|
79
79
|
C# documentation pages and works with `writeSourceRelationArtifact: false`.
|
|
80
80
|
|
|
81
|
-
Unresolved or ambiguous members have no code locator.
|
|
81
|
+
Unresolved or ambiguous members have no code locator. Conflicting declarations, missing
|
|
82
82
|
references, unavailable .NET tooling and sources outside the workspace are never repaired
|
|
83
83
|
by choosing an arbitrary filename. Extraction reads configured source only; it does not
|
|
84
84
|
execute the target build, download source, parse Windows/Portable PDBs or grant publication
|
|
@@ -87,3 +87,9 @@ permission. Existing source preview settings still require explicit publication
|
|
|
87
87
|
中文:XML是文档出处;代码定位来自已配置项目中的唯一真实Roslyn声明。缺失/歧义保持未定位,
|
|
88
88
|
不会回退XML或按名称猜文件。需要现有.NET 8 SDK/helper;本轮不实现PDB读取,尤其不能把传统
|
|
89
89
|
Windows PDB当作Portable PDB。范围与语言随真实声明输出,所有XML注释/本地化字段保持。
|
|
90
|
+
|
|
91
|
+
### Coverage diagnostics (0.1.12)
|
|
92
|
+
|
|
93
|
+
Read `document.metadata.sourceLocationResolution` for coverage counts and reference-warning codes, and each `symbol.diagnostics` for `data.symbolId`, `memberName`, `reason` (`missing`/`ambiguous`) and detail. Proven partial types prefer a non-generated declaration, then stable path/start position; the selected rule and candidate count appear in `symbol.metadata.dotnetdoc.sourceLocationResolution`. Duplicate inputs are not silently collapsed. Re-extract artifacts after upgrading; source publication still requires the existing explicit authorization.
|
|
94
|
+
|
|
95
|
+
中文:计数在metadata层;未定位成员逐项带诊断,合法partial记录主声明选择。升级后重新抽取,不改变公开授权。
|
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.12",
|
|
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.12",
|
|
40
|
+
"@hia-doc/dotnet-xml-doc-extractor": "0.1.12",
|
|
41
|
+
"@hia-doc/dotnetdoc-adapter": "0.1.12",
|
|
42
|
+
"@hia-doc/dotnetdoc-spec": "0.1.12"
|
|
43
43
|
}
|
|
44
44
|
}
|
package/src/index.mjs
CHANGED
|
@@ -33,7 +33,7 @@ import { enrichXmlSourceLocations } from "./source-locations.mjs";
|
|
|
33
33
|
* @lang zh-CN DotNetDoc runner/producer 的公开包版本;它与各个 `0.1.0-draft` artifact contract version 分离。
|
|
34
34
|
* @lang en Public package version of the DotNetDoc runner/producer, kept separate from every `0.1.0-draft` artifact contract version.
|
|
35
35
|
*/
|
|
36
|
-
export const DOTNETDOC_RUNNER_VERSION = "0.1.
|
|
36
|
+
export const DOTNETDOC_RUNNER_VERSION = "0.1.12";
|
|
37
37
|
export const DOTNETDOC_INPUT_KINDS = Object.freeze(["dotnet-xml-doc", "dotnet-csharp-source", "dotnet-aspnet-surface", "dotnet-markup-comments", "dotnet-project"]);
|
|
38
38
|
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"]);
|
|
39
39
|
export const DOTNETDOC_BUILD_WARNING_CLASSIFICATION_CONTRACT = "dotnetdoc-build-warning-classification";
|
package/src/source-locations.mjs
CHANGED
|
@@ -10,22 +10,38 @@ import { dotnetXmlDocsToHiaDocument } from '@hia-doc/dotnetdoc-adapter';
|
|
|
10
10
|
import { DOTNETDOC_XML_DOC_EXTRACTION_CONTRACT, DOTNETDOC_CSHARP_SOURCE_EXTRACTION_CONTRACT, DOTNETDOC_PROJECT_DISCOVERY_CONTRACT } from '@hia-doc/dotnetdoc-spec';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* @lang zh-CN 按完整成员ID
|
|
14
|
-
* @lang en Selects
|
|
13
|
+
* @lang zh-CN 按完整成员ID选声明;同次抽取的真实partial类型选主声明,重复注册/跨抽取冲突仍拒绝。
|
|
14
|
+
* @lang en Selects declarations by complete member ID; genuine partial types from one extraction select a primary declaration, while duplicates and cross-extraction conflicts remain refused.
|
|
15
15
|
* @param {object} member <lang><zh-CN>XML成员身份。</zh-CN><en>XML member identity.</en></lang>
|
|
16
16
|
* @param {object[]} candidates <lang><zh-CN>声明及其程序集身份。</zh-CN><en>Declarations with assembly identities.</en></lang>
|
|
17
17
|
* @param {string|null} assembly <lang><zh-CN>XML声明的程序集。</zh-CN><en>Assembly declared by the XML input.</en></lang>
|
|
18
|
-
* @returns {{declaration?:object,status:string}} <lang><zh-CN
|
|
18
|
+
* @returns {{declaration?:object,status:string,candidateCount:number,selectionRule?:string}} <lang><zh-CN>精确/partial主声明或missing/ambiguous,含候选数与选择规则;不按简称或参数数量回退。</zh-CN><en>Exact/partial primary declaration or missing/ambiguous, with candidate count and selection rule; no short-name or arity fallback.</en></lang>
|
|
19
19
|
*/
|
|
20
20
|
export function selectExactDeclaration(member, candidates, assembly) {
|
|
21
|
-
// <lang><zh-CN
|
|
21
|
+
// <lang><zh-CN>完整ID及签名类型先验证;相同位置重复注册不自动合并为同一输入事实。</zh-CN><en>Validate complete IDs and signature types first; duplicate registrations at the same location do not automatically become one input fact.</en></lang>
|
|
22
22
|
const unique = [];
|
|
23
23
|
for (const candidate of candidates) {
|
|
24
|
-
if (candidate.member.semantic?.documentationCommentId !== member.memberName) continue;
|
|
24
|
+
if (candidate.member.semantic?.documentationCommentId !== member.memberName || candidate.member.semantic?.hasUnresolvedSignatureTypes === true) continue;
|
|
25
25
|
if (assembly && candidate.assembly && candidate.assembly !== 'DotNetDoc.SourceExtraction' && candidate.assembly !== assembly) continue;
|
|
26
|
-
unique.push(candidate
|
|
26
|
+
unique.push(candidate);
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
if(unique.length===1) return {status:'resolved',declaration:unique[0].member,candidateCount:1,selectionRule:'exact-documentation-id'};
|
|
29
|
+
// <lang><zh-CN>partial必须来自同一编译事实、同一程序集且位置各异;普通重复不能靠排序变成有效声明。</zh-CN><en>Partial declarations must share a compilation and assembly with distinct locations; ordering cannot legitimize ordinary duplicates.</en></lang>
|
|
30
|
+
const first=unique[0];
|
|
31
|
+
const locations=new Set(unique.map(candidate=>`${candidate.member.source?.path}:${candidate.member.source?.range?.start?.line}:${candidate.member.source?.range?.start?.column}`));
|
|
32
|
+
if(unique.length>1 && first.origin && locations.size===unique.length && unique.every(candidate=>candidate.origin===first.origin && candidate.assembly===first.assembly && candidate.member.kind==='dotnet-type' && candidate.member.semantic?.declaration?.isPartialType===true && candidate.member.semantic.declaration.declarationCount===unique.length)){
|
|
33
|
+
const ranked=[...unique].sort(compareDeclarations);
|
|
34
|
+
return {status:'resolved',declaration:ranked[0].member,candidateCount:unique.length,selectionRule:'non-generated-path-line'};
|
|
35
|
+
}
|
|
36
|
+
return {status:unique.length===0?'missing':'ambiguous',candidateCount:unique.length};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** @lang zh-CN 排序仅用于已证明的同一partial语义符号,不使用宿主locale。 @lang en Orders only proven parts of the same semantic symbol, independently of host locale. */
|
|
40
|
+
function compareDeclarations(left,right){
|
|
41
|
+
const a=left.member,b=right.member;
|
|
42
|
+
const generated=Number(a.semantic.declaration.isGenerated)-Number(b.semantic.declaration.isGenerated);
|
|
43
|
+
const aPath=a.source.path.replaceAll('\\','/'),bPath=b.source.path.replaceAll('\\','/');
|
|
44
|
+
return generated || (aPath<bPath?-1:aPath>bPath?1:0) || a.source.range.start.line-b.source.range.start.line || (a.source.range.start.column??1)-(b.source.range.start.column??1);
|
|
29
45
|
}
|
|
30
46
|
|
|
31
47
|
/**
|
|
@@ -56,10 +72,15 @@ export async function enrichXmlSourceLocations(records, request) {
|
|
|
56
72
|
const matches = assembly ? available.filter(project => (project.assemblyName ?? project.name) === assembly) : [];
|
|
57
73
|
// <lang><zh-CN>每项目串行抽取并缓存一次;失败也是本请求缓存结果,不反复启动helper。</zh-CN><en>Extract each project serially once and cache failures too, preventing repeated helper launches.</en></lang>
|
|
58
74
|
let discovered = [];
|
|
75
|
+
let referenceDiagnosticCodes = [];
|
|
59
76
|
if (matches.length === 1) {
|
|
60
77
|
const project = matches[0];
|
|
61
|
-
|
|
62
|
-
|
|
78
|
+
const referenceDirectory=path.posix.dirname(record.input.path.replaceAll('\\','/'));
|
|
79
|
+
const cacheKey=`${project.path}\n${referenceDirectory}`;
|
|
80
|
+
if (!cache.has(cacheKey)) cache.set(cacheKey, await readProjectCandidates(project, request.workspaceRoot, referenceDirectory));
|
|
81
|
+
const extracted=cache.get(cacheKey);
|
|
82
|
+
discovered = extracted.candidates;
|
|
83
|
+
referenceDiagnosticCodes=extracted.referenceDiagnosticCodes;
|
|
63
84
|
}
|
|
64
85
|
// <lang><zh-CN>显式输入对其成员ID优先;自动项目发现不重复注册同一显式身份,显式输入之间的重复仍拒绝。</zh-CN><en>Explicit inputs take precedence for their member IDs; automatic discovery never duplicates an explicit identity, while duplicates between explicit inputs remain refused.</en></lang>
|
|
65
86
|
const explicitIds = new Set(explicit.filter(candidate => !assembly || !candidate.assembly || candidate.assembly === assembly || candidate.assembly === 'DotNetDoc.SourceExtraction').map(candidate => candidate.member.semantic?.documentationCommentId));
|
|
@@ -74,21 +95,31 @@ export async function enrichXmlSourceLocations(records, request) {
|
|
|
74
95
|
}
|
|
75
96
|
// <lang><zh-CN>统计是有界元数据;每个符号保留XML原文/i18n,只合并验证后的代码声明。
|
|
76
97
|
// </zh-CN><en>Counts are bounded metadata; each symbol retains XML text/i18n and merges only verified code declarations.</en></lang>
|
|
77
|
-
const summary = { strategy: 'assembly-and-documentation-id', resolved: 0, ambiguous: 0, missing: 0 };
|
|
98
|
+
const summary = { strategy: 'assembly-and-documentation-id', resolved: 0, ambiguous: 0, missing: 0, resolvedPartial: 0, referenceDiagnosticCodes };
|
|
78
99
|
const members = [];
|
|
100
|
+
// <lang><zh-CN>逐成员记录与计数在同一循环生成,避免诊断和source事实漂移。</zh-CN><en>Generate per-member records and counts in one loop to keep diagnostics aligned with source facts.</en></lang>
|
|
101
|
+
const resolutions=[];
|
|
79
102
|
for (const member of record.artifact.members) {
|
|
80
103
|
const selected = selectExactDeclaration(member, byId.get(member.memberName) ?? [], assembly);
|
|
81
|
-
if (selected.status !== 'resolved') { summary[selected.status] += 1; members.push(member); continue; }
|
|
104
|
+
if (selected.status !== 'resolved') { summary[selected.status] += 1; members.push(member); resolutions.push({status:selected.status,candidateCount:selected.candidateCount,reason:selected.status,detail:referenceDiagnosticCodes.length?'metadata-reference-or-project-unavailable':'no-unique-exact-declaration'}); continue; }
|
|
82
105
|
const declaration = selected.declaration;
|
|
83
106
|
try {
|
|
84
107
|
await assertContainedFile(request.workspaceRoot, declaration.source.path);
|
|
85
108
|
if (!/\.cs$/iu.test(declaration.source.path) || !validRange(declaration.source.range)) throw new Error('Not a bounded C# declaration');
|
|
86
109
|
summary.resolved += 1;
|
|
110
|
+
if(selected.selectionRule==='non-generated-path-line') summary.resolvedPartial+=1;
|
|
87
111
|
members.push({ ...member, source: declaration.source, semantic: { ...member.semantic, ...declaration.semantic } });
|
|
88
|
-
|
|
112
|
+
resolutions.push({status:'resolved',candidateCount:selected.candidateCount,selectionRule:selected.selectionRule});
|
|
113
|
+
} catch { summary.missing += 1; members.push(member); resolutions.push({status:'missing',reason:'missing',detail:'unsafe-or-invalid-declaration-location',candidateCount:selected.candidateCount}); }
|
|
89
114
|
}
|
|
90
115
|
const document = dotnetXmlDocsToHiaDocument({ ...record.artifact, members }, { id: record.input.hiaDocumentId, title: record.input.title });
|
|
91
116
|
document.metadata.sourceLocationResolution = summary;
|
|
117
|
+
for(const [index,symbol] of document.symbols.entries()){
|
|
118
|
+
const resolution=resolutions[index];
|
|
119
|
+
symbol.metadata.dotnetdoc.sourceLocationResolution=resolution;
|
|
120
|
+
if(resolution.status!=='resolved') symbol.diagnostics.push({code:resolution.status==='ambiguous'?'DOTNETDOC_SOURCE_LOCATION_AMBIGUOUS':'DOTNETDOC_SOURCE_LOCATION_MISSING',message:'No unique verified C# location is available for this documentation member.',severity:'warning',data:{symbolId:symbol.id,memberName:symbol.metadata.dotnetdoc.memberName,...resolution}});
|
|
121
|
+
}
|
|
122
|
+
if(summary.missing||summary.ambiguous) document.diagnostics.push({code:'DOTNETDOC_SOURCE_LOCATION_UNRESOLVED',message:'Some documentation members have no unique verified C# location; inspect member diagnostics and metadata.sourceLocationResolution.',severity:'warning',data:summary});
|
|
92
123
|
record.hiaDocument = document;
|
|
93
124
|
await writeFile(path.join(request.outputDirectory, record.hiaPath), `${JSON.stringify(document, null, 2)}\n`, 'utf8');
|
|
94
125
|
if (summary.missing || summary.ambiguous) diagnostics.push({ code: 'DOTNETDOC_SOURCE_LOCATION_UNRESOLVED', message: 'Some XML members have no unique C# declaration. Configure the matching project/source inputs and resolve missing references; XML origins are not exposed as code.', severity: 'warning', source: { path: record.input.path }, metadata: summary });
|
|
@@ -98,11 +129,11 @@ export async function enrichXmlSourceLocations(records, request) {
|
|
|
98
129
|
|
|
99
130
|
/** @lang zh-CN 从已有抽取结果取身份和定位,不复制方法体。 @lang en Selects identities/locators from existing extraction results without copying method bodies. */
|
|
100
131
|
function candidatesFrom(artifact) {
|
|
101
|
-
return artifact.members.map(member => ({ member, assembly: artifact.assembly?.name ?? member.semantic?.containingAssembly }));
|
|
132
|
+
return artifact.members.map(member => ({ member, assembly: artifact.assembly?.name ?? member.semantic?.containingAssembly, origin: artifact }));
|
|
102
133
|
}
|
|
103
134
|
|
|
104
135
|
/** @lang zh-CN 受限项目只读抽取;任何路径/工具失败都变为未定位,不泄露底层错误。 @lang en Performs bounded read-only project extraction, mapping path/tool failures to unresolved locations without leaking underlying errors. */
|
|
105
|
-
async function readProjectCandidates(project, root) {
|
|
136
|
+
async function readProjectCandidates(project, root, referenceDirectory) {
|
|
106
137
|
try {
|
|
107
138
|
await assertContainedFile(root, project.path);
|
|
108
139
|
// <lang><zh-CN>显式Compile条目先验证真实路径;SDK默认遍历不跟随symlink,项目根仍须在工作区内。</zh-CN><en>Validate real paths of explicit Compile items first; SDK enumeration does not follow symlinks and its project root must remain inside the workspace.</en></lang>
|
|
@@ -111,8 +142,9 @@ async function readProjectCandidates(project, root) {
|
|
|
111
142
|
const sourcePath = path.posix.normalize(path.posix.join(path.posix.dirname(project.path), item.include.replaceAll('\\', '/')));
|
|
112
143
|
await assertContainedFile(root, sourcePath);
|
|
113
144
|
}
|
|
114
|
-
|
|
115
|
-
|
|
145
|
+
const artifact=await extractDotnetSourceFiles({ workspaceRoot: root, projectPath: project.path, referenceDirectory });
|
|
146
|
+
return {candidates:candidatesFrom(artifact),referenceDiagnosticCodes:[...new Set((artifact.diagnostics??[]).filter(item=>/^DOTNETDOC_(?:METADATA|FRAMEWORK)_REFERENCE/u.test(item.code)).map(item=>item.code))].sort()};
|
|
147
|
+
} catch { return {candidates:[],referenceDiagnosticCodes:['DOTNETDOC_SOURCE_PROJECT_UNAVAILABLE']}; }
|
|
116
148
|
}
|
|
117
149
|
|
|
118
150
|
/** @lang zh-CN 双重路径包含检查,不读取越界symlink目标正文。 @lang en Checks lexical and real-path containment without reading bodies behind escaping symlinks. */
|