ZigDoc (Single-page example)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is ZigDoc itself. Public Index

ZigDoc

File

extract.zig

Builds a model.DocTree from a Zig source file via std.zig.Ast, including same-file codelink resolution (codelinks) while the Ast is alive.

File

extract.zig
Public Function

deinit

pub fn deinit(self: PendingCodelink, gpa: std.mem.Allocator) void

File

extract.zig:17
Public Function

deinit

pub fn deinit(self: ResolvedCodelinks, gpa: std.mem.Allocator) void

File

extract.zig:29
Public Union

Binding

pub const Binding = union(enum)

A binding in scope: a same-file member or an import alias.

File

extract.zig:38
Public Struct

BoundName

pub const BoundName = struct

A binding plus the byte range of its own declaration name token, so the resolver can recognize a declaration site vs. a use.

File

extract.zig:45
Public Struct

ScopeFrame

pub const ScopeFrame = struct

A byte range over which bindings are in effect. Searched innermost-first.

File

extract.zig:53
Public Function

buildFileScopes

pub fn buildFileScopes(
        gpa: std.mem.Allocator,
        tree: Ast,
        members: []const Ast.Node.Index,
        parentPath: []const u8,
        rangeStart: u32,
        rangeEnd: u32,
        frames: *std.ArrayList(ScopeFrame),
    ) std.mem.Allocator.Error!void

Builds the scope frame stack for a container's Ast region: a root frame of members' bindings and imports scoped to [rangeStart, rangeEnd), plus one child frame per nested container or function. parentPath is the dotted path prefix for members.

The range matters: without it, two sibling containers declaring the same-named local (common with const BitSet = ...; across generic containers) would have both bindings compete for every use of that name in the whole file.

File

extract.zig:68
Public Function

freeScopeFrames

pub fn freeScopeFrames(gpa: std.mem.Allocator, frames: *std.ArrayList(ScopeFrame)) void

Frees every frame's bindings, including owned strings.

File

extract.zig:293
Public Function

resolveCodelinksForFile

pub fn resolveCodelinksForFile(gpa: std.mem.Allocator, tree: Ast, frames: []const ScopeFrame) !ResolvedCodelinks

Like resolveCodelinksForDecl, scoped to the entire file (byte range [0, tree.source.len)) rather than one decl — for a whole-file wrapper Section whose own source is the full file, not a decl's trimmed slice. Returned offsets are absolute (relative to byte 0).

File

extract.zig:312
Public Function

resolveCodelinksForDecl

pub fn resolveCodelinksForDecl(
        gpa: std.mem.Allocator,
        tree: Ast,
        declStartByte: u32,
        declEndByte: u32,
        frames: []const ScopeFrame,
    ) !ResolvedCodelinks

Resolves every identifier use within declNode's source span against frames. Returned offsets are relative to declStartByte.

File

extract.zig:318
Public Constant

ExtractError

pub const ExtractError = error

Errors surfaced while extracting a DocTree from source.

File

extract.zig:558
Public Struct

DocCommentResult

pub const DocCommentResult = struct

Result of extractDocComment/extractFieldDocComment: the joined comment text, and whether it came from extractPlainCommentFallback rather than a real /// doc comment.

File

extract.zig:563
Public Function

parseImportTargets

pub fn parseImportTargets(gpa: std.mem.Allocator, source: [:0]const u8) ExtractError![]ImportRef

Parses source and returns the @import targets referenced by its top-level decls, without building a DocTree. Used by import-graph discovery to find edges before deciding whether a file is worth extracting at all.

File

extract.zig:572
Public Function

freeImportTargets

pub fn freeImportTargets(gpa: std.mem.Allocator, refs: []ImportRef) void

Frees a slice returned by importTargets/parseImportTargets.

File

extract.zig:581
Public Function

extractFile

pub fn extractFile(
    gpa: std.mem.Allocator,
    moduleName: []const u8,
    sourcePath: []const u8,
    source: [:0]const u8,
    recursive: bool,
    extras: bool,
    collectTests: bool,
) ExtractError!model.DocTree

Parses source and extracts a DocTree for moduleName. sourcePath is recorded on each Section verbatim, shown to the reader as-is — pass a document-root-relative path, not a raw CLI path.

File

extract.zig:592
Public Function

collectTestSource

pub fn collectTestSource(gpa: std.mem.Allocator, tree: Ast, members: []const Ast.Node.Index) ![]const u8

Collects every top-level test { ... } block's verbatim source, concatenated in source order with a blank line between blocks.

File

extract.zig:652
Public Function

extractModuleDocComment

pub fn extractModuleDocComment(gpa: std.mem.Allocator, tree: Ast) !?[]const u8

Collects leading //! lines at the top of the file, if present.

File

extract.zig:666
Public Struct

FieldsParamsErrors

pub const FieldsParamsErrors = struct

The parts of a Section that come from a struct/union/fn decl's own members: fields, params, error-set members, and whether a fields-less struct downgrades to .namespace_decl (never for a union). Shared by collectMembers and imports.buildSection.

File

extract.zig:682
Public Function

collectFieldsParamsErrors

pub fn collectFieldsParamsErrors(
    gpa: std.mem.Allocator,
    tree: Ast,
    kind: model.Kind,
    fnNode: Ast.Node.Index,
    containerNodes: ?[]const Ast.Node.Index,
    declStartByte: u32,
    extras: bool,
    allowNamespaceDowngrade: bool,
) !FieldsParamsErrors

fnNode is the decl's own content node — used for .fn_decl params and errors, and for the standalone-error-set check; ignored otherwise. containerNodes, when given, is fnNode's struct/union member nodes. allowNamespaceDowngrade is false for a type function's returned container, which keeps its own declared kind rather than downgrading.

File

extract.zig:695
Public Function

collectFields

pub fn collectFields(gpa: std.mem.Allocator, tree: Ast, members: []const Ast.Node.Index, declStartByte: u32) ![]model.Field

Collects a container's field nodes into Fields, in source order.

File

extract.zig:815
Public Function

collectParams

pub fn collectParams(gpa: std.mem.Allocator, tree: Ast, node: Ast.Node.Index, declStartByte: u32) ![]model.Param

Collects a fn_decl/fn_proto* node's parameters into Params.

File

extract.zig:888
Public Function

isErrorSetDecl

pub fn isErrorSetDecl(tree: Ast, node: Ast.Node.Index) bool

Whether a top-level member is a standalone named error-set decl (pub const MyErrors = error{...};).

File

extract.zig:929
Public Function

collectStandaloneErrorSet

pub fn collectStandaloneErrorSet(gpa: std.mem.Allocator, tree: Ast, node: Ast.Node.Index) ![]model.ErrorMember

Collects a standalone error-set decl's own members (error{ A, B }) into ErrorMembers.

File

extract.zig:937
Public Function

collectFnErrors

pub fn collectFnErrors(gpa: std.mem.Allocator, tree: Ast, node: Ast.Node.Index) ![]model.ErrorMember

Resolves a function's declared error-union return type (MyError!void) to its error-set decl and collects its members. Returns empty for an inferred error union (bare !T) or a plain return type with no !.

File

extract.zig:947
Public Function

declLine

pub fn declLine(tree: Ast, token: Ast.TokenIndex) u32

