| author | |
| committer | |
| log | d858f261396fa6b9b3097b5b4d377f6465ec5909 |
| tree | 940d1bfc8ab0ad77aed6f8fbdbb52d7f7abac19c |
| parent | 413cfd4066c547ec1cf3c7b81b0ca34e9eddb82a |
2 files changed, 57 insertions(+), 16 deletions(-)
lib/docs/main.js+25-8| ... | ... | @@ -482,13 +482,13 @@ var zigAnalysis; |
| 482 | 482 | continue; |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | // if ("as" in value.expr) { | |
| 486 | // value = { | |
| 487 | // typeRef: zigAnalysis.exprs[value.expr.as.typeRefArg], | |
| 488 | // expr: zigAnalysis.exprs[value.expr.as.exprArg], | |
| 489 | // }; | |
| 490 | // continue; | |
| 491 | // } | |
| 485 | if ("as" in value.expr) { | |
| 486 | value = { | |
| 487 | typeRef: zigAnalysis.exprs[value.expr.as.typeRefArg], | |
| 488 | expr: zigAnalysis.exprs[value.expr.as.exprArg], | |
| 489 | }; | |
| 490 | continue; | |
| 491 | } | |
| 492 | 492 | |
| 493 | 493 | return value; |
| 494 | 494 | |
| ... | ... | @@ -1355,7 +1355,7 @@ var zigAnalysis; |
| 1355 | 1355 | } |
| 1356 | 1356 | |
| 1357 | 1357 | case "this":{ |
| 1358 | return "this"; | |
| 1358 | return "@This()"; | |
| 1359 | 1359 | } |
| 1360 | 1360 | |
| 1361 | 1361 | case "type": { |
| ... | ... | @@ -2333,6 +2333,23 @@ var zigAnalysis; |
| 2333 | 2333 | * @param {string} childName |
| 2334 | 2334 | */ |
| 2335 | 2335 | function findSubDecl(parentType, childName) { |
| 2336 | { | |
| 2337 | // Generic functions | |
| 2338 | if ("value" in parentType) { | |
| 2339 | const rv = resolveValue(parentType.value); | |
| 2340 | if ("type" in rv.expr) { | |
| 2341 | const t = zigAnalysis.types[rv.expr.type]; | |
| 2342 | if (t.kind == typeKinds.Fn && t.generic_ret != null) { | |
| 2343 | const rgr = resolveValue({expr: t.generic_ret}); | |
| 2344 | if ("type" in rgr.expr) { | |
| 2345 | parentType = zigAnalysis.types[rgr.expr.type]; | |
| 2346 | } | |
| 2347 | } | |
| 2348 | } | |
| 2349 | } | |
| 2350 | } | |
| 2351 | ||
| 2352 | ||
| 2336 | 2353 | if (!parentType.pubDecls) return null; |
| 2337 | 2354 | for (let i = 0; i < parentType.pubDecls.length; i += 1) { |
| 2338 | 2355 | let declIndex = parentType.pubDecls[i]; |
src/Autodoc.zig+32-8| ... | ... | @@ -3885,12 +3885,32 @@ fn analyzeFunctionExtended( |
| 3885 | 3885 | _ = try self.walkRef(file, scope, align_ref, false); |
| 3886 | 3886 | } |
| 3887 | 3887 | |
| 3888 | // TODO: a complete version of this will probably need a scope | |
| 3889 | // in order to evaluate correctly closures around funcion | |
| 3890 | // parameters etc. | |
| 3891 | const generic_ret: ?DocData.Expr = switch (ret_type_ref.expr) { | |
| 3892 | .type => |t| blk: { | |
| 3893 | if (fn_info.body.len == 0) break :blk null; | |
| 3894 | if (t == @enumToInt(Ref.type_type)) { | |
| 3895 | break :blk try self.getGenericReturnType( | |
| 3896 | file, | |
| 3897 | scope, | |
| 3898 | fn_info.body[fn_info.body.len - 1], | |
| 3899 | ); | |
| 3900 | } else { | |
| 3901 | break :blk null; | |
| 3902 | } | |
| 3903 | }, | |
| 3904 | else => null, | |
| 3905 | }; | |
| 3906 | ||
| 3888 | 3907 | self.types.items[type_slot_index] = .{ |
| 3889 | 3908 | .Fn = .{ |
| 3890 | 3909 | .name = "todo_name func", |
| 3891 | 3910 | .src = self_ast_node_index, |
| 3892 | 3911 | .params = param_type_refs.items, |
| 3893 | 3912 | .ret = ret_type_ref.expr, |
| 3913 | .generic_ret = generic_ret, | |
| 3894 | 3914 | .is_extern = extra.data.bits.is_extern, |
| 3895 | 3915 | .has_cc = extra.data.bits.has_cc, |
| 3896 | 3916 | .has_align = extra.data.bits.has_align, |
| ... | ... | @@ -3995,14 +4015,18 @@ fn analyzeFunction( |
| 3995 | 4015 | // in order to evaluate correctly closures around funcion |
| 3996 | 4016 | // parameters etc. |
| 3997 | 4017 | const generic_ret: ?DocData.Expr = switch (ret_type_ref.expr) { |
| 3998 | .type => |t| if (t == @enumToInt(Ref.type_type)) | |
| 3999 | try self.getGenericReturnType( | |
| 4000 | file, | |
| 4001 | scope, | |
| 4002 | fn_info.body[fn_info.body.len - 1], | |
| 4003 | ) | |
| 4004 | else | |
| 4005 | null, | |
| 4018 | .type => |t| blk: { | |
| 4019 | if (fn_info.body.len == 0) break :blk null; | |
| 4020 | if (t == @enumToInt(Ref.type_type)) { | |
| 4021 | break :blk try self.getGenericReturnType( | |
| 4022 | file, | |
| 4023 | scope, | |
| 4024 | fn_info.body[fn_info.body.len - 1], | |
| 4025 | ); | |
| 4026 | } else { | |
| 4027 | break :blk null; | |
| 4028 | } | |
| 4029 | }, | |
| 4006 | 4030 | else => null, |
| 4007 | 4031 | }; |
| 4008 | 4032 |