smalldocs.api

The API reference, made from the code: docstrings, types and docments, as plain Markdown and as site pages.

smalldocs api build one page per module into the site, and the index of names for links smalldocs api check what is typed and documented, and every gap; exit 1 if any smalldocs api module NAME one module as plain Markdown smalldocs api list every module, class, method and function, one line each

Types come from the annotations, the description of a parameter from its docment (the comment beside it, read by fastcore), and the summary from the docstring. A dataclass shows its constructor, a pydantic model its fields with their descriptions or the comment beside each, a TypedDict its keys with the comment beside each, and a click command its function and its options. The settings are api in _smalldocs.yml, or smalldocs.api in _quarto.yml:

api:
  packages: [mypkg]                   # importable packages to document
  out: api                            # the folder of pages, inside the site
  root: ..                            # the repository's root, from the site's folder
  source: https://github.com/me/mypkg/blob/main   # where `source` links point
  check: ["*.py", "docs/*.py", "tests/**/*.py"]  # more files that `check` holds to the convention, from the root

class Symbol

source

Symbol(module: str, name: str, kind: str, summary: str, line: int)

One line of the inventory: a module, a class, a method or a function, and where it is.

Parameter Type Default Description
module str required The module’s full name, such as mypkg.api
name str required render or Choice._check: the name inside the module; empty for the module
kind str required module, class, method or function
summary str required The first line of the docstring, or empty when there is none
line int required The line the definition starts on; 1 for a module

package_modules

source

package_modules(package: str) -> list[ModuleType]

Import every public module of a package, its subpackages’ too, in name order; the package itself when it defines code.

Parameter Type Default Description
package str required The name of an importable package, or of a single module
returns list[ModuleType] The package, when its __init__ defines code, then its public modules and its subpackages’, in name order

file_modules

source

file_modules(files: list[Path], root: Path | None = None) -> list[ModuleType]

Import Python files as modules of their own, named by their paths from the root, such as tests/test_x.py.

Parameter Type Default Description
files list[Path] required Python files that are not part of a package
root Path | None None The folder that names start from; None names each file by its full path
returns list[ModuleType] One module per file, named by its path, in the order given

module

source

module(name: str, packages: list[str]) -> ModuleType

Find one module by its short name or its full name.

Parameter Type Default Description
name str required The module’s short name, api, or its full name, mypkg.api
packages list[str] required The packages to look in
returns ModuleType The imported module; LookupError when there is no such module

doc

source

doc(obj: object) -> str

Read an object’s own docstring, cleaned of its indentation; empty when there is none.

Parameter Type Default Description
obj object required A module, class or function
returns str Its own docstring, cleaned of its indentation; empty when there is none

summary

source

summary(obj: object) -> str

Read the first line of an object’s docstring.

Parameter Type Default Description
obj object required A module, class or function
returns str The first line of its docstring; empty when there is none

line_of

source

line_of(sym: Code) -> int

Find the line a symbol’s definition starts on, to keep symbols in source order.

Parameter Type Default Description
sym Code required A function, method or class
returns int The line its definition starts on

unwrapped

source

unwrapped(obj: object) -> object

See through a decorator that kept the function, as functools.wraps, a fixture and a click command do.

Parameter Type Default Description
obj object required Anything a module or a class holds under a name
returns object The function inside it when it is a decorator’s wrapper or a click command; otherwise the object itself

is_command

source

is_command(obj: object) -> bool

Tell whether an object is a click command: it has a function in callback, a list in params and a name.

Parameter Type Default Description
obj object required Anything a module holds under a name
returns bool Whether it is a click command or group, found by its shape, without importing click

command_of

source

command_of(func: FunctionType, mod: ModuleType) -> object | None

Find the click command that a function is the callback of, to list its options.

Parameter Type Default Description
func FunctionType required A function
mod ModuleType required The module it was written in
returns object | None The click command or group in the module whose function it is; None when there is none

own

source

own(mod: ModuleType, private: bool = False) -> list[Code]

List the functions and classes a module defines itself, in source order; not its imports.

