Skip to content
internal/extractors/zig
On this page

Reading Zig source: the public declarations a file exports, their doc comments and their test blocks, grouped into a reference page by declaration kind.

#internal/extractors/zig

#internal/extractors/zig

Package zig reads Zig source for selfdoc.

It answers directives by scanning source text with regular expressions rather than by parsing it: no Zig toolchain is required, and a file that does not compile still documents. What it reads out of a file is the module's //! documentation, the public declarations -- functions including the extern, export and inline forms, constants whatever their right side is, and variables -- with the /// comment block above each, the fields of a public struct, and the file's test blocks.

#New

Go go
func New() extractors.Extractor

New builds the Zig extractor. It spawns nothing and writes nothing, it only reads source files.

#extractor.Detect

Go go
func (e *extractor) Detect(dir string) bool

Detect reports whether dir is a Zig project, by its build script or that script's dependency manifest.

#extractor.ResolvePath

Go go
func (e *extractor) ResolvePath(pathArg string, sourcePaths []string, baseDir string) string

ResolvePath resolves a directive's path argument to a Zig source file or to a directory of them.

#extractor.FileExtensions

Go go
func (e *extractor) FileExtensions() []string

FileExtensions lists the extensions the build walks a Zig source tree for.

#extractor.PublicSymbols

Go go
func (e *extractor) PublicSymbols(file string) ([]string, error)

PublicSymbols lists the public declarations of a Zig source file, in source order.

A private declaration -- one without "pub" -- is not public API and is not reported, and neither is a test block.

#extractor.ModuleDocstring

Go go
func (e *extractor) ModuleDocstring(path string) (string, error)

ModuleDocstring is a file's //! module documentation.

#extractor.SymbolDetails

Go go
func (e *extractor) SymbolDetails(file, symbol string) (*extractors.SymbolDetails, error)

SymbolDetails reports what a file says about one function's parameters and return value. A dotted name selects a member of a container type ("Config.init").

Search