Sphinx-CMD
A collection of command-line tools for managing Sphinx documentation.
Installation
pip install sphinx-cmd
Commands
The sphinx-cmd tool provides subcommands for different Sphinx documentation management tasks.
Global Options
Options that apply to all commands:
# Specify a context path (directory containing conf.py)
sphinx-cmd --context /path/to/docs COMMAND
# Dry run to preview changes without executing them
sphinx-cmd --dry-run COMMAND
# Process additional directives beyond defaults
sphinx-cmd --directives drawio-figure,drawio-image COMMAND
# Enable verbose output with detailed processing information
sphinx-cmd --verbose COMMAND
By default, sphinx-cmd will automatically detect the context of your documentation project by finding the nearest conf.py file in the directory tree.
sphinx-cmd rm
Delete unused .rst files and their unique assets (images, includes, etc) if not used elsewhere.
# Remove files and assets
sphinx-cmd rm path/to/docs
# Using global options
sphinx-cmd --dry-run --directives drawio-figure,drawio-image rm path/to/docs
Features
- Configure custom directives to be processed
- Only deletes unused unique assets in the provided context path
sphinx-cmd mv
Move/rename .rst files and automatically update all references to them.
# Move and update all references
sphinx-cmd mv old-file.rst new-file.rst
# Move to a different directory
sphinx-cmd mv chapter1.rst topics/chapter1.rst
# Move without updating references
sphinx-cmd mv old-file.rst new-file.rst --no-update-refs
# Using global options
sphinx-cmd --dry-run --directives drawio-figure mv old-file.rst new-file.rst
Features
- Automatically updates
toctreeentries - Updates
:doc:references - Updates
includeandliteralincludedirectives - Handles relative paths correctly
- Preserves file relationships
- Configure custom directives to be processed
Configuration
You can add custom directives to be processed in two ways:
1. Command Line
Use the --directives global option with any command to add custom directives for a single run:
sphinx-cmd --directives drawio-figure,drawio-image rm path/to/docs
2. Configuration File
Create a .sphinx-cmd.toml file in your home directory with your custom directives:
directives = [
"drawio-figure",
"drawio-image"
]
Command line directives will be combined with those in the configuration file and the built-in defaults.
Development
# Clone the repository
git clone https://github.com/yourusername/sphinx-cmd.git
cd sphinx-cmd
# Install in development mode with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run linters
black sphinx_cmd tests
isort sphinx_cmd tests
flake8 sphinx_cmd tests
mypy sphinx_cmd
# Test the command
sphinx-cmd --help
sphinx-cmd rm --help
sphinx-cmd mv --help
Adding New Commands
The architecture is designed to make adding new commands easy:
- Create a new file in
sphinx_cmd/commands/(e.g.,new_command.py) - Implement an
execute(args)function in your new file - Import the command in
sphinx_cmd/cli.py - Add a new subparser for your command in
create_parser() - Create new tests (e.g.,
tests/test_new_command.py)
License
MIT License - see LICENSE file for details.
Metadata
Release files for sphinx-cmd 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| sphinx_cmd-0.5.0.tar.gz | 23.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sphinx_cmd-0.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.6 kB
Release files / sphinx_cmd-0.5.0.tar.gz
| Download URL | sphinx_cmd-0.5.0.tar.gz |
|---|---|
| Size | 23.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c9741edf1987c8c6c2fd41c51cf56e25c0d739ec416c2fafc68e7f1ccf1a5815
|
|
BLAKE2b-256 checksum How to use checksums |
fc6ac64914a91a859f34d1069eecaf272b9fdd9969e9c94ce5c979bfa8272d3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / sphinx_cmd-0.5.0-py3-none-any.whl
| Download URL | sphinx_cmd-0.5.0-py3-none-any.whl |
|---|---|
| Size | 17.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ff79083a799214606ee38d84106252efbd14ea732b3d0e1e8e2d0fbb1f3fd127
|
|
BLAKE2b-256 checksum How to use checksums |
fb2a8a555a4e8c8d1e179e201498987c7242c6657943a324bfc071644474b4b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Security for sphinx-cmd 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.