Generate PDF documentation

- Add a new pdf-docs environment to enable PDF build.
- sphinxcontrib-svg2pdfconverter is used to handle SVG properly.
- maxlistdepth=10 in latex_elements is needed to handle
  deeper levels of nesting.
- Specify openany in extraclassoptions to skip blank pages
  (oneside is also specified to use the same page layout
   for even and odd pages)
- tocdepth is set to 2 for better PDF TOC
- printindex and makeindex are set to empty in latex_elements
  to avoid an empty "Index" section in PDF
- Sample config/policy files are skipped in the PDF document
  as inline sample files cause LaTeX error [1] and direct links
  in PDF doc is discouraged. Note that sample-config and sample-policy
  need to be excluded to avoid the LaTeX error [1] and
  :orphan: is specified in those files.

[1] https://github.com/sphinx-doc/sphinx/issues/3099

Change-Id: I70100a71114e1d75833e6c783086325baa0e3fd2
This commit is contained in:
Arthur Dayne 2019-10-03 15:50:45 +08:00 committed by Brin Zhang
parent c8c7ceff43
commit 31d23b7315
4 changed files with 55 additions and 12 deletions

View File

@ -2,11 +2,11 @@
# of appearance. Changing the order has an impact on the overall integration # of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
sphinx!=1.6.6,!=1.6.7,>=1.6.2,<2.0.0;python_version=='2.7' # BSD sphinx>=1.8.0,!=2.1.0 # BSD
sphinx!=1.6.6,!=1.6.7,>=1.6.2;python_version>='3.4' # BSD
sphinxcontrib-httpdomain>=1.3.0 # BSD sphinxcontrib-httpdomain>=1.3.0 # BSD
sphinxcontrib-pecanwsme>=0.2 # Apache-2.0 sphinxcontrib-pecanwsme>=0.2 # Apache-2.0
sphinxcontrib-seqdiag>=0.8.4 # BSD sphinxcontrib-seqdiag>=0.8.4 # BSD
sphinxcontrib-svg2pdfconverter>=0.1.0 # BSD
reno>=2.5.0 # Apache-2.0 reno>=2.5.0 # Apache-2.0
os-api-ref>=1.4.0 # Apache-2.0 os-api-ref>=1.4.0 # Apache-2.0
openstackdocstheme>=1.20.0 # Apache-2.0 openstackdocstheme>=1.20.0 # Apache-2.0

View File

@ -22,12 +22,12 @@ sys.path.insert(0, os.path.abspath('../..'))
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [ extensions = [
'sphinx.ext.autodoc', 'sphinx.ext.autodoc',
#'sphinx.ext.intersphinx',
'openstackdocstheme', 'openstackdocstheme',
'oslo_config.sphinxconfiggen', 'oslo_config.sphinxconfiggen',
'oslo_config.sphinxext', 'oslo_config.sphinxext',
'oslo_policy.sphinxext', 'oslo_policy.sphinxext',
'oslo_policy.sphinxpolicygen', 'oslo_policy.sphinxpolicygen',
'sphinxcontrib.rsvgconverter',
] ]
# autodoc generation is a bit aggressive and a nuisance when doing heavy # autodoc generation is a bit aggressive and a nuisance when doing heavy
@ -85,13 +85,35 @@ htmlhelp_basename = 'cyborgdoc'
html_title = 'Cyborg' html_title = 'Cyborg'
html_theme = 'openstackdocs' html_theme = 'openstackdocs'
# -- Options for LaTeX output -------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
# openany: Skip blank pages in generated PDFs
'maxlistdepth': 10,
'extraclassoptions': 'openany,oneside',
'preamble': r'\setcounter{tocdepth}{2}',
'makeindex': '',
'printindex': '',
}
# Disable usage of xindy https://bugzilla.redhat.com/show_bug.cgi?id=1643664
# Some distros are missing xindy
latex_use_xindy = False
# Grouping the document tree into LaTeX files. List of tuples # Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass # (source start file, target name, title, author, documentclass
# [howto/manual]). # [howto/manual]).
latex_documents = [ latex_documents = [
('index', ('index',
'cyborg.tex', 'doc-cyborg.tex',
u'cyborg Documentation', u'Cyborg Documentation',
u'OpenStack Foundation', 'manual'), u'OpenStack Foundation', 'manual'),
] ]

View File

@ -2,6 +2,16 @@
Cyborg Configuration Sample Cyborg Configuration Sample
=========================== ===========================
.. NOTE(acewit): literalinclude of sample config files causes
LaTeX error (TeX capacity exceeded), so they are skipped in PDF version.
.. only:: latex
Sample configuration files for all Cyborg services are found in
the online version of this documentation.
.. only:: html
The following is a sample cyborg configuration for adaptation and use. It is The following is a sample cyborg configuration for adaptation and use. It is
auto-generated from cyborg when this documentation is built, so if you are auto-generated from cyborg when this documentation is built, so if you are
having issues with an option, please compare your version of cyborg with the having issues with an option, please compare your version of cyborg with the

13
tox.ini
View File

@ -9,7 +9,9 @@ ignore_basepython_conflict = True
[testenv] [testenv]
usedevelop = True usedevelop = True
whitelist_externals = rm whitelist_externals =
rm
make
install_command = {[testenv:common-constraints]install_command} install_command = {[testenv:common-constraints]install_command}
basepython = python3 basepython = python3
setenv = setenv =
@ -78,8 +80,17 @@ ignore-path = .venv,.git,.tox,*cyborg/locale*,*lib/python*,*cyborg.egg*,api-ref/
[testenv:docs] [testenv:docs]
deps = -r{toxinidir}/doc/requirements.txt deps = -r{toxinidir}/doc/requirements.txt
commands = commands =
rm -rf doc/build/html
sphinx-build -W -b html doc/source doc/build/html sphinx-build -W -b html doc/source doc/build/html
[testenv:pdf-docs]
envdir = {toxworkdir}/docs
deps = {[testenv:docs]deps}
commands =
rm -rf doc/build/pdf
sphinx-build -W -b latex doc/source doc/build/pdf
make -C doc/build/pdf
[testenv:releasenotes] [testenv:releasenotes]
deps = -r{toxinidir}/doc/requirements.txt deps = -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -a -W -E -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html commands = sphinx-build -a -W -E -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html