Sphinx Note#
Overview#
Sphinx is written in Python and supports Python 3.5+.
Installing Sphinx#
Linux#
RHEL, CentOS
yum install python-sphinx
Installation from PyPI#
pip install -U sphinx
Windows#
pip install -U sphinx
Markdown#
Configuration#
pip install --upgrade recommonmark
extensions = ['recommonmark']
source_suffix
source_suffix = { '.rst': 'restructuredtext', '.txt': 'markdown', '.md': 'markdown', }
sphinx-markdown-tables#
pip install sphinx-markdown-tables
conf.py
extensions = [ 'sphinx_markdown_tables', ]
Sphinx Comments#
pip install sphinx-comments
conf.py
extensions = [ 'sphinx_comments', ] comments_config = { "utterances": { "repo": "github-org/github-repo", "optional": "config", } }
Read the Docs#
pip install sphinx_rtd_theme
sphinx-quickstart
Separate source and build directories (y/n) [n]:
y
Project language [en]:
zh_CN
make html
Windows#
make.bat html
Build#
Sign in with GitHub
Import a Project
Sphinx Book Theme#
pip install sphinx-book-theme
conf.py
html_theme = "sphinx_book_theme" html_theme_options = { "path_to_docs": "doc/source", "repository_url": "https://github.com/T5750/framework-repositories", "repository_branch": "master", "use_source_button": True, "use_edit_page_button": True, "use_issues_button": True, }
Tips#
Read the Docs#
requirements.txt
Fix
latexmk -r latexmkrc -pdf
:*.gif
https://readthedocs.org/ -> 项目 -> 管理 -> 设置 -> 名称:
frameworks
Fix
ImportError: cannot import name 'PackageFinder' from 'pip._internal.index'
:Go to Versions
Click on the Edit button of the version you want to wipe on the right side of the page
Go to the bottom of the page and click the wipe link, next to the “Save” button
Fix
Could not import extension sphinx.builders.linkcheck
: use a config file (https://docs.readthedocs.io/en/stable/config-file/v2.html)