Contributing or modifying the theme¶
The sphinx_rtd_theme is primarily a sass project that requires a few other sass libraries. I’m using bower to manage these dependencies and sass to build the css. The good news is I have a very nice set of grunt operations that will not only load these dependencies, but watch for changes, rebuild the sphinx demo docs and build a distributable version of the theme. The bad news is this means you’ll need to set up your environment similar to that of a front-end developer (vs. that of a python developer). That means installing node and ruby.
See also
If you are unsure of appropriate actions to take while interacting with our community please read our Code of Conduct.
Set up your environment¶
Install sphinx into a virtual environment.
pip install sphinx sphinxcontrib-httpdomain
Install sass.
gem install sass
Install node, bower, grunt, and theme dependencies.
# Install node brew install node # Install bower and grunt npm install -g bower grunt-cli # Now that everything is installed, let's install the theme dependencies. npm install
Now that our environment is set up, make sure you’re in your virtual environment, go to this repository in your terminal and run grunt:
grunt
This default task will do the following very cool things that make it worth the trouble:
- Install and update any bower dependencies.
- Run sphinx and build new docs.
- Watch for changes to the sass files and build css from the changes.
- Rebuild the sphinx docs anytime it notices a change to
.rst
,.html
,.js
or.css
files.
Releasing the Theme¶
When you release a new version, you should do the following:
Bump the version in
sphinx_rtd_theme/__init__.py
,bower.json
andpackage.json
– we try to follow semver, so be careful with breaking changes.Update the changelog (
docs/changelog.rst
) with the version information.Run a
grunt build
to rebuild all the theme assets.Commit that change.
Tag the release in git:
git tag $NEW_VERSION
.Push the tag to GitHub:
git push --tags origin
.Upload the package to PyPI:
$ rm -rf dist/ $ python setup.py sdist bdist_wheel $ twine upload --sign --identity security@readthedocs.org dist/*