diff --git a/lib/std/special/docs/main.js b/lib/std/special/docs/main.js
index e0d6cdaf0..181267122 100644
--- a/lib/std/special/docs/main.js
+++ b/lib/std/special/docs/main.js
@@ -20,7 +20,7 @@
var domListValues = document.getElementById("listValues");
var domFnProto = document.getElementById("fnProto");
var domFnProtoCode = document.getElementById("fnProtoCode");
- var domFnDocs = document.getElementById("fnDocs");
+ var domTldDocs = document.getElementById("tldDocs");
var domSectFnErrors = document.getElementById("sectFnErrors");
var domListFnErrors = document.getElementById("listFnErrors");
var domTableFnErrors = document.getElementById("tableFnErrors");
@@ -34,7 +34,6 @@
var domListSearchResults = document.getElementById("listSearchResults");
var domSectSearchNoResults = document.getElementById("sectSearchNoResults");
var domSectInfo = document.getElementById("sectInfo");
- var domListInfo = document.getElementById("listInfo");
var domTdTarget = document.getElementById("tdTarget");
var domTdZigVer = document.getElementById("tdZigVer");
var domHdrName = document.getElementById("hdrName");
@@ -102,7 +101,7 @@
function render() {
domStatus.classList.add("hidden");
domFnProto.classList.add("hidden");
- domFnDocs.classList.add("hidden");
+ domTldDocs.classList.add("hidden");
domSectPkgs.classList.add("hidden");
domSectTypes.classList.add("hidden");
domSectNamespaces.classList.add("hidden");
@@ -190,11 +189,11 @@
var docs = zigAnalysis.astNodes[decl.src].docs;
if (docs != null) {
- domFnDocs.innerHTML = markdown(docs);
+ domTldDocs.innerHTML = markdown(docs);
} else {
- domFnDocs.innerHTML = '
There are no doc comments for this declaration.
';
+ domTldDocs.innerHTML = '
There are no doc comments for this declaration.
';
}
- domFnDocs.classList.remove("hidden");
+ domTldDocs.classList.remove("hidden");
}
function typeIsErrSet(typeIndex) {
@@ -274,8 +273,8 @@
docsSource = protoSrcNode.docs;
}
if (docsSource != null) {
- domFnDocs.innerHTML = markdown(docsSource);
- domFnDocs.classList.remove("hidden");
+ domTldDocs.innerHTML = markdown(docsSource);
+ domTldDocs.classList.remove("hidden");
}
domFnProto.classList.remove("hidden");
}
@@ -893,8 +892,8 @@
var docs = zigAnalysis.astNodes[decl.src].docs;
if (docs != null) {
- domFnDocs.innerHTML = markdown(docs);
- domFnDocs.classList.remove("hidden");
+ domTldDocs.innerHTML = markdown(docs);
+ domTldDocs.classList.remove("hidden");
}
domFnProto.classList.remove("hidden");
@@ -906,8 +905,8 @@
var docs = zigAnalysis.astNodes[decl.src].docs;
if (docs != null) {
- domFnDocs.innerHTML = markdown(docs);
- domFnDocs.classList.remove("hidden");
+ domTldDocs.innerHTML = markdown(docs);
+ domTldDocs.classList.remove("hidden");
}
domFnProto.classList.remove("hidden");
@@ -957,6 +956,14 @@
varsList.sort(byNameProperty);
valsList.sort(byNameProperty);
+ if (container.src != null) {
+ var docs = zigAnalysis.astNodes[container.src].docs;
+ if (docs != null) {
+ domTldDocs.innerHTML = markdown(docs);
+ domTldDocs.classList.remove("hidden");
+ }
+ }
+
if (typesList.length !== 0) {
resizeDomList(domListTypes, typesList.length, '
');
for (var i = 0; i < typesList.length; i += 1) {
diff --git a/lib/std/zig/ast.zig b/lib/std/zig/ast.zig
index 65fbc5160..0a7bfe2f5 100644
--- a/lib/std/zig/ast.zig
+++ b/lib/std/zig/ast.zig
@@ -2253,7 +2253,6 @@ pub const Node = struct {
test "iterate" {
var root = Node.Root{
.base = Node{ .id = Node.Id.Root },
- .doc_comments = null,
.decls = Node.Root.DeclList.init(std.debug.global_allocator),
.eof_token = 0,
};
diff --git a/src/dump_analysis.cpp b/src/dump_analysis.cpp
index b5fd38e26..98bbcc6a4 100644
--- a/src/dump_analysis.cpp
+++ b/src/dump_analysis.cpp
@@ -1088,6 +1088,7 @@ static void anal_dump_node(AnalDumpCtx *ctx, const AstNode *node) {
break;
case NodeTypeContainerDecl:
field_nodes = &node->data.container_decl.fields;
+ doc_comments_buf = &node->data.container_decl.doc_comments;
break;
default:
break;
diff --git a/src/parser.cpp b/src/parser.cpp
index eef832e32..04dccb0d2 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -493,7 +493,9 @@ static AstNode *ast_parse_root(ParseContext *pc) {
node->data.container_decl.layout = ContainerLayoutAuto;
node->data.container_decl.kind = ContainerKindStruct;
node->data.container_decl.is_root = true;
- node->data.container_decl.doc_comments = members.doc_comments;
+ if (buf_len(&members.doc_comments) != 0) {
+ node->data.container_decl.doc_comments = members.doc_comments;
+ }
return node;
}
@@ -2817,7 +2819,9 @@ static AstNode *ast_parse_container_decl_auto(ParseContext *pc) {
res->data.container_decl.fields = members.fields;
res->data.container_decl.decls = members.decls;
- res->data.container_decl.doc_comments = members.doc_comments;
+ if (buf_len(&members.doc_comments) != 0) {
+ res->data.container_decl.doc_comments = members.doc_comments;
+ }
return res;
}