Zig.Doc (zigler v0.9.1) View Source

Translates the docstrings from your Zig code into Elixir documentation.

For instructions on how to incorporate this into an Elixir project, consult Mix.Tasks.ZigDoc

Documentation forms

Currently, Zigler recognizes four types of code segments which should be documented.

  • functions
  • types
  • values
  • errors


functions have the following signature:

pub fn <identifier>(<arguments>) <type> {

and may have the property of being comptime which is due to either the function being itself a comptime function or it having a comptime argument.

NB only pub functions are documented in Zigler, following the Elixir philosophy that only public functions should be documented.


types have the following signature:

pub const <identifier>=<value>;


values can have one of the following signatures:

  • pub const <identifier>=<value>;
  • pub var <identifier>=<value>;

Note that the constant value form is indistinguishable from the type form without doing a full parse and evaluation of the Zig code. In order to avoid doing this, to disambiguate between the two, you must prepend constant value docststrings with a !value token.


/// !value
/// a constant representing the value 47.
pub const fortyseven = 47;


errors appear inside special error struct and should be documented at the per-value level:


/// docstring for this error struct (if desired)
pub const my_error = error {
  /// docstring for ErrorEnum1

  /// docstring for ErrorEnum2


This module will generate documentation from all Zig code that resides in the same code directory as the base module (or overridden directory, if applicable). Zig code in subdirectories will not be subjected to document generation.