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:
- A name, such as
(std random). It is found as the compiler finds it: in the installed library, and in the packages of the nearest.bjo/rootsabove the document. - A string, the path of the source of the module, relative to the document. The dll must be beside the source.
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
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:
- A link to the reference.
- A heading Overview, then the doc of the module, then the body.
- A heading Reference, then an index. The index has a group for each kind: types, functions, values, macros. In each group, the names are in alphabetical order. Each name is a link to its entry.
- A heading for each group, then the entry of each definition of that kind, in the order of the module. Each entry has a link back to its group in the index.
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.
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
Divof classdoc-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
Divof classdoc-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 heading with the name, which a link can go to;
- the kind of the definition;
- the type and the head of the definition, or the forms of a macro;
- the summary;
- the arguments, the keywords, the fields, the cases, the type parameters, the result and the exceptions, with their texts;
- the examples, the reference text, and links to the related names that the document shows.
A call with no name, a module that no @defmodule or
#:module gives, and a name that is shown already are rejected
with refuse.
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
Divof classdoc-entryfor 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.
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