Parameter Type Default Description
mod ModuleType required An imported module
private bool False Include names that start with an underscore
returns list[Code] The functions and classes the module defines, in source order

is_dunder

source

is_dunder(name: str) -> bool

Tell whether a name is one of Python’s own, such as __init__: a dataclass writes those.

Parameter Type Default Description
name str required An attribute name
returns bool Whether it is one of Python’s own, written __like_this__

methods

source

methods(klass: type, private: bool = False) -> list[FunctionType]

List the methods a class defines itself, in source order, not what it inherits.

Parameter Type Default Description
klass type required A class
private bool False Include names that start with one underscore
returns list[FunctionType] The methods the class defines, in source order

entries

source

entries(mod: ModuleType, private: bool = False) -> list[tuple[Code, int]]

List the symbols of a module in the order of its page, each class followed by its methods.

Parameter Type Default Description
mod ModuleType required An imported module
private bool False Include private names, and names outside __all__
returns list[tuple[Code, int]] Each function, class and method, with its heading level: 2 at the top, 3 for a method

held

source

held(mod: ModuleType, shown: bool = False) -> list[Code]

List everything check holds to the convention: every function, class and method, or only what the page shows.

Parameter Type Default Description
mod ModuleType required An imported module
shown bool False Hold only what the module’s page shows
returns list[Code] Every function, class and method in it, private ones and those outside __all__ too; or only those its page shows

inventory

source

inventory(packages: list[str]) -> list[Symbol]

List every public module, class, method and function of the packages, with its summary.

Parameter Type Default Description
packages list[str] required The names of importable packages
returns list[Symbol] One entry per public module, class, method and function, in source order

name_of

source

name_of(anno: object, mod: ModuleType) -> str | None

Find what a module calls a type: an alias such as JSONContent, or the name it imported.

Parameter Type Default Description
anno object required A type, as an annotation holds it
mod ModuleType required The module the annotation was written in
returns str | None The name that module gives the type, or None when it has none

type_text

source

type_text(anno: object, mod: ModuleType) -> str

Write a type the way the source does: JSONContent, not the union it stands for.

Parameter Type Default Description
anno object required A type, as an annotation holds it
mod ModuleType required The module the annotation was written in
returns str The type as the source would write it

default_text

source

default_text(value: object) -> str

Write a default value; a function’s repr holds its memory address, which changes at each build, so a function is written by its name.

Parameter Type Default Description
value object required A parameter’s default value
returns str It as Python: a function by its name, anything else by its repr

signature_of

source

signature_of(sym: Code) -> Signature

Read a signature; when a metaclass’s __call__ hides a class’s __init__, read that of __init__.

Parameter Type Default Description
sym Code required A function, method or class
returns Signature Its signature; for a class with an __init__, never only (*args, **kwargs)

signature

source

signature(sym: Code, mod: ModuleType) -> str

Write a signature as one line of Python: each parameter with its type and default.

Parameter Type Default Description
sym Code required A function, method or class
mod ModuleType required The module it was written in
returns str Its parameters and return as one line of Python, without the name

cell

source

cell(text: str) -> str

Make text safe inside a Markdown table cell.

Parameter Type Default Description
text str required The text of one cell
returns str The same text with every | escaped

table

source

table(rows: list[list[str]], head: list[str]) -> str

Write a Markdown table, or nothing when there are no rows.

Parameter Type Default Description
rows list[list[str]] required The cells of each row
head list[str] required The column titles
returns str A Markdown table; empty when there are no rows

safe_docments

source

safe_docments(sym: Code) -> dict

Read the docments, or, for code with no source (made by exec, or compiled), the signature alone.

Parameter Type Default Description
sym Code required A function, method or class
returns dict Each parameter’s annotation, default and docment, under its name, and return

starred

source

starred(sym: Code) -> set[str]

Find the names of the *args and **kwargs of a function.

Parameter Type Default Description
sym Code required A function, method or class
returns set[str] The names of its *args and **kwargs, which take no default and are never required

params_table

source

params_table(sym: Code, mod: ModuleType) -> str

Describe a function by its parameters and its return: type, default, docment.

