Skip to content
Jennifer Programming Language

docblock API reference

A Jennifer doc-comment parser. Read Jennifer source and return the documentation embedded in it as structured, typed values. It produces data; it does not render (turning docs into HTML is a separate consumer). A doc comment opens with a doc-block marker, and its body is a summary line, an optional description, and tag lines; it immediately precedes the construct it documents (func, def struct, def enum, def const) or, when it carries a module tag, is the file preamble. export is read from the construct keyword, not a tag. Types are written verbatim in Jennifer syntax inside braces. The module reports, never enforces: signature mismatches (a documented name that names no real parameter, a parameter with no doc) and orphaned comments surface as Diagnostic values, and the caller decides what is fatal.

Import with import "docblock.j" as docblock;. See the docblock guide for prose and examples.

Contents

NameWhat it is
parseRead Jennifer source and return a FileDoc: the module preamble, one doc per func / struct / const, and any ...
ConstDocstruct: The documentation of one constant.
Diagnosticstruct: A reported documentation problem (a mismatch or an orphaned comment).
EnumDocstruct: The documentation of one enum (sum type).
FileDocstruct: The full documentation extracted from one source file.
FuncDocstruct: The documentation of one function.
ModuleDocstruct: The module preamble documentation (the doc comment carrying a module tag).
ParamDocstruct: One documented parameter or struct field.
ReturnDocstruct: A documented return value.
StructDocstruct: The documentation of one struct.
ThrowDocstruct: A documented thrown error.

Functions

parse

jennifer
docblock.parse(source as string)

Read Jennifer source and return a FileDoc: the module preamble, one doc per func / struct / const, and any diagnostics (mismatched or orphaned doc comments). It reports; it does not fail on a documentation error.

source
the Jennifer source text to parse
Returns FileDoc
the extracted documentation tree

Structs

ConstDoc

The documentation of one constant.

jennifer
def struct ConstDoc {
    name as string,
    exported as bool,
    type as string,
    summary as string,
    description as string,
    since as string,
    deprecated as string,
    see as list of string,
    internal as bool
};
name
the constant name
exported
whether the constant is exported
type
the declared type, verbatim in Jennifer syntax
summary
the summary (its first paragraph)
description
the description (the paragraphs after the summary)
since
the documented since-version
deprecated
the deprecation note, or "" if not deprecated
see
the cross-references
internal
whether the constant is marked internal

Diagnostic

A reported documentation problem (a mismatch or an orphaned comment).

jennifer
def struct Diagnostic {
    severity as string,
    line as int,
    message as string
};
severity
the level, currently always "warning"
line
the source line the doc comment documents
message
the human-readable description of the problem

EnumDoc

The documentation of one enum (sum type). Enum variants are described in the summary / description prose rather than with per-variant tags, so an EnumDoc carries no field list.

jennifer
def struct EnumDoc {
    name as string,
    exported as bool,
    summary as string,
    description as string,
    since as string,
    deprecated as string,
    see as list of string,
    internal as bool
};
name
the enum name
exported
whether the enum is exported
summary
the summary (its first paragraph)
description
the description (the paragraphs after the summary)
since
the documented since-version
deprecated
the deprecation note, or "" if not deprecated
see
the cross-references
internal
whether the enum is marked internal

FileDoc

The full documentation extracted from one source file.

jennifer
def struct FileDoc {
    module as ModuleDoc,
    funcs as list of FuncDoc,
    structs as list of StructDoc,
    enums as list of EnumDoc,
    consts as list of ConstDoc,
    diagnostics as list of Diagnostic
};
module
the module preamble documentation
funcs
the documented functions
structs
the documented structs
enums
the documented enums (sum types)
consts
the documented constants
diagnostics
the reported documentation problems

FuncDoc

The documentation of one function.

jennifer
def struct FuncDoc {
    name as string,
    exported as bool,
    summary as string,
    description as string,
    params as list of ParamDoc,
    returns as ReturnDoc,
    throws as list of ThrowDoc,
    examples as list of string,
    since as string,
    deprecated as string,
    see as list of string,
    internal as bool
};
name
the function name
exported
whether the function is exported
summary
the summary (its first paragraph)
description
the description (the paragraphs after the summary)
params
the documented parameters
returns
the documented return value
throws
the documented thrown errors
examples
the documented examples
since
the documented since-version
deprecated
the deprecation note, or "" if not deprecated
see
the cross-references
internal
whether the function is marked internal

ModuleDoc

The module preamble documentation (the doc comment carrying a module tag).

jennifer
def struct ModuleDoc {
    summary as string,
    description as string,
    author as string,
    version as string,
    license as string,
    deprecated as string,
    see as list of string
};
summary
the summary (its first paragraph)
description
the description (the paragraphs after the summary)
author
the documented author
version
the documented version
license
the documented license
deprecated
the deprecation note, or "" if the module is not deprecated
see
the cross-references

ParamDoc

One documented parameter or struct field.

jennifer
def struct ParamDoc {
    name as string,
    type as string,
    description as string
};
name
the parameter or field name
type
the declared type, verbatim in Jennifer syntax
description
the prose description

ReturnDoc

A documented return value.

jennifer
def struct ReturnDoc {
    type as string,
    description as string
};
type
the returned type, verbatim in Jennifer syntax
description
the prose description

StructDoc

The documentation of one struct.

jennifer
def struct StructDoc {
    name as string,
    exported as bool,
    summary as string,
    description as string,
    fields as list of ParamDoc,
    since as string,
    deprecated as string,
    see as list of string,
    internal as bool
};
name
the struct name
exported
whether the struct is exported
summary
the summary (its first paragraph)
description
the description (the paragraphs after the summary)
fields
the documented fields
since
the documented since-version
deprecated
the deprecation note, or "" if not deprecated
see
the cross-references
internal
whether the struct is marked internal

ThrowDoc

A documented thrown error.

jennifer
def struct ThrowDoc {
    type as string,
    description as string
};
type
the thrown type, verbatim in Jennifer syntax
description
the prose description