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.

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.

FieldTypeDescription
namestringthe constant name
exportedboolwhether the constant is exported
typestringthe declared type, verbatim in Jennifer syntax
summarystringthe summary (its first paragraph)
descriptionstringthe description (the paragraphs after the summary)
sincestringthe documented since-version
deprecatedstringthe deprecation note, or "" if not deprecated
seelist of stringthe cross-references
internalboolwhether the constant is marked internal

docblock.Diagnostic

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

FieldTypeDescription
severitystringthe level, currently always "warning"
lineintthe source line the doc comment documents
messagestringthe 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.

FieldTypeDescription
namestringthe enum name
exportedboolwhether the enum is exported
summarystringthe summary (its first paragraph)
descriptionstringthe description (the paragraphs after the summary)
sincestringthe documented since-version
deprecatedstringthe deprecation note, or "" if not deprecated
seelist of stringthe cross-references
internalboolwhether the enum is marked internal

docblock.FileDoc

The full documentation extracted from one source file.

FieldTypeDescription
moduleModuleDocthe module preamble documentation
funcslist of FuncDocthe documented methods
structslist of StructDocthe documented structs
enumslist of EnumDocthe documented enums (sum types)
constslist of ConstDocthe documented constants
diagnosticslist of Diagnosticthe reported documentation problems

docblock.FuncDoc

The documentation of one method.

FieldTypeDescription
namestringthe method name
exportedboolwhether the method is exported
summarystringthe summary (its first paragraph)
descriptionstringthe description (the paragraphs after the summary)
paramslist of ParamDocthe documented parameters
returnsReturnDocthe documented return value
throwslist of ThrowDocthe documented thrown errors
exampleslist of stringthe documented examples
sincestringthe documented since-version
deprecatedstringthe deprecation note, or "" if not deprecated
seelist of stringthe cross-references
internalboolwhether the method is marked internal

docblock.ModuleDoc

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

FieldTypeDescription
summarystringthe summary (its first paragraph)
descriptionstringthe description (the paragraphs after the summary)
authorstringthe documented author
versionstringthe documented version
licensestringthe documented license
seelist of stringthe cross-references

docblock.ParamDoc

One documented parameter or struct field.

FieldTypeDescription
namestringthe parameter or field name
typestringthe declared type, verbatim in Jennifer syntax
descriptionstringthe prose description

docblock.ReturnDoc

A documented return value.

FieldTypeDescription
typestringthe returned type, verbatim in Jennifer syntax
descriptionstringthe prose description

docblock.StructDoc

The documentation of one struct.

FieldTypeDescription
namestringthe struct name
exportedboolwhether the struct is exported
summarystringthe summary (its first paragraph)
descriptionstringthe description (the paragraphs after the summary)
fieldslist of ParamDocthe documented fields
sincestringthe documented since-version
deprecatedstringthe deprecation note, or "" if not deprecated
seelist of stringthe cross-references
internalboolwhether the struct is marked internal

docblock.ThrowDoc

A documented thrown error.

FieldTypeDescription
typestringthe thrown type, verbatim in Jennifer syntax
descriptionstringthe prose description