Parameter Type Default Description
sym Code required A function, method or dataclass
mod ModuleType required The module it was written in
returns str A Markdown table of its parameters and its return: type, default, description

is_model

source

is_model(klass: type) -> bool

Tell whether a class is a pydantic model: it has a dict of model_fields whose values say if they are required.

Parameter Type Default Description
klass type required A class
returns bool Whether it is a pydantic model, found by its shape, without importing pydantic

fields_table

source

fields_table(model: type, mod: ModuleType) -> str

Describe a pydantic model by its fields, because its constructor signature says nothing.

Parameter Type Default Description
model type required A pydantic model class
mod ModuleType required The module it was written in
returns str A Markdown table of its fields: type, default, description

field_descriptions

source

field_descriptions(model: type) -> dict[str, str]

Describe each field of a model: its description when it has one, or else the comment beside it.

Parameter Type Default Description
model type required A pydantic model class
returns dict[str, str] For each field that has one, its description

class_comments

source

class_comments(klass: type) -> dict[str, str]

Read the comment beside each annotated name in one class body, such as title: str # The title.

Parameter Type Default Description
klass type required A class
returns dict[str, str] For each name annotated in the class body, the comment beside it

key_comments

source

key_comments(klass: type) -> dict[str, str]

Read the docments of a TypedDict’s keys or a model’s fields: the comment beside each, a subclass’s first.

Parameter Type Default Description
klass type required A TypedDict or a model class
returns dict[str, str] For each key that has one, the comment beside it, from the class and the classes it inherits

parents

source

parents(klass: type) -> list[type]

List a class and its parents; a TypedDict’s parents are in __orig_bases__, because its __mro__ is that of a dict.

Parameter Type Default Description
klass type required A class
returns list[type] The class, then the classes it inherits, nearest first

options_table

source

options_table(command: object) -> str

Describe a click command’s options and arguments, as its --help does.

Parameter Type Default Description
command object required A click command or group
returns str A Markdown table of its options and arguments: names, default, help

keys_table

source

keys_table(klass: type, mod: ModuleType) -> str

Describe a TypedDict by its keys, because calling it says nothing.

Parameter Type Default Description
klass type required A TypedDict class
mod ModuleType required The module it was written in
returns str A Markdown table of its keys: type, description

has_init

source

has_init(klass: type) -> bool

Tell whether a class has a constructor of its own to show, as a dataclass does.

Parameter Type Default Description
klass type required A class
returns bool Whether it has a constructor of its own, written by hand or by dataclass

entry

source

entry(sym: Code, level: int) -> str

Write one symbol: a heading, its signature, its docstring and the table of its parameters.

Parameter Type Default Description
sym Code required A function, method or class
level int required The heading level of its entry: 2 for a top-level symbol, 3 for a method
returns str The Markdown of one entry

module_markdown

source

module_markdown(mod: ModuleType) -> str

Write one module as plain Markdown: its docstring, then an entry for each public symbol.

Parameter Type Default Description
mod ModuleType required An imported module
returns str The whole module as plain Markdown

markdown

source

markdown(name: str, packages: list[str]) -> str

Write one module, found by name, as plain Markdown.

Parameter Type Default Description
name str required The module’s short name, api, or its full name, mypkg.api
packages list[str] required The packages to look in
returns str The whole module as plain Markdown

gaps_of

source

gaps_of(sym: Code) -> list[str]

Find what one symbol is missing: a docstring, a type, a docment, or a field description.

Parameter Type Default Description
sym Code required A function, method or class
returns list[str] One message per gap; empty when the symbol is fully typed and documented

gaps

source

gaps(mod: ModuleType, shown: bool = False) -> dict[str, list[str]]

Find every gap in a module, under the module’s name and then under each symbol’s.

Parameter Type Default Description
mod ModuleType required An imported module
shown bool False Look only at what the module’s page shows
returns dict[str, list[str]] The gaps of each symbol under its name, the module’s under its own

check

source

check(packages: list[str], files: list[Path], root: Path | None = None, shown: bool = False) -> int

Print how much of each module is typed and documented, then every gap, then the total.

