Command-line tools for Sphinx documentation management
Project description
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.
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
# Dry run to preview deletions
sphinx-cmd rm path/to/docs --dry-run
# Process additional directives beyond defaults
sphinx-cmd rm path/to/docs --directives drawio-figure,drawio-image
Features
- Configure custom directives to be processed
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
# Preview the move without making changes
sphinx-cmd mv old-file.rst new-file.rst --dry-run
# Move without updating references
sphinx-cmd mv old-file.rst new-file.rst --no-update-refs
# Process additional directives beyond defaults
sphinx-cmd mv old-file.rst new-file.rst --directives drawio-figure,drawio-image
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 option with any command to add custom directives for a single run:
sphinx-cmd rm path/to/docs --directives drawio-figure,drawio-image
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
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()
License
MIT License - see LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sphinx_cmd-0.3.1.tar.gz.
File metadata
- Download URL: sphinx_cmd-0.3.1.tar.gz
- Upload date:
- Size: 16.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b304b99e2e5fea223c8fe6d3af67677bb08ec9a4cda5f06c818de3c187731a78
|
|
| MD5 |
dead1e5854535ec856ca8e4899be45a1
|
|
| BLAKE2b-256 |
b56906eb68020954ae0177cca4cdf2bcfa256b672ac493fecbb2b1345acec7cf
|
File details
Details for the file sphinx_cmd-0.3.1-py3-none-any.whl.
File metadata
- Download URL: sphinx_cmd-0.3.1-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eda23a96f9417ca9b3181ee1b789747b5f14845bc8cb8f50c46496d23ee45b6a
|
|
| MD5 |
c1c1e06c5c91c44d34ac52a3769e1929
|
|
| BLAKE2b-256 |
0874060e1a259bf89ef7a722de54cb090bda444b0fb7f2763e22cfb9c5067306
|