Skip to main content

Interactive command builders for Sphinx documentation

Project description

sphinx-dynamic-command-builder

PyPI

Interactive command builders for Sphinx documentation.

sphinx-dynamic-command-builder adds a dynamic-command directive that renders a small selector UI from YAML and updates a generated command in the browser. It is useful for docs that need to show command-line examples assembled from several independent choices.

Demo: GitHub Pages

Install

pip install sphinx-dynamic-command-builder

Then enable the extension in conf.py:

extensions = [
    "sphinx_dynamic_command_builder",
]

Usage

```{dynamic-command}
base: python -m sglang.launch_server --model-path [model_path]
format:
  line_break: options
  indent: "  "
options:
  - label: Topology
    key: nodes
    default: single
    choices:
      - label: Single node
        value: single
        args: --host 0.0.0.0 --port 30000
      - label: Multi node
        value: multi
        args: --host 0.0.0.0 --port 30000 --disaggregation-ib-device mlx5_1
```

Rendered result:

Rendered dynamic command builder

Each option group is rendered as one selector row. Selecting a choice updates the generated command. Set multiple: true on a group when choices should toggle independently instead of behaving as a single-select control.

YAML schema

See Configuration for the full field reference and formatting rules.

  • base: base command string.
  • command_label: optional output label. Defaults to Generated command.
  • format.line_break: optional command wrapping mode. Use options to put each --option group on its own shell-continuation line, or none to render a single line. Defaults to options.
  • format.indent: optional indentation for continuation lines. Defaults to two spaces.
  • options: list of option groups.
  • options[].label: visible group label.
  • options[].key: stable group key.
  • options[].multiple: optional boolean. Use true for multi-select groups. Defaults to false.
  • options[].default: optional default choice value. Single-select groups use a string and default to the first choice. Multi-select groups use a string or list of strings and default to no selected choices.
  • options[].choices: list of choices.
  • choices[].label: visible choice label.
  • choices[].value: stable choice value.
  • choices[].env: optional text prepended before the base command.
  • choices[].args: optional text appended after the base command.
  • choices[].base: optional replacement base command for this choice.

Development

uv venv
uv pip install -e ".[test,docs]"
pytest
sphinx-build -M html docs docs/_build

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphinx_dynamic_command_builder-0.3.0.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file sphinx_dynamic_command_builder-0.3.0.tar.gz.

File metadata

File hashes

Hashes for sphinx_dynamic_command_builder-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f9d0d4b902a33079e48444725f9cbe76fe8c5c2c9528f204d686611ada3fe9b2
MD5 a851f148e2f451a3897372c296dea447
BLAKE2b-256 66902b48160f13b093cb67ec8d21bc3eb9daac9539599b90487564ab7e630128

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_dynamic_command_builder-0.3.0.tar.gz:

Publisher: publish.yml on Aionw/sphinx-dynamic-command-builder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sphinx_dynamic_command_builder-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_dynamic_command_builder-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c006ea45ebb2b18dca6396a2c67db5f0da16331eb1e0b133ffc7e08e34d14847
MD5 07b416cbe2506f62a1652c318a971be3
BLAKE2b-256 a47398a409ed81f4bc38e10bface58600364f9915ae271c7cbd136027cba1e0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_dynamic_command_builder-0.3.0-py3-none-any.whl:

Publisher: publish.yml on Aionw/sphinx-dynamic-command-builder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page