Parameter Type Default Description
packages list[str] required The packages to hold to the convention
files list[Path] required More Python files to hold to it, such as the tests
root Path | None None The folder that the names of the files start from
shown bool False Hold the packages only to what their pages show; the files are held in full
returns int The exit code: 0 when nothing is missing, 1 otherwise

class Settings

source

Settings(site: Path, packages: list[str], out: str = 'api', root: Path | None = None, source: str = '', check: tuple[str, ...] = (), linkify: bool = True, shown: bool = False, language: str = 'python', entry: tuple[str, ...] = (), tsconfig: str = '', manifest: Path | None = None, toolchain: str = 'nightly', private: bool = False, file: str = '', command: tuple[str, ...] = (), fastapi: str = '', setup: str = '', python: tuple[str, ...] = (), timeout: float = 300, check_responses: bool = False, listed: bool = False, warnings: list[str] = <factory>)

What the api settings say: api in _smalldocs.yml, or smalldocs.api in _quarto.yml.

Parameter Type Default Description
site Path required The site’s folder, which holds the config
packages list[str] required The packages to document
out str 'api' The folder of pages, inside the site
root Path | None None The repository’s root, for source links and the files of check
source str '' The URL that a file’s path is added to for its source link
check tuple[str, …] () Globs, from the root, of more files that check holds to the convention; **/ is any folders or none
linkify bool True Whether a name in backticks links to its entry
shown bool False Whether check holds the packages only to what their pages show, from check-shown
language str 'python' The language of the code: python, rust, typescript or openapi
entry tuple[str, …] () TypeScript: the entry points, files or folders, from the site’s folder
tsconfig str '' TypeScript: the tsconfig, from the site’s folder; empty lets TypeDoc find it
manifest Path | None None Rust: the crate’s Cargo.toml; None is the one at the root
toolchain str 'nightly' Rust: the toolchain that runs rustdoc
private bool False Rust: document private items too
file str '' OpenAPI: a JSON or YAML document, from the site’s folder
command tuple[str, …] () OpenAPI: a command that prints the document, run in the root
fastapi str '' OpenAPI: a FastAPI app as module:attribute, imported in the project’s environment
setup str '' OpenAPI: with fastapi, a function as module:function that adds the app’s routes
python tuple[str, …] () OpenAPI: the command that runs Python in the project’s environment; empty is uv run --frozen python
timeout float 300 OpenAPI: the seconds to wait for the command or the program
check_responses bool False OpenAPI: whether check needs a schema for each 2xx response, from check-responses
listed bool False Whether the section is one of a list, which keeps its names beside its manifest
warnings list[str] <factory> What the build of the section found that is not an error

Settings.read

source

Settings.read(site: Path, conf: dict) -> Settings

Read the settings from the config, with a warning for each key that the section’s language does not read.

Parameter Type Default Description
site Path required The site’s folder
conf dict required The smalldocs.api section
returns Settings The settings, with defaults

Settings.read_python

source

Settings.read_python(site: Path, conf: dict) -> Settings

Read the settings of Python packages.

Parameter Type Default Description
site Path required The site’s folder
conf dict required The api section
returns Settings The settings, with defaults

Settings.read_other

source

Settings.read_other(site: Path, conf: dict, language: str) -> Settings

Read the settings of a crate, a TypeScript package or an OpenAPI document, which have no packages to import.

Parameter Type Default Description
site Path required The site’s folder
conf dict required The api section
language str required rust, typescript or openapi
returns Settings The settings, with defaults

Settings.read_openapi

source

Settings.read_openapi(conf: dict) -> Settings

Read where an OpenAPI document comes from: exactly one of file, command and fastapi, and setup only with fastapi.

Parameter Type Default Description
conf dict required The api section
returns Settings The same settings, with the input of the OpenAPI document

Settings.importable

source

Settings.importable() -> None

Let the packages import from the repository: its root and its src folder go on sys.path.

Settings.package_files

source

Settings.package_files() -> set[Path]

Find where the documented packages are, so that check does not import their files a second time.

