Skip to content

Commit 409b6c6

Browse files
committed
doc: Move non-language-specific RTD/Sphinx config to conf_common.py
1 parent 69350ea commit 409b6c6

File tree

3 files changed

+342
-645
lines changed

3 files changed

+342
-645
lines changed

docs/conf_common.py

Lines changed: 329 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,329 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Common (non-language-specific) configuration for Read The Docs & Sphinx
4+
#
5+
# Based on a Read the Docs Template documentation build configuration file,
6+
# created by sphinx-quickstart on Tue Aug 26 14:19:49 2014.
7+
#
8+
# This file is imported from a language-specific conf.py (ie en/conf.py or
9+
# zh_CN/conf.py)
10+
#
11+
# Note that not all possible configuration values are present in this
12+
# autogenerated file.
13+
#
14+
# All configuration values have a default; values that are commented out
15+
# serve to show the default.
16+
17+
import sys, os
18+
import re
19+
from subprocess import Popen, PIPE
20+
import shlex
21+
22+
# Note: If extensions (or modules to document with autodoc) are in another directory,
23+
# add these directories to sys.path here. If the directory is relative to the
24+
# documentation root, use os.path.abspath to make it absolute
25+
26+
from local_util import run_cmd_get_output, copy_if_modified
27+
28+
builddir = '_build'
29+
builddir = builddir
30+
if 'BUILDDIR' in os.environ:
31+
builddir = os.environ['BUILDDIR']
32+
33+
# Call Doxygen to get XML files from the header files
34+
print "Calling Doxygen to generate latest XML files"
35+
os.system("doxygen ../Doxyfile")
36+
# Doxygen has generated XML files in 'xml' directory.
37+
# Copy them to 'xml_in', only touching the files which have changed.
38+
copy_if_modified('xml/', 'xml_in/')
39+
40+
# Generate 'api_name.inc' files using the XML files by Doxygen
41+
os.system('python ../gen-dxd.py')
42+
43+
# Generate 'kconfig.inc' file from components' Kconfig files
44+
kconfig_inc_path = '{}/inc/kconfig.inc'.format(builddir)
45+
os.system('python ../gen-kconfig-doc.py > ' + kconfig_inc_path + '.in')
46+
copy_if_modified(kconfig_inc_path + '.in', kconfig_inc_path)
47+
48+
# http://stackoverflow.com/questions/12772927/specifying-an-online-image-in-sphinx-restructuredtext-format
49+
#
50+
suppress_warnings = ['image.nonlocal_uri']
51+
52+
# -- General configuration ------------------------------------------------
53+
54+
# If your documentation needs a minimal Sphinx version, state it here.
55+
#needs_sphinx = '1.0'
56+
57+
# Add any Sphinx extension module names here, as strings. They can be
58+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
59+
# ones.
60+
extensions = ['breathe',
61+
'link-roles',
62+
'sphinxcontrib.blockdiag',
63+
'sphinxcontrib.seqdiag',
64+
'sphinxcontrib.actdiag',
65+
'sphinxcontrib.nwdiag',
66+
'sphinxcontrib.rackdiag',
67+
'sphinxcontrib.packetdiag'
68+
]
69+
70+
# Set up font for blockdiag, nwdiag, rackdiag and packetdiag
71+
blockdiag_fontpath = '../_static/DejaVuSans.ttf'
72+
seqdiag_fontpath = '../_static/DejaVuSans.ttf'
73+
actdiag_fontpath = '../_static/DejaVuSans.ttf'
74+
nwdiag_fontpath = '../_static/DejaVuSans.ttf'
75+
rackdiag_fontpath = '../_static/DejaVuSans.ttf'
76+
packetdiag_fontpath = '../_static/DejaVuSans.ttf'
77+
78+
# Breathe extension variables
79+
80+
# Doxygen regenerates files in 'xml/' directory every time,
81+
# but we copy files to 'xml_in/' only when they change, to speed up
82+
# incremental builds.
83+
breathe_projects = { "esp32-idf": "xml_in/" }
84+
breathe_default_project = "esp32-idf"
85+
86+
# Add any paths that contain templates here, relative to this directory.
87+
templates_path = ['_templates']
88+
89+
# The suffix of source filenames.
90+
source_suffix = ['.rst', '.md']
91+
92+
source_parsers = {
93+
'.md': 'recommonmark.parser.CommonMarkParser',
94+
}
95+
96+
# The encoding of source files.
97+
#source_encoding = 'utf-8-sig'
98+
99+
# The master toctree document.
100+
master_doc = 'index'
101+
102+
103+
# The version info for the project you're documenting, acts as replacement for
104+
# |version| and |release|, also used in various other places throughout the
105+
# built documents.
106+
#
107+
108+
# Readthedocs largely ignores 'version' and 'release', and displays one of
109+
# 'latest', tag name, or branch name, depending on the build type.
110+
# Still, this is useful for non-RTD builds.
111+
# This is supposed to be "the short X.Y version", but it's the only version
112+
# visible when you open index.html.
113+
# Display full version to make things less confusing.
114+
version = run_cmd_get_output('git describe')
115+
# The full version, including alpha/beta/rc tags.
116+
# If needed, nearest tag is returned by 'git describe --abbrev=0'.
117+
release = version
118+
print 'Version: {0} Release: {1}'.format(version, release)
119+
120+
# There are two options for replacing |today|: either, you set today to some
121+
# non-false value, then it is used:
122+
#today = ''
123+
# Else, today_fmt is used as the format for a strftime call.
124+
#today_fmt = '%B %d, %Y'
125+
126+
# List of patterns, relative to source directory, that match files and
127+
# directories to ignore when looking for source files.
128+
exclude_patterns = ['_build','README.md']
129+
130+
# The reST default role (used for this markup: `text`) to use for all
131+
# documents.
132+
#default_role = None
133+
134+
# If true, '()' will be appended to :func: etc. cross-reference text.
135+
#add_function_parentheses = True
136+
137+
# If true, the current module name will be prepended to all description
138+
# unit titles (such as .. function::).
139+
#add_module_names = True
140+
141+
# If true, sectionauthor and moduleauthor directives will be shown in the
142+
# output. They are ignored by default.
143+
#show_authors = False
144+
145+
# The name of the Pygments (syntax highlighting) style to use.
146+
pygments_style = 'sphinx'
147+
148+
# A list of ignored prefixes for module index sorting.
149+
#modindex_common_prefix = []
150+
151+
# If true, keep warnings as "system message" paragraphs in the built documents.
152+
#keep_warnings = False
153+
154+
155+
# -- Options for HTML output ----------------------------------------------
156+
157+
# The theme to use for HTML and HTML Help pages. See the documentation for
158+
# a list of builtin themes.
159+
html_theme = 'default'
160+
161+
# Theme options are theme-specific and customize the look and feel of a theme
162+
# further. For a list of options available for each theme, see the
163+
# documentation.
164+
#html_theme_options = {}
165+
166+
# Add any paths that contain custom themes here, relative to this directory.
167+
#html_theme_path = []
168+
169+
# The name for this set of Sphinx documents. If None, it defaults to
170+
# "<project> v<release> documentation".
171+
#html_title = None
172+
173+
# A shorter title for the navigation bar. Default is the same as html_title.
174+
#html_short_title = None
175+
176+
# The name of an image file (relative to this directory) to place at the top
177+
# of the sidebar.
178+
#html_logo = None
179+
180+
# The name of an image file (within the static path) to use as favicon of the
181+
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
182+
# pixels large.
183+
#html_favicon = None
184+
185+
# Add any paths that contain custom static files (such as style sheets) here,
186+
# relative to this directory. They are copied after the builtin static files,
187+
# so a file named "default.css" will overwrite the builtin "default.css".
188+
#html_static_path = ['_static']
189+
190+
# Add any extra paths that contain custom files (such as robots.txt or
191+
# .htaccess) here, relative to this directory. These files are copied
192+
# directly to the root of the documentation.
193+
#html_extra_path = []
194+
195+
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
196+
# using the given strftime format.
197+
#html_last_updated_fmt = '%b %d, %Y'
198+
199+
# If true, SmartyPants will be used to convert quotes and dashes to
200+
# typographically correct entities.
201+
#html_use_smartypants = True
202+
203+
# Custom sidebar templates, maps document names to template names.
204+
#html_sidebars = {}
205+
206+
# Additional templates that should be rendered to pages, maps page names to
207+
# template names.
208+
#html_additional_pages = {}
209+
210+
# If false, no module index is generated.
211+
#html_domain_indices = True
212+
213+
# If false, no index is generated.
214+
#html_use_index = True
215+
216+
# If true, the index is split into individual pages for each letter.
217+
#html_split_index = False
218+
219+
# If true, links to the reST sources are added to the pages.
220+
#html_show_sourcelink = True
221+
222+
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
223+
#html_show_sphinx = True
224+
225+
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
226+
#html_show_copyright = True
227+
228+
# If true, an OpenSearch description file will be output, and all pages will
229+
# contain a <link> tag referring to it. The value of this option must be the
230+
# base URL from which the finished HTML is served.
231+
#html_use_opensearch = ''
232+
233+
# This is the file name suffix for HTML files (e.g. ".xhtml").
234+
#html_file_suffix = None
235+
236+
# Output file base name for HTML help builder.
237+
htmlhelp_basename = 'ReadtheDocsTemplatedoc'
238+
239+
240+
# -- Options for LaTeX output ---------------------------------------------
241+
242+
latex_elements = {
243+
# The paper size ('letterpaper' or 'a4paper').
244+
#'papersize': 'letterpaper',
245+
246+
# The font size ('10pt', '11pt' or '12pt').
247+
#'pointsize': '10pt',
248+
249+
# Additional stuff for the LaTeX preamble.
250+
#'preamble': '',
251+
}
252+
253+
# Grouping the document tree into LaTeX files. List of tuples
254+
# (source start file, target name, title,
255+
# author, documentclass [howto, manual, or own class]).
256+
latex_documents = [
257+
('index', 'ReadtheDocsTemplate.tex', u'Read the Docs Template Documentation',
258+
u'Read the Docs', 'manual'),
259+
]
260+
261+
# The name of an image file (relative to this directory) to place at the top of
262+
# the title page.
263+
#latex_logo = None
264+
265+
# For "manual" documents, if this is true, then toplevel headings are parts,
266+
# not chapters.
267+
#latex_use_parts = False
268+
269+
# If true, show page references after internal links.
270+
#latex_show_pagerefs = False
271+
272+
# If true, show URL addresses after external links.
273+
#latex_show_urls = False
274+
275+
# Documents to append as an appendix to all manuals.
276+
#latex_appendices = []
277+
278+
# If false, no module index is generated.
279+
#latex_domain_indices = True
280+
281+
282+
# -- Options for manual page output ---------------------------------------
283+
284+
# One entry per manual page. List of tuples
285+
# (source start file, name, description, authors, manual section).
286+
man_pages = [
287+
('index', 'readthedocstemplate', u'Read the Docs Template Documentation',
288+
[u'Read the Docs'], 1)
289+
]
290+
291+
# If true, show URL addresses after external links.
292+
#man_show_urls = False
293+
294+
295+
# -- Options for Texinfo output -------------------------------------------
296+
297+
# Grouping the document tree into Texinfo files. List of tuples
298+
# (source start file, target name, title, author,
299+
# dir menu entry, description, category)
300+
texinfo_documents = [
301+
('index', 'ReadtheDocsTemplate', u'Read the Docs Template Documentation',
302+
u'Read the Docs', 'ReadtheDocsTemplate', 'One line description of project.',
303+
'Miscellaneous'),
304+
]
305+
306+
# Documents to append as an appendix to all manuals.
307+
#texinfo_appendices = []
308+
309+
# If false, no module index is generated.
310+
#texinfo_domain_indices = True
311+
312+
# How to display URL addresses: 'footnote', 'no', or 'inline'.
313+
#texinfo_show_urls = 'footnote'
314+
315+
# If true, do not generate a @detailmenu in the "Top" node's menu.
316+
#texinfo_no_detailmenu = False
317+
318+
# -- Use sphinx_rtd_theme for local builds --------------------------------
319+
# ref. https://github.com/snide/sphinx_rtd_theme#using-this-theme-locally-then-building-on-read-the-docs
320+
#
321+
# on_rtd is whether we are on readthedocs.org
322+
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
323+
324+
if not on_rtd: # only import and set the theme if we're building docs locally
325+
import sphinx_rtd_theme
326+
html_theme = 'sphinx_rtd_theme'
327+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
328+
329+
# otherwise, readthedocs.org uses their theme by default, so no need to specify it

0 commit comments

Comments
 (0)