Returns the 1-based source line a token starts on. tokenLocation's .line is 0-indexed, hence + 1.

File

extract.zig:1015
Public Function

containerMembers

pub fn containerMembers(gpa: std.mem.Allocator, tree: Ast, node: Ast.Node.Index) !?[]const Ast.Node.Index

Returns the member node list of a container-typed decl's initializer (struct/enum/union body), if the decl's value is itself a container. Copies members into a newly allocated slice (caller frees), since fullContainerDecl's compact form may borrow from scratch space.

File

extract.zig:1038
Public Function

hasFieldMember

pub fn hasFieldMember(tree: Ast, members: []const Ast.Node.Index) bool

Whether any of members is a struct/union field, independent of --extras. Zig's convention for a real data type vs. a namespace.

File

extract.zig:1061
Public Struct

ImportRef

pub const ImportRef = struct

A top-level const/var decl whose initializer is @import("target").

File

extract.zig:1069
Public Function

importTargets

pub fn importTargets(gpa: std.mem.Allocator, tree: Ast, members: []const Ast.Node.Index) ![]ImportRef

Scans members for decls initialized by an @import(...) call and returns one ImportRef per match, in declaration order.

File

extract.zig:1078
Public Function

containerKind

pub fn containerKind(tree: Ast, containerNode: Ast.Node.Index) ?model.Kind

Classifies a container node (struct/union/enum/opaque) by its keyword token.

File

extract.zig:1135
Public Function

declKind

pub fn declKind(tree: Ast, node: Ast.Node.Index) model.Kind

File

extract.zig:1147
Public Function

isPubDecl

pub fn isPubDecl(tree: Ast, node: Ast.Node.Index) bool

Whether a top-level container member is marked pub.

File

extract.zig:1162
Public Function

extractDocComment

pub fn extractDocComment(gpa: std.mem.Allocator, tree: Ast, nameToken: Ast.TokenIndex, isPub: bool) !?DocCommentResult

Collects contiguous /// lines immediately preceding a declaration. isPub: when false and none found, falls back to a leading // comment.

File

extract.zig:1172
Public Function

extractSignature

pub fn extractSignature(gpa: std.mem.Allocator, tree: Ast, node: Ast.Node.Index) ![]const u8

