From eca15c1c409bc88ef9617d8f18f3890b22f7a905 Mon Sep 17 00:00:00 2001 From: whoami-rajat Date: Tue, 17 Sep 2019 13:53:57 +0530 Subject: [PATCH] Generate PDF documentation This commit adds a new tox target to build PDF documentation. It's a part of community goal, see storyboard for more information. Change-Id: I04b9253ae30ec125e45a272f0c7ce384c7770372 Story: 2006076 Task: 35607 --- doc/requirements.txt | 2 ++ doc/source/conf.py | 18 ++++++++++++++++-- tox.ini | 13 ++++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 doc/requirements.txt diff --git a/doc/requirements.txt b/doc/requirements.txt new file mode 100644 index 0000000..9638eea --- /dev/null +++ b/doc/requirements.txt @@ -0,0 +1,2 @@ +openstackdocstheme>=1.30.0 # Apache-2.0 +sphinxcontrib-svg2pdfconverter>=0.1.0 # BSD \ No newline at end of file diff --git a/doc/source/conf.py b/doc/source/conf.py index c921783..cdb60fe 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -23,6 +23,7 @@ extensions = [ 'sphinx.ext.autodoc', # 'sphinx.ext.intersphinx', 'openstackdocstheme', + 'sphinxcontrib.rsvgconverter' ] # autodoc generation is a bit aggressive and a nuisance when doing heavy @@ -64,14 +65,27 @@ htmlhelp_basename = '%sdoc' % project # html_last_updated_fmt = '%b %d, %Y' html_last_updated_fmt = '%Y-%m-%d %H:%M' +# Disable usage of xindy https://bugzilla.redhat.com/show_bug.cgi?id=1643664 +latex_use_xindy = False + +latex_domain_indices = False + +latex_elements = { + 'makeindex': '', + 'printindex': '', + 'preamble': r'\setcounter{tocdepth}{3}', +} + # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass # [howto/manual]). +# NOTE: Specify toctree_only=True for a better document structure of +# the generated PDF file. latex_documents = [ ('index', - '%s.tex' % project, + 'doc-%s.tex' % project, u'%s Documentation' % project, - u'OpenStack Foundation', 'manual'), + u'OpenStack Foundation', 'manual', True), ] # Example configuration for intersphinx: refer to the Python standard library. diff --git a/tox.ini b/tox.ini index 669d6ef..e3ae816 100644 --- a/tox.ini +++ b/tox.ini @@ -59,7 +59,18 @@ commands = python setup.py test --coverage --testr-args='{posargs}' [testenv:docs] basepython = python3 -commands = python setup.py build_sphinx +deps = -r{toxinidir}/doc/requirements.txt +commands = sphinx-build -W -b html -d doc/build/doctrees doc/source doc/build/html + +[testenv:pdf-docs] +basepython = python3 +deps = -r{toxinidir}/doc/requirements.txt +envdir = {toxworkdir}/docs +whitelist_externals = + make +commands = + sphinx-build -W -b latex doc/source doc/build/pdf + make -C doc/build/pdf [flake8] # E123, E125 skipped as they are invalid PEP-8.