diff options
| author | Loris Cro <kappaloris@gmail.com> | 2022-08-21 18:53:00 +0200 |
|---|---|---|
| committer | Loris Cro <kappaloris@gmail.com> | 2022-08-23 18:37:29 +0200 |
| commit | 0482e8ba9d63ea009a9e0c2d497371261764d3e1 (patch) | |
| tree | 3e92ac8a2a2da11a0bc301510bdefb87d5dd9723 /lib | |
| parent | 583175dc1d8d14bc92838476eb226f0e91077abc (diff) | |
| download | zig-0482e8ba9d63ea009a9e0c2d497371261764d3e1.tar.gz zig-0482e8ba9d63ea009a9e0c2d497371261764d3e1.zip | |
autodoc: initial support for struct_init_anon
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/docs/main.js | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/lib/docs/main.js b/lib/docs/main.js index 5a3572a629..8f6bbcedd2 100644 --- a/lib/docs/main.js +++ b/lib/docs/main.js @@ -1430,20 +1430,25 @@ var zigAnalysis; return lhs + "!" + rhs; } case "struct": { - const struct_name = - zigAnalysis.decls[expr.struct[0].val.typeRef.refPath[0].declRef].name; + // const struct_name = + // zigAnalysis.decls[expr.struct[0].val.typeRef.refPath[0].declRef].name; + const struct_name = "."; let struct_body = ""; struct_body += struct_name + "{ "; for (let i = 0; i < expr.struct.length; i++) { - const val = expr.struct[i].name; - const exprArg = zigAnalysis.exprs[expr.struct[i].val.expr.as.exprArg]; - let value_field = exprArg[Object.keys(exprArg)[0]]; - if (value_field instanceof Object) { - value_field = - zigAnalysis.decls[value_field[0].val.typeRef.refPath[0].declRef] - .name; - } - struct_body += "." + val + " = " + value_field; + const fv = expr.struct[i]; + const field_name = fv.name; + const exprArg = zigAnalysis.exprs[fv.val.expr.as.exprArg]; + let field_value = exprName(exprArg, opts); + // TODO: commented out because it seems not needed. if it deals + // with a corner case, please add a comment when re-enabling it. + // let field_value = exprArg[Object.keys(exprArg)[0]]; + // if (field_value instanceof Object) { + // value_field = exprName(value_field) + // zigAnalysis.decls[value_field[0].val.typeRef.refPath[0].declRef] + // .name; + // } + struct_body += "." + field_name + " = " + field_value; if (i !== expr.struct.length - 1) { struct_body += ", "; } else { |
