mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
autodoc: Lookup file-as-a-struct doctests using the stem of the filename
This is not a perfect solution and relies on the convention that file-as-a-struct types have the same file name as the type name. Fixes #23614
This commit is contained in:
parent
86d3546184
commit
04c3ccf877
2 changed files with 8 additions and 0 deletions
|
|
@ -599,6 +599,7 @@
|
|||
const members = namespaceMembers(decl_index, false).slice();
|
||||
const fields = declFields(decl_index).slice();
|
||||
renderNamespace(decl_index, members, fields);
|
||||
renderDocTests(decl_index);
|
||||
}
|
||||
|
||||
function operatorCompare(a, b) {
|
||||
|
|
|
|||
|
|
@ -537,6 +537,13 @@ fn struct_decl(
|
|||
try w.file.get().scopes.putNoClobber(gpa, node, &namespace.base);
|
||||
try w.scanDecls(namespace, container_decl.ast.members);
|
||||
|
||||
// TODO: Support for doctests on file-as-a-struct types without using
|
||||
// the filename to find the associated test.
|
||||
const stem = std.fs.path.stem(w.file.path());
|
||||
if (namespace.doctests.get(stem)) |doctest_node| {
|
||||
try w.file.get().doctests.put(gpa, parent_decl.get().ast_node, doctest_node);
|
||||
}
|
||||
|
||||
for (container_decl.ast.members) |member| switch (ast.nodeTag(member)) {
|
||||
.container_field_init,
|
||||
.container_field_align,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue