Merge pull request #13300 from jcalabro/master

Better Autodoc Src File Links
This commit is contained in:
Loris Cro 2022-10-30 17:20:57 +01:00 committed by GitHub
commit 1696434063
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1859,8 +1859,10 @@ var zigAnalysis;
"</a>";
} else {
payloadHtml += escapeHtml(opts.fnDecl.name);
payloadHtml = "<a target=\"_blank\" href=\"" +
sourceFileLink(opts.fnDecl) + "\">" +
escapeHtml(opts.fnDecl.name) + "</a>";
}
payloadHtml += renderSourceFileLink(opts.fnDecl);
payloadHtml += "</span>";
}
} else {
@ -2328,12 +2330,12 @@ var zigAnalysis;
}
}
}
function renderSourceFileLink(decl) {
let srcNode = getAstNode(decl.src);
return "<a style=\"float: right;\" href=\"" +
sourceFileUrlTemplate.replace("{{file}}",
zigAnalysis.files[srcNode.file]).replace("{{line}}", srcNode.line + 1) + "\">[src]</a>";
function sourceFileLink(decl) {
const srcNode = getAstNode(decl.src);
return sourceFileUrlTemplate.
replace("{{file}}", zigAnalysis.files[srcNode.file]).
replace("{{line}}", srcNode.line + 1);
}
function renderContainer(container) {
@ -2460,7 +2462,8 @@ var zigAnalysis;
fnDecl: decl,
linkFnNameDecl: navLinkDecl(decl.name),
});
tdFnSrc.innerHTML = renderSourceFileLink(decl);
tdFnSrc.innerHTML = "<a style=\"float: right;\" target=\"_blank\" href=\"" +
sourceFileLink(decl) + "\">[src]</a>";
let docs = getAstNode(decl.src).docs;
if (docs != null) {