Autodoc tokenizer (#16409)

* autodoc: init work to refactor exprName

* autodoc: Implement more expressions in exprName refactor

* autodoc: more work

* autodoc: More exprName to ex refactoring

* autodoc: Remove whitespace flag from renderer; Add pre tags in
value and variable drawing in renderContainer

* autodoc: add inline styling to pre blocks

* autodoc: move renderer code to main.js

* autodoc: More exprName to ex refactoring; Fn signatures rendered with new code

* autodoc: Fix function rendering. Add more things to ex

* autodoc: nuke exprName

---------

Co-authored-by: Krzysztof Wolicki <der.teufel.mail@gmail.com>
This commit is contained in:
Loris Cro 2023-07-14 16:27:09 +02:00 committed by GitHub
parent 3022c525ec
commit a187141056
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 1525 additions and 1691 deletions

View File

@ -297,6 +297,13 @@
overflow-x: auto;
}
.docs pre.inline {
background-color: var(--bg-color);
padding: 0;
display: inline;
}
.docs code {
font-family: var(--mono);
font-size: 1em;
@ -685,15 +692,23 @@
</style>
<style>
pre{
pre {
--zig-keyword: #333;
--zig-identifier: 'black';
--zig-builtin: #0086b3;
--zig-identifier: 'black';
--zig-string-literal: #d14;
--zig-type: #458;
--zig-fn: #900;
}
@media (prefers-color-scheme: dark) {
pre {
--zig-keyword: 'white';
--zig-identifier: 'purple';
--zig-keyword: #eee;
--zig-builtin: #ff894c;
--zig-identifier: 'purple';
--zig-string-literal: #2e5;
--zig-type: #68f;
--zig-fn: #e33;
}
}
@ -748,7 +763,7 @@
.zig_keyword_anytype,
.zig_keyword_fn
{
color: #333;
color: var(--zig-keyword);
font-weight: bold;
}
@ -757,12 +772,12 @@
.zig_multiline_string_literal_line,
.zig_char_literal
{
color: #d14;
color: var(--zig-string-literal);
}
.zig_builtin
{
color: #0086b3;
color: var(--zig-builtin);
}
.zig_doc_comment,
@ -772,15 +787,24 @@
}
.zig_identifier {
color: white;
color: var(--zig-identifier);
font-weight: bold;
}
.zig_number_literal {
color: #008080;
.zig_number_literal,
.zig_special {
color: #ff8080;
}
.zig_type {
color: var(--zig-type);
font-weight: bold;
}
.zig_fn {
color: var(--zig-fn);
font-weight: bold;
}
</style>
</head>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -814,6 +814,7 @@ const DocData = struct {
this: usize, // index in `types`
declRef: *Scope.DeclStatus,
declIndex: usize, // index into `decls`, alternative repr for `declRef`
declName: []const u8, // unresolved decl name
builtinField: enum { len, ptr },
fieldRef: FieldRef,
refPath: []Expr,
@ -2282,7 +2283,7 @@ fn walkInstruction(
var path: std.ArrayListUnmanaged(DocData.Expr) = .{};
try path.append(self.arena, .{
.string = file.zir.nullTerminatedString(extra.data.field_name_start),
.declName = file.zir.nullTerminatedString(extra.data.field_name_start),
});
// Put inside path the starting index of each decl name that
@ -2304,7 +2305,7 @@ fn walkInstruction(
);
try path.append(self.arena, .{
.string = file.zir.nullTerminatedString(lhs_extra.data.field_name_start),
.declName = file.zir.nullTerminatedString(lhs_extra.data.field_name_start),
});
}
};
@ -3665,7 +3666,7 @@ fn tryResolveRefPath(
var i: usize = 0;
outer: while (i < path.len - 1) : (i += 1) {
const parent = path[i];
const child_string = path[i + 1].string; // we expect to find a string union case
const child_string = path[i + 1].declName; // we expect to find an unsolved decl
var resolved_parent = parent;
var j: usize = 0;
@ -3738,14 +3739,14 @@ fn tryResolveRefPath(
return;
}
// If the last element is a string or a CTE, then we give up,
// If the last element is a declName or a CTE, then we give up,
// otherwise we resovle the parent to it and loop again.
// NOTE: we assume that if we find a string, it's because of
// a CTE component somewhere in the path. We know that the path
// is not pending futher evaluation because we just checked!
const last = rp[rp.len - 1];
switch (last) {
.comptimeExpr, .string => break :outer,
.comptimeExpr, .declName => break :outer,
else => {
resolved_parent = last;
continue;
@ -3772,7 +3773,7 @@ fn tryResolveRefPath(
"TODO: handle `{s}`in tryResolveRefPath\nInfo: {}",
.{ @tagName(resolved_parent), resolved_parent },
);
path[i + 1] = (try self.cteTodo("<match failure>")).expr;
// path[i + 1] = (try self.cteTodo("<match failure>")).expr;
continue :outer;
},
.comptimeExpr, .call, .typeOf => {