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.
Functions
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.
Parameters
source{string}- the Jennifer source text to parse
Returns {FileDoc} - the extracted documentation tree
Structs
docblock.ConstDoc
The documentation of one constant.
| Field | Type | Description |
|---|---|---|
name | string | the constant name |
exported | bool | whether the constant is exported |
type | string | the declared type, verbatim in Jennifer syntax |
summary | string | the summary (its first paragraph) |
description | string | the description (the paragraphs after the summary) |
since | string | the documented since-version |
deprecated | string | the deprecation note, or "" if not deprecated |
see | list of string | the cross-references |
internal | bool | whether the constant is marked internal |
docblock.Diagnostic
A reported documentation problem (a mismatch or an orphaned comment).
| Field | Type | Description |
|---|---|---|
severity | string | the level, currently always "warning" |
line | int | the source line the doc comment documents |
message | string | the human-readable description of the problem |
docblock.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.
| Field | Type | Description |
|---|---|---|
name | string | the enum name |
exported | bool | whether the enum is exported |
summary | string | the summary (its first paragraph) |
description | string | the description (the paragraphs after the summary) |
since | string | the documented since-version |
deprecated | string | the deprecation note, or "" if not deprecated |
see | list of string | the cross-references |
internal | bool | whether the enum is marked internal |
docblock.FileDoc
The full documentation extracted from one source file.
| Field | Type | Description |
|---|---|---|
module | ModuleDoc | the module preamble documentation |
funcs | list of FuncDoc | the documented methods |
structs | list of StructDoc | the documented structs |
enums | list of EnumDoc | the documented enums (sum types) |
consts | list of ConstDoc | the documented constants |
diagnostics | list of Diagnostic | the reported documentation problems |
docblock.FuncDoc
The documentation of one method.
| Field | Type | Description |
|---|---|---|
name | string | the method name |
exported | bool | whether the method is exported |
summary | string | the summary (its first paragraph) |
description | string | the description (the paragraphs after the summary) |
params | list of ParamDoc | the documented parameters |
returns | ReturnDoc | the documented return value |
throws | list of ThrowDoc | the documented thrown errors |
examples | list of string | the documented examples |
since | string | the documented since-version |
deprecated | string | the deprecation note, or "" if not deprecated |
see | list of string | the cross-references |
internal | bool | whether the method is marked internal |
docblock.ModuleDoc
The module preamble documentation (the doc comment carrying a module tag).
| Field | Type | Description |
|---|---|---|
summary | string | the summary (its first paragraph) |
description | string | the description (the paragraphs after the summary) |
author | string | the documented author |
version | string | the documented version |
license | string | the documented license |
see | list of string | the cross-references |
docblock.ParamDoc
One documented parameter or struct field.
| Field | Type | Description |
|---|---|---|
name | string | the parameter or field name |
type | string | the declared type, verbatim in Jennifer syntax |
description | string | the prose description |
docblock.ReturnDoc
A documented return value.
| Field | Type | Description |
|---|---|---|
type | string | the returned type, verbatim in Jennifer syntax |
description | string | the prose description |
docblock.StructDoc
The documentation of one struct.
| Field | Type | Description |
|---|---|---|
name | string | the struct name |
exported | bool | whether the struct is exported |
summary | string | the summary (its first paragraph) |
description | string | the description (the paragraphs after the summary) |
fields | list of ParamDoc | the documented fields |
since | string | the documented since-version |
deprecated | string | the deprecation note, or "" if not deprecated |
see | list of string | the cross-references |
internal | bool | whether the struct is marked internal |
docblock.ThrowDoc
A documented thrown error.
| Field | Type | Description |
|---|---|---|
type | string | the thrown type, verbatim in Jennifer syntax |
description | string | the prose description |