aboutsummaryrefslogtreecommitdiff
path: root/lib/docs/commonmark.js
diff options
context:
space:
mode:
authorLoris Cro <kappaloris@gmail.com>2023-08-06 18:12:05 +0200
committerGitHub <noreply@github.com>2023-08-06 18:12:05 +0200
commit373e48c9831c44f15c3209a92779a87348f690fd (patch)
treec167d4bc0eb612631060625a3212956009d81183 /lib/docs/commonmark.js
parent1c7798a3cde9e8dad31c276aab4c1affb2043ad2 (diff)
downloadzig-373e48c9831c44f15c3209a92779a87348f690fd.tar.gz
zig-373e48c9831c44f15c3209a92779a87348f690fd.zip
autodoc: new layout (#16715)
* autodoc: init guide TOC work * autodoc: working guides toc navigation * autodoc: more improvements * autodoc: ui refinements * autodoc: new layout and init descriptions for namespaces in std.zig
Diffstat (limited to 'lib/docs/commonmark.js')
-rw-r--r--lib/docs/commonmark.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/docs/commonmark.js b/lib/docs/commonmark.js
index c1b33d7571..8a3762ea80 100644
--- a/lib/docs/commonmark.js
+++ b/lib/docs/commonmark.js
@@ -7831,6 +7831,16 @@
} else {
node._literal = contents;
}
+ const doc = this.options.autoDoc;
+ if (doc) {
+ const decl_hash = doc.detectDeclPath(contents);
+ if (decl_hash) {
+ var l = new Node("link");
+ l.destination = decl_hash;
+ l.appendChild(node);
+ node = l;
+ }
+ }
block.appendChild(node);
return true;
}
@@ -9702,6 +9712,7 @@
this.buffer = "";
this.lastOut = "\n";
+ this.heading_count = 0;
while ((event = walker.next())) {
type = event.node.type;
@@ -9883,6 +9894,10 @@
var tagname = "h" + node.level,
attrs = this.attrs(node);
if (entering) {
+ if (node.level != 1) {
+ attrs.push(["id", ":" + this.heading_count]);
+ this.heading_count += 1;
+ }
this.cr();
this.tag(tagname, attrs);
} else {