Commit 5f0ab34cc5

Reece Van Atta <reece@thrasker.com>
2022-03-21 18:42:22
autodoc: add type comments to main.js file
1 parent 9cd9a39
Changed files (1)
lib
docs
lib/docs/main.js
@@ -1,5 +1,184 @@
 'use strict';
 
+/**
+ * @typedef {
+    | "Type"
+    | "Void"
+    | "Bool"
+    | "NoReturn"
+    | "Int"
+    | "Float"
+    | "Pointer"
+    | "Array"
+    | "Struct"
+    | "ComptimeFloat"
+    | "ComptimeInt"
+    | "Undefined"
+    | "Null"
+    | "Optional"
+    | "ErrorUnion"
+    | "ErrorSet"
+    | "Enum"
+    | "Union"
+    | "Fn"
+    | "BoundFn"
+    | "Opaque"
+    | "Frame"
+    | "AnyFrame"
+    | "Vector"
+    | "EnumLiteral"
+    | "ComptimeExpr"
+    | "Unanalyzed"
+   } TypeKind
+*/
+
+/**
+ * @typedef {
+    | WalkResult
+    | { unspecified: {} }
+    | { anytype: {} }
+    | { type: number }
+    | { comptimeExpr: number }
+    | { call: number }
+    | { hasCte: boolean; declPath: number[] }
+   } TypeRef
+*/
+
+/**
+ * @typedef {
+    | { void: {} }
+    | { unreachable: {} }
+    | { anytype: {} }
+    | { type: number }
+    | { comptimeExpr: number }
+    | { call: number }
+    | { int: { typeRef: TypeRef; value: number } }
+    | { float: { typeRef: TypeRef; value: number } }
+    | { bool: boolean }
+    | { undefined: TypeRef }
+    | { null: TypeRef }
+    | { typeOf: WalkResult }
+    | { compileError: string }
+    | { string: string }
+    | { struct: Struct }
+    | { hasCte: boolean; declPath: number[] }
+    | { array: ZigArray }
+    | { enumLiteral: string }
+   } WalkResult
+*/
+
+/**
+ * @typedef {
+     { kind: number } & (
+        | { name: string } // Type, Void, Bool, NoReturn, Int, Float, ComptimeExpr, ComptimeFloat, ComptimeInt, Undefined, Null, ErrorUnion, BoundFn, Opaque, Frame, AnyFrame, Vector, EnumLiteral
+        | { name: string; child: TypeRef } // Optional
+        | { len: WalkResult; child: TypeRef } // Array
+        | { name: string; fields: { name: string; docs: string }[] } // ErrorSet
+        | { size: "One" | "Many" | "Slice" | "C"; child: TypeRef } // Pointer
+        | { name: string; src?: number; privDecls: number[]; pubDecls: number[]; fields?: TypeRef[] } // Struct, Enum, Union
+        | { name: string; src?: number; ret: TypeRef; params?: TypeRef[] } // Fn
+     )
+   } Type
+*/
+
+/**
+ * @typedef {{
+       name: string,
+       src: number | null,
+       ret: TypeRef,
+       params: TypeRef[] | null,
+   }} Fn
+*/
+
+/**
+ * @typedef {{
+       func: TypeRef,
+       args: WalkResult[],
+       ret: WalkResult,
+   }} Call
+*/
+
+/**
+ * @typedef {{
+       file: number,
+       line: number,
+       col: number,
+       name?: string,
+       docs?: string,
+       fields?: number[],
+       comptime: boolean,
+   }} AstNode
+*/
+
+/**
+ * @typedef {{
+      name: string,
+      kind: string,
+      src: number,
+      value: WalkResult,
+      decltest?: number,
+   }} Decl
+*/
+
+/**
+ * @typedef {{
+      name: string,
+      file: number,
+      main: number,
+      table: { root: number },
+   }} Package
+*/
+
+/**
+ * @typedef {{
+      name: string,
+      src?: number,
+      privDecls: number[],
+      pubDecls: number[],
+      fields?: TypeRef[],
+   }} Struct
+*/
+
+/**
+ * @typedef {{
+      len: WalkResult,
+      child: TypeRef,
+  }} ZigArray
+*/
+
+/**
+ * @typedef {{
+      code: string,
+      typeRef: TypeRef,
+   }} ComptimeExpr
+*/
+
+/**
+ * @typedef {{
+       typeKinds: TypeKind[];
+       rootPkg: number;
+       params: {
+           zigId: string;
+           zigVersion: string;
+           target: string;
+           rootName: string;
+           builds: { target: string };
+       };
+       packages: Package[];
+       errors: {};
+       astNodes: AstNode[];
+       calls: Call[];
+       files: Record<string, number>;
+       types: Type[];
+       decls: Decl[];
+       comptimeExprs: ComptimeExpr[];
+       fns: Fn[];
+   }} DocData
+*/
+
+/** @type {DocData} */
+var zigAnalysis;
+
 (function() {
     var domStatus = document.getElementById("status");
     var domSectNav = document.getElementById("sectNav");