(samizdat apidocs)

Reference

Overview

Commands that show the docs of a Bjolang module in a document.

(meta (title "(std random)"))

@generate-docs[#:module "std random"]{
  Text of your own, at the end of the overview.
}

@comment{Or arrange the page yourself:}

@defmodule[(std random)]{
  Everything here takes @code{#:rng}.
}

@defdoc[random-int]{
  A die is @code{(random-int 1 6)}.
}

Or use @docref[random-double], further down.

@defdoc[random-double]

The docs are the (:doc ...) forms that the compiler published in the dll of the module. The commands read them with (bjo docs) while the document is expanded. So a page shows the docs of the module as it was compiled. The dll is added to the sources of the document, so a kept page is stale when the module is built again.

Which module. A module is written in one of two ways:

Texts. The texts in a doc are samizdat markup. They are expanded with the commands of the document.

Errors. These are rejected with refuse: a module that is not found, a module that is not compiled, a name that the module has no doc for, a definition that the document shows twice, and a @docref to a definition that the document does not show.

Classes. An entry is a Div of class doc-entry. The doc of a module is a Div of class doc-module. The kind of an entry is a Span of class doc-kind. On a page that @generate-docs made, the link up to the index is a Span of class doc-up, and the index is a Div of class doc-index.

See also: generate-docs, defmodule, defdoc, defdocs, docref

Reference

Functions

Functions

generate-docs

function ↑ Functions

(: generate-docs (-> Ctx Call (Vec Piece)))
(generate-docs cx c)

A command that makes a whole page for the docs of a module.

cx
The state of the document.
c
The call.
returns
The blocks of the page.
@generate-docs[#:module "std datetime"]
@generate-docs[#:path "src/thing.bjo"]{Text for the overview.}

It takes #:module or #:path, not both. #:module is the name of the module, as a string with or without parentheses: "std datetime". #:path is the path of the source of the module, relative to the document.

The page has these parts:

The headings of the parts are at level 1, the groups at level 2, and the entries at level 3. After the command, the module is the module of @defdoc, @defdocs and @docref.

Positional arguments, a call with neither keyword, and a call with both are rejected with refuse.

See also: defmodule, defdocs, docref

defmodule

function ↑ Functions

(: defmodule (-> Ctx Call (Vec Piece)))
(defmodule cx c)

A command that shows the doc of a module, and sets the module of the commands after it.

cx
The state of the document.
c
The call.
returns
A Div of class doc-module: the doc of the module, then the body.
@defmodule[(std random)]{
  Everything here takes @code{#:rng}.
}
@defmodule["src/thing.bjo"]

It takes one positional argument: the name of the module, or the path of its source as a string. It takes no keywords. A module with no module doc shows only the body.

@defdoc, @defdocs and @docref without #:module use this module, until the next @defmodule or @generate-docs.

See also: defdoc, defdocs, docref, generate-docs

defdoc

function ↑ Functions

(: defdoc (-> Ctx Call (Vec Piece)))
(defdoc cx c)

A command that shows the doc of one definition, then the body.

cx
The state of the document.
c
The call.
returns
A Div of class doc-entry.
@defdoc[random-int]{
  A die is @code{(random-int 1 6)}.
}
@defdoc["#pair"]
@defdoc[random-double #:module (std random) #:level 3]

The argument is the name of the definition. A reader extension is named with a string: "#pair". #:module names a module other than the module of @defmodule. #:level is the level of the heading, 4 by default, so that a table of contents of sections does not list the definitions.

The entry has:

A call with no name, a module that no @defmodule or #:module gives, and a name that is shown already are rejected with refuse.

See also: defdocs, defmodule, docref

defdocs

function ↑ Functions

(: defdocs (-> Ctx Call (Vec Piece)))
(defdocs cx c)

A command that shows the docs of every definition of a module, in the order of the module.

cx
The state of the document.
c
The call.
returns
One Div of class doc-entry for each definition. The doc of the module is not included.
@defmodule[(std random)]
@defdocs
@defdocs[#:module (std datetime) #:level 3]

It takes #:module and #:level, as @defdoc does. Positional arguments and a body are rejected with refuse. Use @defdoc for a definition with text of your own.

See also: defdoc, defmodule

docref

function ↑ Functions

(: docref (-> Ctx Call (Vec Piece)))
(docref cx c)

A command that makes a link to a definition that the document shows, before or after the link.

cx
The state of the document.
c
The call.
returns
A link to the entry. Its text is the body, or the name as code when there is no body.
See @docref[random-int].
See @docref[random-int]{the function for dice}.

It takes #:module, as @defdoc does. A name that the module has no doc for is rejected with refuse. A name that the document does not show with @defdoc, @defdocs or @generate-docs is also rejected, after every command ran.

See also: defdoc, defdocs, generate-docs