Parameter Type Default Description
returns set[Path] The folders of the documented packages, and the files of single modules

Settings.check_files

source

Settings.check_files() -> list[Path]

Find the files of check.

Parameter Type Default Description
returns list[Path] The files the globs of check find

page

source

page(s: Settings, mod: ModuleType, syms: list[Symbol]) -> str

Turn one module’s Markdown into a page: front matter, an id and a source link for each heading.

Parameter Type Default Description
s Settings required The settings
mod ModuleType required One module
syms list[Symbol] required The inventory entries of that module, the module’s own first
returns str The text of its .qmd page

build

source

build(s: Settings) -> list[Path]

Write one reference page per module, and _symbols.json, the index of names that links use.

Parameter Type Default Description
s Settings required The settings
returns list[Path] The pages written

write_names

source

write_names(s: Settings, out_dir: Path, index: dict[str, str], full: set[str]) -> None

Write the index of names: _symbols.json for a single section, or the names file beside the manifest for a section of a list.

Parameter Type Default Description
s Settings required The settings
out_dir Path required The folder of pages, resolved
index dict[str, str] required The index of names for links
full set[str] required The names in it that are full names, such as mypkg.api.build, and not short ones

language_module

source

language_module(s: Settings) -> ModuleType

Load the module that reads the language, only when it is needed.

Parameter Type Default Description
s Settings required The settings of a Rust, TypeScript or OpenAPI project
returns ModuleType smalldocs.api_rust, smalldocs.api_ts or smalldocs.api_openapi

one_line

source

one_line(text: str) -> str

Join the lines of a comment, because a table cell holds one line; never for the body of a page.

Parameter Type Default Description
text str required A comment or a description, which may span lines
returns str It on one line, for a table cell

unique

source

unique(names: list[str], reserved: re.Pattern | PageIds | None = None) -> list[str]

Make names unique, so that no page or id takes the place of another.

Parameter Type Default Description
names list[str] required Names that may repeat, such as b for b.ts and b/index.ts
reserved re.Pattern | PageIds | None None Names that no item may take, matched whole; given, each name keeps its first place and a repeat skips every name of the list
returns list[str] The same names, a repeat taking -2, -3 and so on; letters’ case does not tell names apart, as on macOS

class PageIds

source

PageIds(taken: set[str] = frozenset())

The ids that the entries of a page may not take: those of RESERVED_IDS, and some more, matched whole in any case.

Parameter Type Default Description
taken set[str] frozenset() More ids that no entry may take, in lower case

PageIds.fullmatch

source

PageIds.fullmatch(name: str) -> bool

Tell whether an id is taken, as re.Pattern.fullmatch does for unique.

Parameter Type Default Description
name str required An id that unique would give
returns bool Whether it is reserved

entry_ids

source

entry_ids(names: list[str]) -> list[str]

Make the ids of a page’s entries, so that no entry’s id is also an id of the page.

Parameter Type Default Description
names list[str] required The ids that the entries of a page would have, in order
returns list[str] The same ids made unique, none of them an id of the page’s markup, nor toc- before another of them, which the table of contents writes

code_span

source

code_span(text: str) -> str

Write text as code, so that a backtick in it ends nothing.

Parameter Type Default Description
text str required Any text on one line, such as a JSON value
returns str It as a Markdown code span, its backticks longer than any run in the text

code_block

source

code_block(text: str, lang: str) -> str

Put code in a fenced code block that no line of it closes.

Parameter Type Default Description
text str required Code, of one line or more
lang str required Its language, such as http
returns str A fenced code block, its fence longer than any run of backticks in the code

source_line

source

source_line(s: Settings, path: str, line: int) -> str

Link a line of a file in the repository.

Parameter Type Default Description
s Settings required The settings
path str required The file, from the root, such as api/routers/teams.py
line int required The line
returns str A Markdown link to the line, or empty when there is no source

escape_angles

source

escape_angles(text: str) -> str

Escape a stray <, such as in Vec<u8> or vs <Opp> written outside backticks, so that it shows as text and starts no HTML.

