Module

cli

Command-line interface for Kida (kida check, future subcommands).

Functions

_iter_templates 1 list[Path]
Collect template files matching all known extensions, sorted.
def _iter_templates(root: Path) -> list[Path]
Parameters
Name Type Description
root Path
Returns
list[Path]
_cmd_check 5 int
Parse every template under *template_dir*; exit non-zero on failure.
def _cmd_check(template_dir: Path, *, strict: bool, validate_calls: bool, a11y: bool, typed: bool) -> int
Parameters
Name Type Description
template_dir Path
strict bool
validate_calls bool
a11y bool
typed bool
Returns
int
_format_pot 2 str
Format extracted messages as a PO template (.pot) file.
def _format_pot(messages: list[ExtractedMessage], *, template_dir: Path | None = None) -> str
Parameters
Name Type Description
messages list[ExtractedMessage]
template_dir Path | None Default:None
Returns
str
_pot_escape 1 str
Escape a string for POT file output.
def _pot_escape(s: str) -> str
Parameters
Name Type Description
s str
Returns
str
_cmd_extract 3 int
Extract translatable messages from templates under *template_dir*.
def _cmd_extract(template_dir: Path, *, output: Path | None, extensions: list[str]) -> int
Parameters
Name Type Description
template_dir Path
output Path | None
extensions list[str]
Returns
int
_cmd_fmt 3 int
Format template files.
def _cmd_fmt(paths: list[Path], *, indent: int, check_only: bool) -> int
Parameters
Name Type Description
paths list[Path]
indent int
check_only bool
Returns
int
_ast_contains 2 bool
Check if a Kida AST tree contains any node of the given type.
def _ast_contains(node: object, cls: type) -> bool
Parameters
Name Type Description
node object
cls type
Returns
bool
_print_explain 2 None
Print which compile-time optimizations are active for this template.
def _print_explain(env: Environment, tpl: object) -> None
Parameters
Name Type Description
env Environment
tpl object
_cmd_render 11 int
Render a single template to stdout.
def _cmd_render(template_path: Path, *, data_file: Path | None, data_str: str | None, data_format: str, width: int | None, color: str | None, mode: str, stream: bool = False, stream_delay: float = 0.02, explain: bool = False, set_vars: list[str] | None = None) -> int
Parameters
Name Type Description
template_path Path
data_file Path | None
data_str str | None
data_format str
width int | None
color str | None
mode str
stream bool Default:False
stream_delay float Default:0.02
explain bool Default:False
set_vars list[str] | None Default:None
Returns
int
_cmd_components 3 int
List all ``{% def %}`` components across templates in *template_dir*.
def _cmd_components(template_dir: Path, *, json_output: bool, filter_name: str | None) -> int
Parameters
Name Type Description
template_dir Path
json_output bool
filter_name str | None
Returns
int
_cmd_readme 7 int
Generate a README from auto-detected project metadata.
def _cmd_readme(root: Path, *, output: Path | None, preset: str | None, template: Path | None, set_vars: list[str] | None, depth: int, dump_json: bool) -> int
Parameters
Name Type Description
root Path
output Path | None
preset str | None
template Path | None
set_vars list[str] | None
depth int
dump_json bool
Returns
int
main 1 int
Entry point for ``python -m kida`` / the ``kida`` console script.
def main(argv: list[str] | None = None) -> int
Parameters
Name Type Description
argv list[str] | None Default:None
Returns
int