authorgravatar for clementespeute@shirogames.comClement Espeute <clementespeute@shirogames.com> 2023-01-10 14:00:11+01:00
committergravatar for espeut.clement@gmail.comValden <espeut.clement@gmail.com> 2023-01-10 18:55:49+01:00
logb63a771e18d61290b785370fcd86e70db3d04c42
treeeaf29932b79a4ef1118cae6b81f8135c7d3b2ad5
parentf7ade7e63bfe63258807df6a97e222072cde1a35

autodoc: allow function descriptions expansion


2 files changed, 61 insertions(+), 4 deletions(-)

lib/docs/index.html+36
...@@ -266,6 +266,42 @@...@@ -266,6 +266,42 @@
266 font-weight: bold;266 font-weight: bold;
267 }267 }
268268
269 details[open] summary .sum-less {
270 display: none;
271 }
272
273 details[open] summary .sum-more {
274 display: block;
275 }
276
277 details summary .sum-more {
278 display: none;
279 }
280
281 details summary {
282 list-style-type: none;
283 position: relative;
284 pointer-events: none;
285 }
286
287 details summary::before {
288 content: "[+] ";
289 font-family: var(--mono);
290 color: var(--link-color);
291 position: sticky;
292 float: left;
293 top: 0px;
294 right: -16px;
295 z-index: 1;
296 margin-left: -2em;
297 pointer-events: all;
298 cursor: pointer;
299 }
300
301 details[open] summary::before {
302 content: "[-] ";
303 }
304
269 .examples {305 .examples {
270 list-style-type: none;306 list-style-type: none;
271 margin: 0;307 margin: 0;
lib/docs/main.js+25-4
...@@ -2466,9 +2466,19 @@ var zigAnalysis;...@@ -2466,9 +2466,19 @@ var zigAnalysis;
24662466
2467 let docs = getAstNode(decl.src).docs;2467 let docs = getAstNode(decl.src).docs;
2468 if (docs != null) {2468 if (docs != null) {
2469 tdDesc.innerHTML = shortDescMarkdown(docs);2469 docs = docs.trim();
2470 var short = shortDesc(docs);
2471 if (short != docs) {
2472 short = markdown(short);
2473 var long = markdown(docs);
2474 tdDesc.innerHTML =
2475 "<details><summary><div class=\"sum-less\">" + short + "</div>" + "<div class=\"sum-more\">" + long + "</div></summary></details>";
2476 }
2477 else {
2478 tdDesc.innerHTML = markdown(short);
2479 }
2470 } else {2480 } else {
2471 tdDesc.textContent = "";2481 tdDesc.innerHTML = "<p><i>No documentation provided.</i><p>";
2472 }2482 }
2473 }2483 }
2474 domSectFns.classList.remove("hidden");2484 domSectFns.classList.remove("hidden");
...@@ -2897,7 +2907,7 @@ var zigAnalysis;...@@ -2897,7 +2907,7 @@ var zigAnalysis;
2897 });2907 });
2898 }2908 }
28992909
2900 function shortDescMarkdown(docs) {2910 function shortDesc(docs){
2901 const trimmed_docs = docs.trim();2911 const trimmed_docs = docs.trim();
2902 let index = trimmed_docs.indexOf("\n\n");2912 let index = trimmed_docs.indexOf("\n\n");
2903 let cut = false;2913 let cut = false;
...@@ -2913,7 +2923,11 @@ var zigAnalysis;...@@ -2913,7 +2923,11 @@ var zigAnalysis;
29132923
2914 let slice = trimmed_docs.slice(0, index);2924 let slice = trimmed_docs.slice(0, index);
2915 if (cut) slice += "...";2925 if (cut) slice += "...";
2916 return markdown(slice);2926 return slice;
2927 }
2928
2929 function shortDescMarkdown(docs) {
2930 return markdown(shortDesc(docs));
2917 }2931 }
29182932
2919 function markdown(input) {2933 function markdown(input) {
...@@ -3110,6 +3124,13 @@ var zigAnalysis;...@@ -3110,6 +3124,13 @@ var zigAnalysis;
3110 }3124 }
3111 flushRun();3125 flushRun();
31123126
3127 if (in_code) {
3128 in_code = false;
3129 parsing_code = false;
3130 innerHTML += "</code>";
3131 codetag = "";
3132 }
3133
3113 while (stack.length > 0) {3134 while (stack.length > 0) {
3114 const fmt = stack.pop();3135 const fmt = stack.pop();
3115 innerHTML += "</" + fmt.tag + ">";3136 innerHTML += "</" + fmt.tag + ">";