From adaf0b1132527b1f67cb8428067a883e8be18b33 Mon Sep 17 00:00:00 2001 From: "Ian Y. Choi" Date: Wed, 1 Mar 2017 16:47:58 +0000 Subject: [PATCH] PDF support for sample document with font This commit enables the sample document to support PDF builds with Liberation font. Since current Jenkins gate has docs build but does not have publish-docs build, PDF builds are done in docs tox build job. Change-Id: I9d40ac0bf179075c102170f9560629989520e12f Implements: blueprint build-pdf-from-rst-guides Co-Authored-By: SeongSoo Cho --- bindep.txt | 7 ++++++ doc/source/conf.py | 24 ++++++++++++++----- .../theme/openstackdocs_pdf/pdftheme.sty | 7 ++++++ tox.ini | 6 ++++- 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/bindep.txt b/bindep.txt index 4d5e14c5..1a936400 100644 --- a/bindep.txt +++ b/bindep.txt @@ -1,6 +1,8 @@ # This is a cross-platform list tracking distribution packages needed by tests; # see http://docs.openstack.org/infra/bindep/ for additional information. +fonts-lmodern [platform:dpkg] +fonts-liberation [platform:dpkg] libxml2-dev [platform:dpkg] libxml2-devel [platform:rpm] libxml2-utils [platform:dpkg] @@ -13,3 +15,8 @@ python3-devel [platform:fedora] python34-devel [platform:centos] zlib-devel [platform:rpm] zlib1g-dev [platform:dpkg] +inkscape +texlive-latex-base [platform:dpkg] +texlive-latex-extra [platform:dpkg] +texlive-xetex [platform:dpkg] +texlive-fonts-recommended [platform:dpkg] diff --git a/doc/source/conf.py b/doc/source/conf.py index 331574a1..bd734721 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -24,6 +24,12 @@ import openstackdocstheme # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) +# Release name for PDF documents +latex_custom_template = r""" +\usepackage{""" + openstackdocstheme.get_pdf_theme_path() + """} +\\newcommand{\openstacklogo}{""" + openstackdocstheme.get_openstack_logo_path() + """} +""" + # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. @@ -216,16 +222,22 @@ htmlhelp_basename = 'os-doc-demodoc' # -- Options for LaTeX output --------------------------------------------- +latex_engine = 'xelatex' latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', + # The paper size ('letterpaper' or 'a4paper'). + 'papersize': 'a4paper', -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', + # The font size ('10pt', '11pt' or '12pt'). + 'pointsize': '11pt', -# Additional stuff for the LaTeX preamble. -#'preamble': '', + #Default figure align + 'figure_align': 'H', + + # Not to generate blank page after chapter + 'classoptions': ',openany', + # Additional stuff for the LaTeX preamble. + 'preamble': latex_custom_template, } # Grouping the document tree into LaTeX files. List of tuples diff --git a/openstackdocstheme/theme/openstackdocs_pdf/pdftheme.sty b/openstackdocstheme/theme/openstackdocs_pdf/pdftheme.sty index 2d335704..7da70163 100644 --- a/openstackdocstheme/theme/openstackdocs_pdf/pdftheme.sty +++ b/openstackdocstheme/theme/openstackdocs_pdf/pdftheme.sty @@ -52,3 +52,10 @@ % Do not use chapter and section number \setcounter{secnumdepth}{-1} + +% Font selection (English) +\usepackage{fontspec} +\defaultfontfeatures{Scale=MatchLowercase} +\setmainfont{Liberation Serif} +\setsansfont{Liberation Sans} +\setmonofont[SmallCapsFont={Liberation Mono}]{Liberation Mono} diff --git a/tox.ini b/tox.ini index c7406de8..c2a51a98 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,9 @@ setenv = VIRTUAL_ENV={envdir} BRANCH_NAME=master CLIENT_NAME=openstackdocstheme sitepackages = False -whitelist_externals = rm +whitelist_externals = + rm + make [testenv:pep8] commands = @@ -23,6 +25,8 @@ commands = {posargs} commands = rm -rf doc/build api-ref/build python setup.py build_sphinx + sphinx-build -a -E -W -d doc/build/doctrees -b latex doc/source doc/build/pdf + make -C doc/build/pdf sphinx-build -a -E -W -d api-ref/build/doctrees -b html api-ref/source api-ref/build/html [testenv:releasenotes]