aboutsummaryrefslogtreecommitdiff
path: root/lib/docs
diff options
context:
space:
mode:
authorLoris Cro <kappaloris@gmail.com>2023-01-10 19:40:57 +0100
committerGitHub <noreply@github.com>2023-01-10 19:40:57 +0100
commit0cba60afed935b9ea0f40324cc15730414f2550e (patch)
treeeaf29932b79a4ef1118cae6b81f8135c7d3b2ad5 /lib/docs
parentf7ade7e63bfe63258807df6a97e222072cde1a35 (diff)
parentb63a771e18d61290b785370fcd86e70db3d04c42 (diff)
downloadzig-0cba60afed935b9ea0f40324cc15730414f2550e.tar.gz
zig-0cba60afed935b9ea0f40324cc15730414f2550e.zip
Merge pull request #14260 from EspeuteClement/master
autodoc: allow function descriptions expansion
Diffstat (limited to 'lib/docs')
-rw-r--r--lib/docs/index.html36
-rw-r--r--lib/docs/main.js29
2 files changed, 61 insertions, 4 deletions
diff --git a/lib/docs/index.html b/lib/docs/index.html
index 52012cad2f..8bf527999e 100644
--- a/lib/docs/index.html
+++ b/lib/docs/index.html
@@ -266,6 +266,42 @@
font-weight: bold;
}
+ details[open] summary .sum-less {
+ display: none;
+ }
+
+ details[open] summary .sum-more {
+ display: block;
+ }
+
+ details summary .sum-more {
+ display: none;
+ }
+
+ details summary {
+ list-style-type: none;
+ position: relative;
+ pointer-events: none;
+ }
+
+ details summary::before {
+ content: "[+] ";
+ font-family: var(--mono);
+ color: var(--link-color);
+ position: sticky;
+ float: left;
+ top: 0px;
+ right: -16px;
+ z-index: 1;
+ margin-left: -2em;
+ pointer-events: all;
+ cursor: pointer;
+ }
+
+ details[open] summary::before {
+ content: "[-] ";
+ }
+
.examples {
list-style-type: none;
margin: 0;
diff --git a/lib/docs/main.js b/lib/docs/main.js
index 4604744012..32ef68c572 100644
--- a/lib/docs/main.js
+++ b/lib/docs/main.js
@@ -2466,9 +2466,19 @@ var zigAnalysis;
let docs = getAstNode(decl.src).docs;
if (docs != null) {
- tdDesc.innerHTML = shortDescMarkdown(docs);
+ docs = docs.trim();
+ var short = shortDesc(docs);
+ if (short != docs) {
+ short = markdown(short);
+ var long = markdown(docs);
+ tdDesc.innerHTML =
+ "<details><summary><div class=\"sum-less\">" + short + "</div>" + "<div class=\"sum-more\">" + long + "</div></summary></details>";
+ }
+ else {
+ tdDesc.innerHTML = markdown(short);
+ }
} else {
- tdDesc.textContent = "";
+ tdDesc.innerHTML = "<p><i>No documentation provided.</i><p>";
}
}
domSectFns.classList.remove("hidden");
@@ -2897,7 +2907,7 @@ var zigAnalysis;
});
}
- function shortDescMarkdown(docs) {
+ function shortDesc(docs){
const trimmed_docs = docs.trim();
let index = trimmed_docs.indexOf("\n\n");
let cut = false;
@@ -2913,7 +2923,11 @@ var zigAnalysis;
let slice = trimmed_docs.slice(0, index);
if (cut) slice += "...";
- return markdown(slice);
+ return slice;
+ }
+
+ function shortDescMarkdown(docs) {
+ return markdown(shortDesc(docs));
}
function markdown(input) {
@@ -3110,6 +3124,13 @@ var zigAnalysis;
}
flushRun();
+ if (in_code) {
+ in_code = false;
+ parsing_code = false;
+ innerHTML += "</code>";
+ codetag = "";
+ }
+
while (stack.length > 0) {
const fmt = stack.pop();
innerHTML += "</" + fmt.tag + ">";