mkdocs¶
Serve the mkdocs site of the consumer project from a pre-provisioned Python virtual environment.
See References → Common contract for the
USER_WORKING_DIR, pin-strategy, override-syntax, and venv conventions
that apply across every module.
Prerequisites¶
- A Python virtual environment at
~/.venvs/docsthat holds the consumer's mkdocs stack. Thenolte/workstationplaybook provisions it; pointPYTHON_VENVS_BASEDIRat a different location otherwise. - The consumer's
mkdocs.ymllives in the working directory thetaskcommand runs from (USER_WORKING_DIR).
Tasks¶
| Task | Description |
|---|---|
mkdocs:start |
Activate PYTHON_VENV_DIR_DOCS and run mkdocs serve -a localhost:{{.MKDOCS_PORT}}. |
Variables¶
| Variable | Default | Purpose |
|---|---|---|
MKDOCS_PORT |
8001 |
Port for mkdocs serve. |
PYTHON_VENVS_BASEDIR |
~/.venvs/ |
Base directory for the Python virtual environments. |
PYTHON_VENV_DIR_DOCS |
{{.PYTHON_VENVS_BASEDIR}}/docs |
Full path to the docs virtual environment. |
Example¶
version: '3'
vars:
TASK_COLLECTION_BASE: https://raw.githubusercontent.com/nolte/taskfiles/main/src
includes:
mkdocs:
taskfile: "{{.TASK_COLLECTION_BASE}}/taskfile-include-mkdocs.yaml"
vars:
MKDOCS_PORT: 8080
Run task mkdocs:start from the directory that holds the consumer's
mkdocs.yml.
Troubleshooting¶
mkdocs: command not found. The docs venv is missing or empty. Confirm that~/.venvs/docs/bin/activateexists and that the venv holds themkdocspackage.- Port already in use. Another
mkdocs servealready holds the default port. OverrideMKDOCS_PORTas shown in the preceding example. - mkdocs serves a different site than expected. The task uses
USER_WORKING_DIR. Verify the directory thetaskcommand runs from has the consumer'smkdocs.yml.