Renders a decl's signature: its source span up to the body's {.

File

extract.zig:1244
Public Function

sliceForNode

pub fn sliceForNode(tree: Ast, node: Ast.Node.Index) []const u8

Returns the full source slice spanned by node, including leading indentation on the first token's line.

File

extract.zig:1253
Public Function

lineStart

pub fn lineStart(source: [:0]const u8, pos: usize) usize

Walks back from pos over spaces/tabs to the start of the indentation on that line, stopping at a newline or byte 0.

File

extract.zig:1273
File

bare_function.zig

Simple module with one documented function.

File

fixtures/bare_function.zig
Public Function

add

pub fn add(a: i32, b: i32) i32

Adds two integers.

File

fixtures/bare_function.zig:4
File

documented_struct.zig

Module exposing a single documented struct.

File

fixtures/documented_struct.zig
Public Struct

Point

pub const Point = struct

A point in 2D space.

File

fixtures/documented_struct.zig:4
File

generic_container.zig

A generic container type, in its own file, instantiated directly by the root. Its returned struct and that struct's own methods must stay inlined on whichever page instantiates it — none of them is an @import boundary in its own right.

File

fixtures/generic_container.zig
Public Function

Container

pub fn Container(comptime T: type) type

Generic container over T.

File

fixtures/generic_container.zig:7
File

generic_container_root.zig

Root module that instantiates a generic type imported from another file. Box is not an @import boundary itself (it's an ordinary decl on this page); its body's real sourceFile is the imported file, not this one.

File

fixtures/generic_container_root.zig
Public Constant

Box

pub const Box = generic_container.Container(u32)

Instantiated container of u32.

File

fixtures/generic_container_root.zig:9
Public Namespace

Plain

pub const Plain = struct

An ordinary same-file struct, for contrast.

File

fixtures/generic_container_root.zig:12
Public Function

touch

pub fn touch(self: Plain) void

A same-file method.

File

fixtures/generic_container_root.zig:14
Public Struct

T

pub const T = struct

A real decl whose bare name collides with the generic container's own comptime T: type parameter, over in generic_container.zig. That parameter must never itself resolve to a link (it shadows, it isn't a decl) — this collision is what let it fall through to this decl's bare-name table entry instead and render as a dead self-link in Container's own signature.

File

fixtures/generic_container_root.zig:25
File

import_graph_child.zig

Leaf module with no further imports.

File

fixtures/import_graph_child.zig
Public Function

greet

pub fn greet() void

A documented function.

File

fixtures/import_graph_child.zig:4
File

import_graph_diamond_left.zig

Left branch of a diamond import.

File

fixtures/import_graph_diamond_left.zig
Public Constant

shared

pub const shared = @import("import_graph_shared.zig")

File

fixtures/import_graph_diamond_left.zig:2
File

import_graph_diamond_right.zig

Right branch of a diamond import.

File

fixtures/import_graph_diamond_right.zig
Public Constant

shared

pub const shared = @import("import_graph_shared.zig")

File

fixtures/import_graph_diamond_right.zig:2
File

import_graph_root.zig

Root of a small import graph fixture.

File

fixtures/import_graph_root.zig
Public Constant

child

pub const child = @import("import_graph_child.zig")

File

fixtures/import_graph_root.zig:2
Public Constant

left

pub const left = @import("import_graph_diamond_left.zig")

File

fixtures/import_graph_root.zig:3
Public Constant

right

pub const right = @import("import_graph_diamond_right.zig")

File

fixtures/import_graph_root.zig:4
Public Function

ownDecl

pub fn ownDecl() void

Declared directly on the root, not via an import.

File

fixtures/import_graph_root.zig:7
File

import_graph_shared.zig

Reached from two different import sites; must appear once.

File

fixtures/import_graph_shared.zig
Public Function

common

pub fn common() void

Reached via two paths from root.

File

fixtures/import_graph_shared.zig:4
File

many_small_containers.zig

Module with several small sibling structs, each holding its own nested decls, to exercise the compact two-member container shape repeatedly and at some depth.

File

fixtures/many_small_containers.zig
Public Namespace

Alpha

pub const Alpha = struct

First small container.

File

fixtures/many_small_containers.zig:6
Public Constant

one

pub const one = 1

A constant on Alpha.

File

fixtures/many_small_containers.zig:8
Public Constant

two

pub const two = 2

Another constant on Alpha.

File

fixtures/many_small_containers.zig:10
Public Namespace

Beta

pub const Beta = struct

Second small container.

File

fixtures/many_small_containers.zig:14
Public Function

double

pub fn double(x: i32) i32

A function on Beta.

File

fixtures/many_small_containers.zig:16
Public Namespace

Gamma

pub const Gamma = struct

Third small container, nested two levels deep.

File

fixtures/many_small_containers.zig:22
Public Namespace

Delta

pub const Delta = struct

Nested inside Gamma.

File

fixtures/many_small_containers.zig:24
Public Constant

value

pub const value = 3

A constant on Delta.

File

fixtures/many_small_containers.zig:26
Public Function

triple

pub fn triple(x: i32) i32

A function on Delta.

File

fixtures/many_small_containers.zig:28
File

markdown_doc_comment.zig

Module whose doc comments exercise the markdown dialect.

File

fixtures/markdown_doc_comment.zig
Public Function

format

pub fn format(value: i32) i32

Formats a value using std.fmt.

Supports:

  • integers
  • floats
  • strings

Example:

const s = format(42);

File

fixtures/markdown_doc_comment.zig:14
File

module_only.zig

A module with only a top-level doc comment and no public declarations.

File

fixtures/module_only.zig
File

nested_containers.zig

Module with a struct containing a nested struct.

File

fixtures/nested_containers.zig
Public Namespace

Outer

pub const Outer = struct

Outer container.

File

fixtures/nested_containers.zig:4
Public Namespace

Inner

pub const Inner = struct

Inner container, nested inside Outer.

File

fixtures/nested_containers.zig:6
Public Constant

value

pub const value = 42

A documented constant on the inner struct.

File

fixtures/nested_containers.zig:8
File

tz_repro.zig

The Time Zone Information Format (TZif) https://datatracker.ietf.org/doc/html/rfc8536

File

fixtures/tz_repro.zig
Public Struct

Transition

pub const Transition = struct

File

fixtures/tz_repro.zig:10
Public Struct

Timetype

pub const Timetype = struct

File

fixtures/tz_repro.zig:15
Public Function

name

pub fn name(self: *const Timetype) [:0]const u8

File

fixtures/tz_repro.zig:20
Public Function

isDst

pub fn isDst(self: Timetype) bool

File

fixtures/tz_repro.zig:24
Public Function

standardTimeIndicator

pub fn standardTimeIndicator(self: Timetype) bool

File

fixtures/tz_repro.zig:28
Public Function

utIndicator

pub fn utIndicator(self: Timetype) bool

File

fixtures/tz_repro.zig:32
Public Struct

Leapsecond

pub const Leapsecond = struct

File

fixtures/tz_repro.zig:37
Public Struct

Tz

pub const Tz = struct

File

fixtures/tz_repro.zig:42
Public Function

parse

pub fn parse(allocator: Allocator, reader: *Reader) !Tz

File

fixtures/tz_repro.zig:63
Public Function

deinit

pub fn deinit(self: *Tz) void

File

fixtures/tz_repro.zig:207
File

undocumented_decl.zig

Module with one undocumented function.

File

fixtures/undocumented_decl.zig
Public Function

bare

pub fn bare() void

File

fixtures/undocumented_decl.zig:3
File

imports.zig

Discovers a --discover ns doc tree by following @import(...) targets from a root file, then builds model.Sections from the resulting walk.Graph — resolving .alias decls (re-exports) to their real target's content, the way Zig's own Autodoc does.

File

imports.zig
Public Constant

WalkError

pub const WalkError = error

Errors surfaced while walking an import graph.

File

imports.zig:14
Public Struct

Reader

pub const Reader = struct

Reads a file's full contents into a null-terminated buffer, so walkTree can be tested against in-memory sources.

File

imports.zig:18
Public Function

walkDisk

pub fn walkDisk(
    gpa: std.mem.Allocator,
    io: std.Io,
    rootPath: []const u8,
    recursive: bool,
    extras: bool,
    collectTests: bool,
    progress: ?*progress_mod.Progress,
) WalkError!model.DocTree

Walks the whole import graph and builds a model.DocTree rooted at rootPath, nested rather than a flat sibling list. progress, if given, is updated during discovery and again before tree-building.

File

imports.zig:123
Public Function

walkTree

pub fn walkTree(
    gpa: std.mem.Allocator,
    reader: Reader,
    rootPath: []const u8,
    recursive: bool,
    extras: bool,
    collectTests: bool,
    progress: ?*progress_mod.Progress,
) WalkError!model.DocTree

Discovers every file reachable from rootPath via @import (already-visited targets, including cycles, aren't re-visited), parses+walks each into a shared walk.Graph, then builds a model.DocTree from the root file, recursively resolving .alias.

File

imports.zig:153
Public Function

resolveImport

pub fn resolveImport(gpa: std.mem.Allocator, importingFile: []const u8, importTarget: []const u8) ![]u8

Resolves an @import string against the importing file's own directory. Works equally on doc-root-relative display paths (as used by render.resolvePendingCodelinks) and on real disk paths (as used by discoverFile) — it's pure lexical path algebra, not filesystem access.

File

imports.zig:245
Public Function

isRelativeImport

pub fn isRelativeImport(target: []const u8) bool

Whether target is a relative .zig file path rather than a package name.

File

imports.zig:252
File

main.zig

CLI entry point: options parsing, progress reporting, extract, render, and write output.

File

main.zig
Public Namespace

options

pub const options = struct

File

main.zig:12
Public Enum

Format

pub const Format = enum

Output document format.

File

main.zig:14
Public Enum

Split

pub const Split = enum

Whether output is one file (none) or split per input file (file) or per item (item). --split ns is an accepted alias for file under --discover ns.

File

main.zig:17
Public Enum

SourceMode

pub const SourceMode = enum

How decl source is embedded in HTML output. md only supports none/inline_. tab requires --split item (page-level) or non-none split (page-source level).

File

main.zig:20
Public Enum

TestsMode

pub const TestsMode = enum

Same as SourceMode minus tab — used by --tests.

File

main.zig:22
Public Enum

CssMode

pub const CssMode = enum

Whether CSS is embedded in the output or written to a sibling file.

File

main.zig:24
Public Enum

Theme

pub const Theme = enum

Which color scheme the generated CSS uses. auto follows the OS.

File

main.zig:26
Public Enum

Collapse

pub const Collapse = enum

Which nested lists start collapsed. dir: --tree directory groups. ns: --discover ns per-file namespace roots. top: a page's outermost index list. all: everything collapsible. HTML-only.

File

main.zig:30
Public Enum

ItemOrder

pub const ItemOrder = enum

How sections are ordered, recursively at every nesting level.

File

main.zig:32
Public Enum

DirOrder

pub const DirOrder = enum

Where directories sort relative to files in index/nav listings.

File

main.zig:34
Public Enum

Discover

pub const Discover = enum

Which strategy finds the files to document: fs walks the filesystem, ns follows @import(...) from a root file.

File

main.zig:37
Public Enum

ShowFlag

pub const ShowFlag = enum

One category of content --show can turn on or off: file/linenum are a decl's source location, fields/parameters/errorsets are its own members, the rest list its children by kind as links. funcsigs is a rendering variant of functions (signature + doc comment instead of a plain link) and trumps it when both are shown; excluding functions always excludes funcsigs too — see parseShow.

File

main.zig:44
Public Enum

OmitDocFlag

pub const OmitDocFlag = enum

A listing category --omitdoc can mark link-less. functions/values decls each have their own page, so marking them also suppresses that page entirely, leaving just the name + doc comment shown in the parent's listing. fields, errors, and params never had a page of their own to begin with, so they're accepted for symmetry but change nothing.

File

main.zig:65
Public Constant

defaultHead

pub const defaultHead = "<link rel=\"shortcut icon\" href=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAARVBMVEVHcEwAAA0BAQKWWAH7lhH/qAHZ2tv6jwT////8xn9SMQSzbAL/ogj49/X92quSlZoIGzr91J780Jb7rUf+5sf/wwD91aGX+9VwAAAAAXRSTlMAQObYZgAAAMpJREFUeNql0ssSgyAMQFEeiYEQUVra///U1tKFRGeY2ruRxZmRR8xWJujK1XQVoL4CsQORVFnoNgJ0G4BOHEC9UxNHgO+ISqWteAAgntkLUK3lmWOZNRC262pZiO6figKS3BLC4pJQKyqA3k4hTNbjJSCIj9RAeiCKAiDJ+8RuA463tUAHhJ211jXwWbLsAXq3zNO7OYT2XZzHPeA1qFYeg+EvRpscHvOni/r/LcbPrQdGAz1yGuihPYKuC6AAnQbFfMsEJ1E2xpgXnRgXb8riHD8AAAAASUVORK5CYII=\" />"

Default --head value: a self-contained favicon <link> as a data URI.

File

main.zig:68
Public Struct

Options

pub const Options = struct

Resolved CLI configuration shared by the extractor, renderers, and build.zig integration.

File

main.zig:73
Public Function

shows

pub fn shows(opts: Options, flag: ShowFlag) bool

Whether flag is one of the categories --show turned on.

File

main.zig:178
Public Function

collectsExtras

pub fn collectsExtras(opts: Options) bool

Whether extraction should collect a struct/fn/error-set's own members at all — true if any of the three is shown.

File

main.zig:187
Public Enum

OmitKind

pub const OmitKind = enum

A decl kind excludable via --omitkind. No directory variant — directory headings are always structural, never a documented item.

File

main.zig:194
Public Constant

ParseError

pub const ParseError = std.mem.Allocator.Error

Allocator-failure-only error surfaced while parsing CLI arguments. Malformed input (unknown options/values, missing values, invalid combinations) is never fatal — it's recorded in Options.parseWarnings and a sane default is used instead.

File

main.zig:199
Public Function

parseArgs

pub fn parseArgs(gpa: std.mem.Allocator, args: []const []const u8) ParseError!Options

Parses CLI arguments (excluding argv[0]) into Options. Resolves source/filename defaults from the final --format once the whole argument list is read. Malformed input never fails parsing: it's recorded in the returned Options.parseWarnings and a sane default is substituted, so the caller can always proceed.

File

main.zig:205
Public Namespace

progress_mod

pub const progress_mod = struct

File

main.zig:560
Public Struct

Progress

pub const Progress = struct

File

main.zig:565
Public Function

update

pub fn update(self: *Progress, comptime fmt: []const u8, args: anytype) void

File

main.zig:568
Public Function

clear

pub fn clear(self: *Progress) void

File

main.zig:577
Public Function

main

pub fn main(init: std.process.Init) !void

Process entry point.

File

main.zig:587
File

Document.zig

An abstract tree representation of a Markdown document.

File

markdown/Document.zig
Public Struct

Node

pub const Node = struct

File

markdown/Document.zig:17
Public Enum

Index

pub const Index = enum(u32)

File

markdown/Document.zig:21
Public Constant

List

pub const List = std.MultiArrayList(Node)

File

markdown/Document.zig:25
Public Enum

Tag

pub const Tag = enum

File

markdown/Document.zig:27
Public Union

Data

pub const Data = union

File

markdown/Document.zig:72
Public Enum

ListStart

pub const ListStart = enum(u30)

The starting number of a list. This is either a number between 0 and 999,999,999, inclusive, or unordered to indicate an unordered list.

File

markdown/Document.zig:121
Public Function

asNumber

pub fn asNumber(start: ListStart) ?u30

File

markdown/Document.zig:129
Public Enum

TableCellAlignment

pub const TableCellAlignment = enum(u2)

File

markdown/Document.zig:136
Public Struct

Children

pub const Children = struct

Trailing: len times Node.Index

File

markdown/Document.zig:144
Public Enum

ExtraIndex

pub const ExtraIndex = enum(u32)

File

markdown/Document.zig:149
Public Enum

StringIndex

pub const StringIndex = enum(u32)

The index of a null-terminated string in string_bytes.

File

markdown/Document.zig:152
Public Function

deinit

pub fn deinit(doc: *Document, allocator: Allocator) void

File

markdown/Document.zig:157
Public Function

render

pub fn render(doc: Document, writer: *std.Io.Writer) std.Io.Writer.Error!void

Renders a document directly to a writer using the default renderer.

File

markdown/Document.zig:165
Public Function

ExtraData

pub fn ExtraData(comptime T: type) type

File

markdown/Document.zig:170
Public Function

extraData

pub fn extraData(doc: Document, comptime T: type, index: ExtraIndex) ExtraData(T)

File

markdown/Document.zig:174
Public Function

extraChildren

pub fn extraChildren(doc: Document, index: ExtraIndex) []const Node.Index

File

markdown/Document.zig:188
Public Function

string

pub fn string(doc: Document, index: StringIndex) [:0]const u8

File

markdown/Document.zig:193
File

Parser.zig

A Markdown parser producing Documents.

The parser operates at two levels: at the outer level, the parser accepts the content of an input document line by line and begins building the block structure of the document. This creates a stack of currently open blocks.

When the parser detects the end of a block, it closes the block, popping it from the open block stack and completing any additional parsing of the block's content. For blocks which contain parseable inline content, this invokes the inner level of the parser, handling the inline structure of the block.

Inline parsing scans through the collected inline content of a block. When it encounters a character that could indicate the beginning of an inline, it either handles the inline right away (if possible) or adds it to a pending inlines stack. When an inline is completed, it is added to a list of completed inlines, which (along with any surrounding text nodes) will become the children of the parent inline or the block whose inline content is being parsed.

File

markdown/Parser.zig
Public Function

init

pub fn init(allocator: Allocator) Allocator.Error!Parser

File

markdown/Parser.zig:182
Public Function

deinit

pub fn deinit(p: *Parser) void

File

markdown/Parser.zig:192
Public Function

feedLine

pub fn feedLine(p: *Parser, line: []const u8) Allocator.Error!void

Accepts a single line of content. line should not have a trailing line ending character.

File

markdown/Parser.zig:204
Public Function

endInput

pub fn endInput(p: *Parser) Allocator.Error!Document

Completes processing of the input and returns the parsed document.

File

markdown/Parser.zig:304
Public Function

extraData

pub fn extraData(p: Parser, comptime T: type, index: ExtraIndex) ExtraData(T)

File

markdown/Parser.zig:1583
Public Function

extraChildren

pub fn extraChildren(p: Parser, index: ExtraIndex) []const Node.Index

File

markdown/Parser.zig:1597
File

renderer.zig

Renders a Document to HTML or plain text.

File

markdown/renderer.zig
Public Function

Renderer

pub fn Renderer(comptime Context: type) type

A Markdown document renderer.

Each concrete Renderer type has a renderDefault function, with the intention that custom renderFn implementations can call renderDefault for node types for which they require no special rendering.

File

markdown/renderer.zig:17
Public Function

renderInlineNodeText

pub fn renderInlineNodeText(
    doc: Document,
    node: Node.Index,
    writer: *Writer,
) Writer.Error!void

Renders an inline node as plain text. Asserts that the node is an inline and has no non-inline children.

File

markdown/renderer.zig:194
Public Function

fmtHtml

pub fn fmtHtml(bytes: []const u8) std.fmt.Alt([]const u8, formatHtml)

File

markdown/renderer.zig:239
File

model.zig

Format-agnostic intermediate representation shared by all renderers.

File

model.zig
Public Enum

Kind

pub const Kind = enum

What kind of thing a Section documents. Directory headings are not a Kind — --tree grouping is synthesized from Section.fileLabel at render time.

File

model.zig:6
Public Struct

Field

pub const Field = struct

A struct/union field, extracted for --extras content.

File

model.zig:22
Public Struct

Param

pub const Param = struct

A function parameter, extracted for --extras content.

File

model.zig:43
Public Struct

ErrorMember

pub const ErrorMember = struct

One error set member, extracted for --extras content.

File

model.zig:58
Public Struct

CodelinkTarget

pub const CodelinkTarget = struct

One resolved identifier reference inside a Section's own source.

File

model.zig:64
Public Struct

PendingCodelinkTarget

pub const PendingCodelinkTarget = struct

A cross-file identifier reference whose target file is known but whose target Section.path isn't resolvable until the whole tree exists.

File

model.zig:73
Public Struct

Section

pub const Section = struct

A single extracted declaration, plus its nested children.

File

model.zig:83
Public Function

anchorSlug

pub fn anchorSlug(self: Section, gpa: std.mem.Allocator) ![]u8

HTML id / md fragment anchor for this section.

File

model.zig:152
Public Function

anchorSlugMd

pub fn anchorSlugMd(self: Section, gpa: std.mem.Allocator) ![]u8

Anchor slug for Markdown output.

File

model.zig:157
Public Function

fileStem

pub fn fileStem(self: Section, gpa: std.mem.Allocator) ![]u8

Filename stem for this section's page in split layout.

File

model.zig:162
Public Function

isWholeFileWrapper

pub fn isWholeFileWrapper(self: Section) bool

Whether this section's source/docComment/testSource describe a whole file.

File

model.zig:167
Public Function

slugifyMd

pub fn slugifyMd(gpa: std.mem.Allocator, path: []const u8) ![]u8

Like slugify but lowercases, matching Markdown's auto-generated heading anchors.

File

model.zig:172
Public Struct

DocTree

pub const DocTree = struct

A module's full set of extracted sections, ready for rendering.

File

model.zig:186
Public Function

deinit

pub fn deinit(self: *DocTree, gpa: std.mem.Allocator) void

Frees every allocation owned by this tree.

File

model.zig:207
Public Function

fileWrapperSection

pub fn fileWrapperSection(gpa: std.mem.Allocator, tree: DocTree, kind: Kind, displayName: []const u8, fileLabel: []const u8, locationPath: []const u8) !Section

Wraps one file's extracted DocTree as a synthetic top-level Section.

File

model.zig:235
Public Function

rawFileSection

pub fn rawFileSection(gpa: std.mem.Allocator, moduleName: []const u8, displayName: []const u8, rawLabel: []const u8, content: []const u8) !Section

Builds a synthetic per-file Section for a non-.zig input (--filetypes).

File

model.zig:273
Public Function

disambiguateSectionPaths

pub fn disambiguateSectionPaths(gpa: std.mem.Allocator, sections: []const Section) ![]Section

Detects path collisions among top-level file-kind sections and disambiguates them using their real fileLabel. Caller owns the returned slice.

File

model.zig:301
Public Function

freeDisambiguatedSections

pub fn freeDisambiguatedSections(gpa: std.mem.Allocator, sections: []Section, originals: []const Section) void

Frees a slice returned by disambiguateSectionPaths.

File

model.zig:344
Public Function

mergeTrees

pub fn mergeTrees(
    gpa: std.mem.Allocator,
    moduleName: []const u8,
    trees: []DocTree,
    labels: MergeLabels,
) !DocTree

Merges several file-level DocTrees into one, nesting each under a synthetic module section. Takes ownership of trees.

File

model.zig:366
Public Function

mergeNamespaceTrees

pub fn mergeNamespaceTrees(gpa: std.mem.Allocator, moduleName: []const u8, trees: []DocTree) !DocTree

Merges several --discover ns root DocTrees into one, nesting each under a synthetic Kind.namespace wrapper. Takes ownership of trees.

File

model.zig:396
Public Struct

MergeLabels

pub const MergeLabels = struct

How mergeTrees labels, kinds, and locates each merged tree's synthetic wrapper section.

File

model.zig:421
Public Function

fileDisplayName

pub fn fileDisplayName(gpa: std.mem.Allocator, rawLabel: []const u8, showExt: bool, showDirPrefix: bool) ![]u8

Formats a raw directory-relative label for display, per showExt/showDirPrefix.

File

model.zig:435
Public Function

stripZigExt

pub fn stripZigExt(name: []const u8) []const u8

Strips a trailing .zig extension, if present.

File

model.zig:452
Public Function

freeSection

pub fn freeSection(gpa: std.mem.Allocator, section: *Section) void

Recursively frees a section and its children.

File

model.zig:457
Public Enum

SectionOrder

pub const SectionOrder = enum

Mirrors options.ItemOrder; kept here to avoid a dependency on the CLI-parsing module.

File

model.zig:511
Public Enum

DirOrder

pub const DirOrder = enum

Mirrors options.DirOrder.

File

model.zig:514
Public Enum

OmitKind

pub const OmitKind = enum

Mirrors options.OmitKind.

File

model.zig:517
Public Enum

OmitDocFlag

pub const OmitDocFlag = enum

Mirrors options.OmitDocFlag, minus none (an empty excluded slice serves that role).

File

model.zig:538
Public Function

markOmitDoc

pub fn markOmitDoc(sections: []Section, excluded: []const OmitDocFlag) void

Marks docOnly on every function/value decl whose bucket is in excluded. Never deletes: the decl still gets a listing entry (name + doc comment, unlinked) in its parent's Functions/Values list. What disappears is the decl's own page/anchor and content block — nowhere to link it to, so nothing renders there (see Section.docOnly).

File

model.zig:545
Public Function

filterSections

pub fn filterSections(gpa: std.mem.Allocator, sections: *[]Section, excluded: []const OmitKind) !void

Recursively drops sections whose kind is in excluded. A dropped .file wrapper splices its children into its place; other kinds take their children with them. In-place.

File

model.zig:567
Public Function

filterPrivate

pub fn filterPrivate(gpa: std.mem.Allocator, sections: *[]Section) !void

Recursively drops sections whose isPub is false, along with their children. In-place.

File

model.zig:605
Public Function

filterEmpty

pub fn filterEmpty(gpa: std.mem.Allocator, sections: *[]Section) !void

Recursively drops a .file section once it has no doc comment and no children left. Never drops raw sections (--filetypes), which are always childless and doc-less.

File

model.zig:622
Public Function

sortSections

pub fn sortSections(sections: []Section, order: SectionOrder) void

Recursively sorts sections in place per order. code is a no-op (already AST order).

File

model.zig:638
Public Function

slugify

pub fn slugify(gpa: std.mem.Allocator, path: []const u8) ![]u8

Replaces non-alphanumeric bytes with "-", preserving "." as the path separator and case (HTML anchors are case-sensitive, unlike slugifyMd).

File

model.zig:658
Public Function

filenameSegment

pub fn filenameSegment(gpa: std.mem.Allocator, name: []const u8) ![]u8

Filesystem-safe form of a single decl name for a page filename or directory segment; case is preserved since Zig identifiers are case-sensitive.

File

model.zig:671
Public Function

avoidWindowsReservedName

pub fn avoidWindowsReservedName(gpa: std.mem.Allocator, segment: []u8) ![]u8

Appends a trailing "~" if segment case-insensitively matches a Windows-reserved name.

File

model.zig:689
Public Function

pageDepth

pub fn pageDepth(pagePath: []const u8) usize

Number of directory levels deep a page's output path sits.

File

model.zig:701
Public Function

relativeHref

pub fn relativeHref(gpa: std.mem.Allocator, fromPath: []const u8, toPath: []const u8, prettyUrls: bool) ![]u8

Builds a relative href from fromPath to toPath, both output-relative. Drops a trailing index.html when prettyUrls is set.

File

model.zig:711
Public Function

writePathLinksMd

pub fn writePathLinksMd(
    gpa: std.mem.Allocator,
    writer: *std.Io.Writer,
    path: []const u8,
    rootLen: usize,
    rootHref: ?[]const u8,
) !void

Writes path as Markdown with each dotted segment linked to its ancestor section's anchor.

File

model.zig:773
Public Function

writeIndexTree

pub fn writeIndexTree(
    sections: []const Section,
    prefixLen: usize,
    context: anytype,
    comptime onDir: fn (@TypeOf(context), []const u8) anyerror!void,
    comptime onLeaf: fn (@TypeOf(context), Section) anyerror!void,
    comptime onDirEnd: fn (@TypeOf(context)) anyerror!void,
) anyerror!void

Groups sections (sorted by fileLabel) into a directory tree for --tree index listings.

File

model.zig:809
Public Function

forEachDirGroup

pub fn forEachDirGroup(
    sections: []const Section,
    prefixLen: usize,
    context: anytype,
    comptime onDir: fn (@TypeOf(context), []const u8, []const Section) anyerror!void,
    comptime onLeaf: fn (@TypeOf(context), Section) anyerror!void,
) anyerror!void

Walks one level of sections, handing onDir the subdirectory's own slice — for callers that need to write that subdirectory's page too, not just link to it.

File

model.zig:844
Public Function

hasFileLabels

pub fn hasFileLabels(sections: []const Section) bool

File

model.zig:869
Public Function

lessByFileLabel

pub fn lessByFileLabel(_: void, a: Section, b: Section) bool

File

model.zig:876
Public Function

sortByFileLabelOrder

pub fn sortByFileLabelOrder(sections: []Section, order: DirOrder) void

Sorts sections by fileLabel so writeIndexTree/writeDirPages group correctly.

File

model.zig:881
Public Function

walk

pub fn walk(
    sections: []const Section,
    context: anytype,
    comptime visit: fn (@TypeOf(context), Section) anyerror!void,
) anyerror!void

Depth-first traversal of sections, calling visit on each node.

File

model.zig:921
Public Function

isPrimitiveTypeName

pub fn isPrimitiveTypeName(text: []const u8) bool

Whether text names a Zig primitive type (bool, f32, sized-int forms like u8/i32, etc). Primitives are never real decls, so a reference to one must never become a codelink.

File

model.zig:943
File

render.zig

Renders a DocTree into output Pages for a given --split mode and --format.

File

render.zig
Public Struct

Page

pub const Page = struct

One rendered output page.

File

render.zig:17
Public Function

deinit

pub fn deinit(self: *Page, gpa: std.mem.Allocator) void

File

render.zig:22
Public Function

freePages

pub fn freePages(gpa: std.mem.Allocator, pages: *std.ArrayList(Page)) void

File

render.zig:28
Public Enum

Format

pub const Format = enum

File

render.zig:33
Public Function

write

pub fn write(
    gpa: std.mem.Allocator,
    fmt: Format,
    tree: model.DocTree,
    title: []const u8,
    opts: options.Options,
    tplDoc: []const u8,
    tplSec: []const u8,
    reporter: *progress_mod.Progress,
) ![]Page

Renders tree into a set of Pages. Caller owns the result (freePages).

File

render.zig:91
Public Struct

Registry

pub const Registry = struct

Maps a file's fileLabel to the slug its page (and, under --split item, its decls' folder) is built from, resolving collisions with sibling files/directories. Built once per write() call so every page's filename agrees on where a file's page lives.

File

render.zig:726
Public Function

deinit

pub fn deinit(self: *Registry, gpa: std.mem.Allocator) void

File

render.zig:734
Public Function

slugFor

pub fn slugFor(self: Registry, fileLabel: []const u8) []const u8

Registered slug for fileLabel, or its .zig-stripped form if unregistered.

File

render.zig:756
Public Function

declSegmentFor

pub fn declSegmentFor(self: Registry, gpa: std.mem.Allocator, parentDeclPath: []const u8, name: []const u8) !?[]const u8

Registered path segment for name under parentDeclPath, or null if unseen (single-page mode).

File

render.zig:762
Public Function

slugForFileSection

pub fn slugForFileSection(self: Registry, gpa: std.mem.Allocator, section: model.Section) ![]u8

Registered slug for a top-level whole-file-wrapper section. Always freshly allocated, unlike slugFor.

File

render.zig:770
Public Function

buildRegistry

pub fn buildRegistry(gpa: std.mem.Allocator, sections: []const model.Section, fmt: Format, opts: options.Options) !Registry

Builds sections' Registry. Also walks into every decl's own children (whatever --split item's recursion will later append segments onto) so two sibling decls whose names only differ by case — a real collision on a case-insensitive filesystem — are resolved once, up front, the same way two files already are.

File

render.zig:787
Public Function

pageFilename

pub fn pageFilename(gpa: std.mem.Allocator, fmt: Format, section: model.Section, ownDeclPath: []const u8, opts: options.Options, registry: Registry) ![]u8

Output-relative path for a section's own page. A whole-file wrapper uses its registered slug as <slug>/index<ext> or <slug><ext> depending on opts.dirUrls. An item-kind section uses ownDeclPath directly, becoming a folder if it has children, else following opts.dirUrls like the file case.

File

render.zig:1195
Public Function

appendDeclPathSegment

pub fn appendDeclPathSegment(gpa: std.mem.Allocator, parentDeclPath: []const u8, name: []const u8, registry: Registry) ![]u8

Builds parentDeclPath's child path for name, preferring the registry's collision-resolved segment; falls back to computing one directly when unregistered (single-page mode).

File

render.zig:1212
Public Struct

FileRootIndex

pub const FileRootIndex = struct

Maps a file's sourceFile display path to its own file-root Section — a real one built by extraction, or a synthetic stand-in at virtualRoot for a root file with no wrapper of its own. byModuleName covers Zig's package-name self-import (@import("std") from inside std itself). byDottedPath covers --discover ns's alias shortcuts: a decl that's itself a cross-file re-export is built there as an empty stand-in carrying only aliasTargetPath. Pointers borrow from tree/virtualRoot; the index must not outlive either.

File

render.zig:1382
Public Function

deinit

pub fn deinit(self: *FileRootIndex) void

File

render.zig:1394
Public Function

buildFileRootIndex

pub fn buildFileRootIndex(gpa: std.mem.Allocator, tree: model.DocTree, virtualRoot: *model.Section) !FileRootIndex

File

render.zig:1403
Public Function

writeIndexItemOpen

pub fn writeIndexItemOpen(gpa: std.mem.Allocator, writer: *std.Io.Writer, section: model.Section, showPub: bool) !void

Writes an index <li>'s opening tag: item-<kind> class always, plus item-pub/item-priv and a prefix label for anything but a plain whole-file wrapper.

File

render.zig:2382
File

search.zig

Builds the --search feature's index: one entry per documented decl, giving the client-side script a name, breadcrumb path, resolved href, and plain-text doc comment without re-parsing rendered HTML.

File

search.zig
Public Struct

Entry

pub const Entry = struct

One search result's worth of data. href is root-relative, resolved by the client script against its own <script> tag's URL at runtime.

File

search.zig:11
Public Function

freeEntries

pub fn freeEntries(gpa: std.mem.Allocator, entries: []Entry) void

File

search.zig:25
Public Function

buildIndex

pub fn buildIndex(gpa: std.mem.Allocator, tree: model.DocTree, opts: options.Options) ![]Entry

Builds the full-site index for tree under opts. Assumes --format html. Caller owns the result (freeEntries).

File

search.zig:32
Public Function

normalizeWhitespace

pub fn normalizeWhitespace(gpa: std.mem.Allocator, md: []const u8) ![]u8

Collapses doc-comment whitespace to single spaces and trims the ends, leaving markdown syntax untouched.

File

search.zig:105
Public Constant

clientJs

pub const clientJs = @embedFile("assets/search.js")

--search on's client-side widget script, written unmodified to search.js.

File

search.zig:127
Public Function

toJs

pub fn toJs(gpa: std.mem.Allocator, entries: []const Entry) ![]u8

Serializes entries as window.ZDI = [...];, the content of search-index.js. Each entry is a positional 4-element array to keep the file small.

File

search.zig:131
File

sources.zig

Renders a decl's source as HTML, per options.SourceMode, syntax-highlighted via std.zig.Tokenizer. No JS: highlighting and the line-number gutter are pure CSS/HTML.

File

sources.zig
Public Struct

ResolvedSpan

pub const ResolvedSpan = struct

Resolves the identifier token starting at byte offset start to its documenting href, plus the byte offset one past the last token the resolved reference covers (a resolved reference can span multiple tokens, e.g. array_list.Aligned). Position-based rather than name-based, since the same identifier can resolve differently at different offsets (shadowing). Used only for tokenized source; prose uses ProseLinkResolver instead.

File

sources.zig:14
Public Struct

LinkResolver

pub const LinkResolver = struct

File

sources.zig:16
Public Function

resolve

pub fn resolve(self: LinkResolver, start: u32) ?ResolvedSpan

File

sources.zig:20
Public Struct

ProseLinkResolver

pub const ProseLinkResolver = struct

Resolves a bare identifier name (not a byte position) to an href, for doc-comment prose and other non-tokenized text with no source position to key off.

File

sources.zig:27
Public Function

resolve

pub fn resolve(self: ProseLinkResolver, name: []const u8) ?[]const u8

File

sources.zig:31
Public Function

write

pub fn write(gpa: std.mem.Allocator, writer: *std.Io.Writer, source: []const u8, mode: options.SourceMode, raw: bool, links: ?LinkResolver, startLine: u32) !void

Writes source as an HTML fragment matching mode. Always escapes. links, when given, wraps resolvable identifiers in a link (ignored when raw). startLine is the 1-based line the gutter should begin counting from. Callers should skip this entirely for binary content rather than pass it in.

File

sources.zig:40
Public Function

writeTokens

pub fn writeTokens(writer: *std.Io.Writer, source: [:0]const u8) !void

Writes source as highlighted, HTML-escaped Zig source using std.zig.Tokenizer. Never links identifiers — see writeTokensLinked for that.

File

sources.zig:121
Public Function

writeTokensLinked

pub fn writeTokensLinked(writer: *std.Io.Writer, source: [:0]const u8, links: ?LinkResolver) !void

Like writeTokens, but also links a resolvable identifier or string literal (an @import(...) target) to its docs. A resolved reference spanning multiple tokens (e.g. array_list.Aligned) is folded into a single <a>, each token still individually syntax-highlighted inside it.

File

sources.zig:129
Public Function

isFnNameToken

pub fn isFnNameToken(prevTag: ?std.zig.Token.Tag, nextTag: std.zig.Token.Tag) bool

Reports whether an identifier token is a function name: immediately preceded by the fn keyword (a declaration's own name) or immediately followed by ( (a call expression). nextTag is the very next token after the identifier — callers get it via a cloned tokenizer peek, since std.zig.Tokenizer.next() has no lookahead of its own. There's always a next token (.eof at worst), but prevTag is genuinely absent for the very first token in a source.

File

sources.zig:263
Public Function

classFor

pub fn classFor(tag: std.zig.Token.Tag, text: []const u8, isFnName: bool) ?[]const u8

Maps a token's tag and text to a CSS class, or null for tokens left unstyled. isFnName marks an identifier as a function name (declaration or call site) — callers with token-sequence context (see writeOneToken's caller) decide that and it overrides the default tok-id an identifier would otherwise get.

File

sources.zig:273
Public Function

writeEscaped

pub fn writeEscaped(writer: *std.Io.Writer, text: []const u8) !void

HTML-escapes <, >, and &.

File

sources.zig:287
Public Function

writeEscapedAttr

pub fn writeEscapedAttr(writer: *std.Io.Writer, text: []const u8) !void

HTML-escapes an attribute value: as writeEscaped, plus ".

File

sources.zig:299
File

style.zig

Default CSS shared by --css embed and --css external output.

File

style.zig
Public Function

css

pub fn css(gpa: std.mem.Allocator, opts: options.Options, theme: options.Theme) ![]u8

Default stylesheet. theme controls whether colors follow prefers-color-scheme (.auto) or are fixed. Only includes CSS chunks for features opts actually has enabled. Caller owns the returned slice.

File

style.zig:69
File

template.zig

A deliberately minimal templating engine: {variable} substitution and nothing else — no conditionals, no loops, no escaping syntax inside the template itself. Values are supplied pre-rendered (already HTML/Markdown, already escaped where the caller wants escaping) and substituted verbatim; the engine does no escaping of its own. A literal { not immediately followed by a known variable name and } is passed through unchanged (so templates can contain, say, a {} Zig snippet in a comment without the engine tripping over it — anything not exactly matching a provided key is left as-is rather than treated as an error).

A variable may also carry an inline format="..." attribute: {name format="<div>{name}</div>"}. When present and the variable's value is non-empty, the format string is rendered as a sub-template — name rebound to the raw value, every other variable still available — instead of substituting the raw value directly. An empty value renders the whole {name format="..."} span as nothing, same as an empty plain {name} would. Within the format string, \" and \n are unescaped before rendering, so a wrapper can embed quoted HTML attributes or a literal newline without breaking out of the tag's own quotes.

When render is given a padBlock (Markdown mode), literal newlines in the template source are stripped before parsing — so a .tpl file can wrap across lines for readability — and a bare \n outside any tag becomes a real newline in the output. A format="..." attribute's own \n/\" escapes are unaffected by this, since they're decoded separately once that attribute renders.

File

template.zig
Public Struct

Var

pub const Var = struct

One {name} → value substitution.

File

template.zig:32
Public Constant

PadBlockFn

pub const PadBlockFn = *const fn (std.mem.Allocator, []const u8) std.mem.Allocator.Error![]u8

A render's padBlock callback: pads a bare substitution's value for a particular output format's block conventions.

File

template.zig:74
Public Function

padMdBlock

pub fn padMdBlock(gpa: std.mem.Allocator, value: []const u8) std.mem.Allocator.Error![]u8

Pads value with a trailing newline if non-empty and not already terminated. Pass as render's padBlock for Markdown; null for HTML.

File

template.zig:78
Public Function

render

pub fn render(gpa: std.mem.Allocator, template: []const u8, vars: []const Var, padBlock: ?PadBlockFn) ![]u8

Renders template, replacing every matched {name}/{name format="..."} with its value. Unmatched spans are copied through unchanged. padBlock, when non-null, applies only to a bare {name} substitution, never one inside a format="..." string.

File

template.zig:145
Public Constant

htmlDoc

pub const htmlDoc = @embedFile("templates/htmldoc.tpl")

File

template.zig:197
Public Constant

htmlSec

pub const htmlSec = @embedFile("templates/htmlsec.tpl")

File

template.zig:199
Public Constant

mdDoc

pub const mdDoc = @embedFile("templates/mddoc.tpl")

File

template.zig:201
Public Constant

mdSec

pub const mdSec = @embedFile("templates/mdsec.tpl")

File

template.zig:203
File

test.zig

Integration tests: extract each fixture and exercise the split renderers' page/file-splitting logic. Templates (.tpl files) are user-overridable and may be blanked or rewritten arbitrarily, so no test may assume anything about what a template renders — assertions stick to page counts, .filename paths, tree/registry structure, and search.buildIndex entries (all computed independently of .tpl content), never Page.contents.

File

test.zig
File

walk.zig

A cross-file identifier/scope graph for --discover ns, ported from Zig's own Autodoc (lib/docs/wasm/{Walk,Decl}.zig). Parses every reachable file into one shared graph, resolves identifiers against per-file Scopes, and classifies each decl into a Category — including .alias, so a re-export resolves through to its real target decl rather than showing the one-line alias.

Renamed to this project's camelCase convention; index types are plain u32s into owned ArrayLists; no modules/multi-package support, no doctest extraction. Otherwise a close, node-tag-for-node-tag port.

File

walk.zig
Public Constant

Error

pub const Error = std.mem.Allocator.Error

File

walk.zig:14
Public Constant

AddFileError

pub const AddFileError = Error || error

Graph.addFile's own error set: allocation failure, or the source failed to parse as valid Zig.

File

walk.zig:17
Public Union

Category

pub const Category = union(enum)

What a decl's value expression resolves to. Mirrors Autodoc's own Category — keeps alias as a distinct case callers chase themselves via Decl.resolveAlias, since a decl's own identity is meaningful even when its content is an alias.

File

walk.zig:23
Public Struct

File

pub const File = struct

One parsed, walked file. Owns its own Ast and per-file resolution tables; does not own the Decls it contributes (those live in the shared Graph.decls).

File

walk.zig:49
Public Function

deinit

pub fn deinit(self: *File, gpa: std.mem.Allocator) void

File

walk.zig:65
Public Enum

Index

pub const Index = enum(u32)

File

walk.zig:75
Public Function

get

pub fn get(i: File.Index, graph: *const Graph) *File

File

walk.zig:78
Public Function

path

pub fn path(i: File.Index, graph: *const Graph) []const u8

File

walk.zig:82
Public Function

displayPath

pub fn displayPath(i: File.Index, gpa: std.mem.Allocator, graph: *const Graph) ![]u8

This file's path as it should be shown to a reader — relative to the root file's own directory, /-separated. Falls back to path verbatim if relative resolution fails.

File

walk.zig:89
Public Function

findRootDecl

pub fn findRootDecl(i: File.Index, graph: *const Graph) Decl.Index

File

walk.zig:95
Public Struct

Decl

pub const Decl = struct

File

walk.zig:102
Public Enum

Index

pub const Index = enum(u32)

File

walk.zig:109
Public Function

get

pub fn get(i: Decl.Index, graph: *const Graph) *Decl

File

walk.zig:113
Public Struct

ExtraInfo

pub const ExtraInfo = struct

File

walk.zig:118
Public Function

extraInfo

pub fn extraInfo(decl: *const Decl, graph: *const Graph) ExtraInfo

File

walk.zig:124
Public Function

categorize

pub fn categorize(decl: *const Decl, graph: *Graph) Error!Category

File

walk.zig:167
Public Function

resolveAliasIndex

pub fn resolveAliasIndex(index: Decl.Index, graph: *Graph) Error!struct

Follows .alias until a non-alias Category (or a cycle, guarded by Graph.maxAliasChase) is reached.

File

walk.zig:173
Public Function

getChild

pub fn getChild(decl: *const Decl, graph: *Graph, name: []const u8) Error!?Decl.Index

Looks up a direct child of decl by name — a member of its namespace/container, or (transparently) of whatever it's an alias for.

File

walk.zig:192
Public Function

children

pub fn children(decl: *const Decl, graph: *Graph, gpa: std.mem.Allocator) Error![]Decl.Index

Lists every direct child of decl's namespace/container, in source order — transparently chasing .alias first, same as getChild. Re-derives the member list directly from the container's own AST node, which preserves source order without scanning the whole graph's decl list.

File

walk.zig:211
Public Struct

Graph

pub const Graph = struct

The shared graph every walked file's decls live in. One Graph per --discover ns invocation.

File

walk.zig:261
Public Function

init

pub fn init(gpa: std.mem.Allocator) Graph

File

walk.zig:273
Public Function

deinit

pub fn deinit(self: *Graph) void

File

walk.zig:277
Public Function

addFile

pub fn addFile(self: *Graph, path: []const u8, source: [:0]const u8) AddFileError!File.Index

Parses source and walks its whole body, registering every decl and building this file's identifier/scope resolution tables. path is duplicated and owned by the graph. source itself is not retained past this call — this makes its own durable copy first and parses that.

File

walk.zig:292
Public Function

findFileByPath

pub fn findFileByPath(self: *const Graph, path: []const u8) ?File.Index

Finds a file already added to this graph by its resolved path, if any. Used to resolve @import("...") targets that were already discovered under a different import name/site.

File

walk.zig:324
Public Function

resolveImportString

pub fn resolveImportString(self: *const Graph, fromFile: File.Index, importString: []const u8) ?File.Index

Resolves a raw @import("importString") argument, as seen from fromFile, to the File.Index it targets. Returns null if the target isn't (yet, or ever) part of this graph.

File

walk.zig:334
Public Struct

Scope

pub const Scope = struct

A lexical scope during the walk: the top scope (file root), a local var/const binding, or a namespace (struct/union/enum/opaque body, including the file root once it's known to be one).

File

walk.zig:353
Public Function

getChild

pub fn getChild(scope: *Scope, name: []const u8) ?Ast.Node.Index

File

walk.zig:386
Public Function

lookup

pub fn lookup(startScope: *Scope, ast: *const Ast, name: []const u8) ?Ast.Node.Index

File

walk.zig:396