Parameter Type Default Description
text str required Markdown, of one line or more
returns str The same text with each < that starts no HTML tag, autolink or comment written &lt;; code spans and fenced code blocks stay as they are

escape_prose

source

escape_prose(text: str) -> str

Escape the stray < of prose that holds no code block.

Parameter Type Default Description
text str required Markdown prose, outside a code block
returns str The same text with each stray < written &lt;; code spans stay as they are

type_cell

source

type_cell(text: str) -> str

Write a type in a table cell as plain text, so that &, <, >, *, _, $, ~, ^, quotes, a backtick, [ and ] show as they are.

Parameter Type Default Description
text str required A type, as Rust or TypeScript writes it
returns str It as plain text, as the Python pages write types, with Markdown’s, maths’ and HTML’s signs escaped; table escapes |

heading_text

source

heading_text(text: str) -> str

Escape a heading’s text, so that __x__ is no bold, $a.$b no maths, Wrapper<B> no tag and a--b no dash; the heading’s id is written apart.

Parameter Type Default Description
text str required The text of a heading, such as fn __x__ or $a.$b
returns str The same text with each sign of Markdown, maths and HTML escaped by a backslash; a _ between two letters or digits, as in in_a, stays as it is, and so does a lone - or .

warn_unlinked

source

warn_unlinked(s: Settings, files: set[str]) -> None

Warn that source is set, but some items have no source link, because their files are not inside the root.

Parameter Type Default Description
s Settings required The settings
files set[str] required The source files outside the root, whose items got no source link

front_matter

source

front_matter(title: str, description: str | None = None, order: int | None = None) -> str

Begin a Rust, TypeScript or OpenAPI page, marked as written by a build, so that a lost manifest leaves no page frozen.

Parameter Type Default Description
title str required The page’s title, as plain text; it is escaped, because a title is Markdown
description str | None None Its description; None writes none
order int | None None Its place in the sidebar; None writes none
returns str The front matter, with the mark of a build first, and the blank line after it

yaml_text

source

yaml_text(text: str) -> str

Quote text for front matter; JSON’s \ud83e\udd80 for an emoji is two broken characters to PyYAML.

Parameter Type Default Description
text str required Any text
returns str It as a YAML string in double quotes, with every character that is not ASCII as it is, as YAML reads an emoji

out_folder

source

out_folder(s: Settings) -> Path

Find the folder of pages, and refuse one that is the site or outside it, before any tool runs.

Parameter Type Default Description
s Settings required The settings
returns Path The folder of pages, resolved

inside

source

inside(out_dir: Path, rel: str) -> Path | None

Check that a page’s path stays inside out: relative, no .., no empty part, no backslash, a .qmd.

Parameter Type Default Description
out_dir Path required The folder of pages
rel str required A path in it, from the manifest or from a page’s place
returns Path | None The file, when the path is a .qmd that stays inside the folder; None otherwise

built_before

source

built_before(out_dir: Path) -> set[str]

Read the manifest of the last build.

Parameter Type Default Description
out_dir Path required The folder of pages
returns set[str] The pages that the last build wrote, from its manifest, as paths from the folder

page_key

source

page_key(rel: str) -> str

Name the page that a source makes, so that two sources of one page are found.

Parameter Type Default Description
rel str required A page’s path in the folder of pages, such as components/Badge.qmd or utils/format.ipynb
returns str The page it makes on the site, without its suffix, in lower case: .md, .qmd and .ipynb of one name are one page, as on macOS

marked

source

marked(f: Path) -> bool

Read a page’s mark.

Parameter Type Default Description
f Path required A page
returns bool Whether a build wrote it, by the mark at its start

hand_written

source

hand_written(out_dir: Path) -> set[str]

Find the pages that someone wrote in the folder of pages, which a build never writes over: a .md, an .ipynb, or a .qmd without the mark.

Parameter Type Default Description
out_dir Path required The folder of pages
returns set[str] The pages in it that no build wrote, as paths from the folder

listing

source

listing(rows: list[tuple[str, str, str]]) -> str

List some pages of the reference, in a table.

