authorgravatar for der.teufel.mail@gmail.comKrzysztof Wolicki <der.teufel.mail@gmail.com> 2023-03-07 00:22:48+01:00
committergravatar for der.teufel.mail@gmail.comKrzysztof Wolicki <der.teufel.mail@gmail.com> 2023-03-07 00:32:26+01:00
log27d2848e0096d31cb42cb258a89ed276ec26434e
treee338146e8097edfeecff5f2a42ccbdd5c16e9ae8
parent6218e4004608000ba2e42e07ed1bd56745626820

autodoc: Add struct to tryResolveRefPath

fix rendering of fieldRef in exprName

2 files changed, 22 insertions(+), 3 deletions(-)

lib/docs/main.js+3-3
...@@ -1139,9 +1139,9 @@ const NAV_MODES = {...@@ -1139,9 +1139,9 @@ const NAV_MODES = {
1139 return exprName(switchIndex, opts);1139 return exprName(switchIndex, opts);
1140 }1140 }
1141 case "fieldRef": {1141 case "fieldRef": {
1142 const enumObj = exprName({ type: expr.fieldRef.type }, opts);1142 const field_idx = expr.fieldRef.index;
1143 const field =1143 const type = getType(expr.fieldRef.type);
1144 getAstNode(enumObj.src).fields[expr.fieldRef.index];1144 const field = getAstNode(type.src).fields[field_idx];
1145 const name = getAstNode(field).name;1145 const name = getAstNode(field).name;
1146 return name;1146 return name;
1147 }1147 }
src/Autodoc.zig+19
...@@ -3616,6 +3616,25 @@ fn tryResolveRefPath(...@@ -3616,6 +3616,25 @@ fn tryResolveRefPath(
3616 continue :outer;3616 continue :outer;
3617 },3617 },
3618 },3618 },
3619 .@"struct" => |st| {
3620 for (st) |field| {
3621 if (std.mem.eql(u8, field.name, child_string)) {
3622 path[i + 1] = field.val.expr;
3623 continue :outer;
3624 }
3625 }
3626
3627 // if we got here, our search failed
3628 printWithContext(
3629 file,
3630 inst_index,
3631 "failed to match `{s}` in struct",
3632 .{child_string},
3633 );
3634
3635 path[i + 1] = (try self.cteTodo("match failure")).expr;
3636 continue :outer;
3637 },
3619 }3638 }
3620 }3639 }
36213640