Skip to content

tux.cli.docs

Documentation commands for the Tux CLI.

Functions:

Name Description
find_mkdocs_config

Find the mkdocs.yml configuration file.

docs_serve

Serve documentation locally.

docs_build

Build documentation site.

Functions

find_mkdocs_config() -> str

Find the mkdocs.yml configuration file.

Returns:

Type Description
str

Path to the mkdocs.yml file

Source code in tux/cli/docs.py
Python
def find_mkdocs_config() -> str:
    """Find the mkdocs.yml configuration file.

    Returns
    -------
    str
        Path to the mkdocs.yml file
    """

    current_dir = pathlib.Path.cwd()

    # Check if we're in the docs directory
    if (current_dir / "mkdocs.yml").exists():
        return "mkdocs.yml"

    # Check if we're in the root repo with docs subdirectory
    if (current_dir / "docs" / "mkdocs.yml").exists():
        return "docs/mkdocs.yml"
    logger.error("Can't find mkdocs.yml file. Please run from the project root or docs directory.")

    return ""

docs_serve() -> int

Serve documentation locally.

Source code in tux/cli/docs.py
Python
@command_registration_decorator(docs_group, name="serve")
def docs_serve() -> int:
    """Serve documentation locally."""
    if mkdocs_path := find_mkdocs_config():
        return run_command(["mkdocs", "serve", "--dirty", "-f", mkdocs_path])
    return 1

docs_build() -> int

Build documentation site.

Source code in tux/cli/docs.py
Python
@command_registration_decorator(docs_group, name="build")
def docs_build() -> int:
    """Build documentation site."""
    if mkdocs_path := find_mkdocs_config():
        return run_command(["mkdocs", "build", "-f", mkdocs_path])
    return 1