mirror of
https://github.com/tauri-apps/rustdocusaurus.git
synced 2026-02-04 02:31:18 +01:00
fix: Improved headers, docblocks & link to source
This commit is contained in:
32
github-action/dist/index.js
vendored
32
github-action/dist/index.js
vendored
@@ -75237,8 +75237,17 @@ const removeChildren = (parent) => {
|
||||
}
|
||||
};
|
||||
|
||||
const insertAfter = (document, newNode, referenceNode) => {
|
||||
if (!referenceNode.nextSibling) {
|
||||
const sibling = document.createElement("div")
|
||||
referenceNode.parentNode.appendChild(sibling);
|
||||
}
|
||||
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
removeChildren,
|
||||
insertAfter
|
||||
};
|
||||
|
||||
|
||||
@@ -164636,7 +164645,7 @@ const jsdom = __webpack_require__(2039);
|
||||
const TurndownService = __webpack_require__(4469);
|
||||
const { clone, itemsReference } = __webpack_require__(5225);
|
||||
const pretty = __webpack_require__(8555);
|
||||
const { removeChildren } = __webpack_require__(4323);
|
||||
const { removeChildren, insertAfter } = __webpack_require__(4323);
|
||||
|
||||
// const Entities = require('html-entities').AllHtmlEntities;
|
||||
|
||||
@@ -164700,9 +164709,10 @@ const transformSourceLinks = (dom, crate, repositoryInfo) => {
|
||||
.replace(/#(.+)/, ":$1");
|
||||
|
||||
const functionName = header.querySelector("code > a").textContent;
|
||||
|
||||
let functionPrototype = header
|
||||
.querySelector("code")
|
||||
.textContent.replace(/\s{4,5}/g, "\n ");
|
||||
.innerHTML.replace(/\s{4,5}/g, "\n ");
|
||||
if (functionPrototype.match(/\(\n/)) {
|
||||
functionPrototype = functionPrototype.replace(") ->", "\n) ->");
|
||||
}
|
||||
@@ -164710,21 +164720,28 @@ const transformSourceLinks = (dom, crate, repositoryInfo) => {
|
||||
|
||||
const functionNameWrapper = dom.window.document.createElement("code");
|
||||
const prototype = dom.window.document.createElement("pre");
|
||||
const wrapper = dom.window.document.createElement("span");
|
||||
const wrapper = dom.window.document.createElement("i");
|
||||
const text = dom.window.document.createTextNode("Defined in: ");
|
||||
|
||||
functionNameWrapper.textContent = functionName;
|
||||
prototype.textContent = functionPrototype;
|
||||
prototype.innerHTML = functionPrototype;
|
||||
srclink.href = getGitHubURL(`core/${crate}/src/${file}`);
|
||||
srclink.title = "";
|
||||
|
||||
removeChildren(header);
|
||||
header.appendChild(functionNameWrapper);
|
||||
wrapper.appendChild(prototype);
|
||||
wrapper.appendChild(text);
|
||||
wrapper.appendChild(srclink);
|
||||
|
||||
header.nextElementSibling.appendChild(wrapper);
|
||||
insertAfter(dom.window.document, prototype, header);
|
||||
|
||||
insertAfter(
|
||||
dom.window.document,
|
||||
wrapper,
|
||||
prototype.nextSibling.classList.contains("docblock")
|
||||
? prototype.nextSibling
|
||||
: prototype
|
||||
);
|
||||
};
|
||||
|
||||
Array.from(dom.window.document.querySelectorAll("h3")).forEach(
|
||||
@@ -164765,7 +164782,8 @@ const transform = async (contents, crate, repositoryInfo) => {
|
||||
for (const path in transformedContents.module) {
|
||||
transformedContents.module[path] = await transform(
|
||||
transformedContents.module[path],
|
||||
crate
|
||||
crate,
|
||||
repositoryInfo
|
||||
);
|
||||
}
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user