Skip to content

Commit aec189a

Browse files
evildmpdpgeorge
authored andcommitted
docs: Add optional sphinx_rtd_theme; add docs build instructions.
The sphinx_rtd_theme is used by ReadTheDocs to render a pretty looking documentation. If you have this theme installed locally then your locally-compiled docs will look exactly like the published documentation. Otherwise it falls back to the default theme.
1 parent ca0b0cb commit aec189a

2 files changed

Lines changed: 29 additions & 6 deletions

File tree

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,18 @@ AUR. If the above does not work it may be because you don't have the
9898
correct permissions. Try then:
9999

100100
$ sudo dfu-util -a 0 -d 0483:df11 -D build-PYBV10/firmware.dfu
101+
102+
Building the documentation locally
103+
----------------------------------
104+
105+
Install Sphinx, and optionally (for the RTD-styling), sphinx_rtd_theme,
106+
preferably in a virtualenv:
107+
108+
pip install sphinx
109+
pip install sphinx_rtd_theme
110+
111+
In `micropython/docs`, build the docs:
112+
113+
make html
114+
115+
You'll find the index page at `micropython/docs/build/html/index.html`.

docs/conf.py

100644100755
Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,25 @@
103103

104104
# -- Options for HTML output ----------------------------------------------
105105

106-
# The theme to use for HTML and HTML Help pages. See the documentation for
107-
# a list of builtin themes.
108-
html_theme = 'default'
106+
# on_rtd is whether we are on readthedocs.org
107+
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
108+
109+
if not on_rtd: # only import and set the theme if we're building docs locally
110+
try:
111+
import sphinx_rtd_theme
112+
html_theme = 'sphinx_rtd_theme'
113+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
114+
except:
115+
html_theme = 'default'
116+
html_theme_path = ['.']
109117

110118
# Theme options are theme-specific and customize the look and feel of a theme
111119
# further. For a list of options available for each theme, see the
112120
# documentation.
113121
#html_theme_options = {}
114122

115123
# Add any paths that contain custom themes here, relative to this directory.
116-
html_theme_path = ['.']
124+
# html_theme_path = ['.']
117125

118126
# The name for this set of Sphinx documents. If None, it defaults to
119127
# "<project> v<release> documentation".
@@ -154,7 +162,7 @@
154162

155163
# Additional templates that should be rendered to pages, maps page names to
156164
# template names.
157-
html_additional_pages = {"index":"topindex.html"}
165+
html_additional_pages = {"index": "topindex.html"}
158166

159167
# If false, no module index is generated.
160168
#html_domain_indices = True
@@ -234,7 +242,7 @@
234242
# (source start file, name, description, authors, manual section).
235243
man_pages = [
236244
('index', 'micropython', 'Micro Python Documentation',
237-
['Damien P. George'], 1)
245+
['Damien P. George'], 1),
238246
]
239247

240248
# If true, show URL addresses after external links.

0 commit comments

Comments
 (0)