Parameter Type Default Description
rows list[tuple[str, str, str]] required Each page: its name, its link and its summary
returns str A Markdown table with a link to each page by its name, and its summary; empty when there are none

folder_listing

source

folder_listing(out: str, folder: str, summaries: dict[str, str]) -> str

List what one folder of the reference holds, for its index.qmd.

Parameter Type Default Description
out str required The folder of pages in the site, such as api
folder str required A folder of pages in it, such as components; empty for out itself
summaries dict[str, str] required The summary of each page, by its path in out, such as components/Badge.qmd
returns str The table of the folder’s pages and subfolders, each a link, in name order; a subfolder links to its index.qmd

folder_indexes

source

folder_indexes(out: str, summaries: dict[str, str], taken: set[str], description: str = '') -> dict[str, str]

Write an index.qmd for each folder of pages that has none: titled by its folder, with a table of its pages and subfolders.

Parameter Type Default Description
out str required The folder of pages in the site, such as api
summaries dict[str, str] required The summary of each page that the build writes, by its path in out
taken set[str] required The pages that someone wrote, which a build never writes over
description str '' The description of the index of out itself, such as the crate’s summary
returns dict[str, str] The text of each folder’s index.qmd that no page of the build, and no one, has written

write_reference

source

write_reference(s: Settings, pages: dict[str, str], index: dict[str, str], taken: set[str], full: set[str] = frozenset()) -> list[Path]

Write the pages, the manifest and the index of names; delete only the marked pages that an earlier build listed and this one does not write in that spelling.

Parameter Type Default Description
s Settings required The settings
pages dict[str, str] required The text of each page, by its path in the folder of pages
index dict[str, str] required The index of names for links, for _symbols.json
taken set[str] required The pages that someone wrote, from hand_written
full set[str] frozenset() The names in the index that are full names, which two sections of a list must not share
returns list[Path] The pages written

sections

source

sections(site: Path, conf: object) -> list[Settings]

Read the api settings: one section, or each section of a list, whose out folders must be apart.

Parameter Type Default Description
site Path required The site’s folder
conf object required The api setting: one mapping, or a list of them
returns list[Settings] The settings of each section, in the order of the list

chosen

source

chosen(found: list[Settings], out: str | None) -> list[Settings]

Pick the section that --out names, or every section.

Parameter Type Default Description
found list[Settings] required The sections
out str | None required The out of the one section to run, from --out; None runs every section
returns list[Settings] The sections to run

merge_names

source

merge_names(site: Path, found: list[Settings]) -> list[str]

Write _symbols.json from the names file of each section, in the order of the list; the first section to give a name keeps it.

Parameter Type Default Description
site Path required The site’s folder
found list[Settings] required Every section of the list
returns list[str] The warnings: a full name that two sections give, and a folder of pages that no section names

build_sections

source

build_sections(site: Path, conf: object, out: str | None = None) -> tuple[list[Path], list[str]]

Build each section of the api settings, then, for a list, merge their names into _symbols.json.

Parameter Type Default Description
site Path required The site’s folder
conf object required The api setting: one mapping, or a list of them
out str | None None The out of the one section to build; None builds every section
returns tuple[list[Path], list[str]] The pages written, and the warnings

build_from_config

source

build_from_config(project: object) -> tuple[list[Path], list[str]]

Build the reference pages that smalldocs.api asks for, before the site is rendered.

Parameter Type Default Description
project object required A loaded config.Project
returns tuple[list[Path], list[str]] The pages written, and the warnings, which Site.build keeps

main

source

main(site: str, action: str, name: str | None = None, shown: bool = False, out: str | None = None) -> int

Run one smalldocs api command.

Parameter Type Default Description
site str required The site’s folder, whose config has the api settings
action str required build, check, module or list
name str | None None The module, for module
shown bool False For check: hold the packages only to what their pages show, as check-shown: true does
out str | None None The out of the one section to run; None runs every section
returns int The exit code

run

source

run(s: Settings, action: str, name: str | None) -> int

Run one smalldocs api command with its settings read.

Parameter Type Default Description
s Settings required The settings
action str required build, check, module or list
name str | None required The module, for module
returns int The exit code