From patchwork Mon Feb 2 13:16:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John McNamara X-Patchwork-Id: 2913 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id D8EEA377E; Mon, 2 Feb 2015 14:16:15 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 36BB0376C for ; Mon, 2 Feb 2015 14:16:13 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 02 Feb 2015 05:09:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,506,1418112000"; d="scan'208";a="679665282" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 02 Feb 2015 05:16:11 -0800 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t12DG9be005972; Mon, 2 Feb 2015 13:16:09 GMT Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id t12DG901027113; Mon, 2 Feb 2015 13:16:09 GMT Received: (from jmcnam2x@localhost) by sivswdev02.ir.intel.com with id t12DG9YU027109; Mon, 2 Feb 2015 13:16:09 GMT From: John McNamara To: dev@dpdk.org Date: Mon, 2 Feb 2015 13:16:05 +0000 Message-Id: <1422882967-27060-3-git-send-email-john.mcnamara@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1422882967-27060-1-git-send-email-john.mcnamara@intel.com> References: <1421255657-19521-1-git-send-email-john.mcnamara@intel.com> <1422882967-27060-1-git-send-email-john.mcnamara@intel.com> Subject: [dpdk-dev] [PATCH v3 2/4] doc: Add Sphinx config to build pdf version of guides X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add Python Sphinx config to allow conversion of guides to Latex and then PDF format. This mainly adds metadata but also includes an override to the Latex formatter to control the font size in code blocks. Signed-off-by: John McNamara --- doc/guides/conf.py | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 43 insertions(+), 1 deletions(-) diff --git a/doc/guides/conf.py b/doc/guides/conf.py index 385af03..9f546bd 100644 --- a/doc/guides/conf.py +++ b/doc/guides/conf.py @@ -29,11 +29,53 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import subprocess +from sphinx.highlighting import PygmentsBridge +from pygments.formatters.latex import LatexFormatter project = 'DPDK' copyright = '2014, Intel' -version = subprocess.check_output(["make","-sRrC","../../", "showversion"]) +version = subprocess.check_output(['make', '-sRrC', '../../', 'showversion']) +release = version master_doc = 'index' + +# Latex directives to be included directly in the latex/pdf docs. +latex_preamble = r""" +\usepackage[utf8]{inputenc} +\usepackage{DejaVuSansMono} +\usepackage[T1]{fontenc} +\usepackage{helvet} +\renewcommand{\familydefault}{\sfdefault} + +\RecustomVerbatimEnvironment{Verbatim}{Verbatim}{xleftmargin=5mm} +""" + +# Configuration for the latex/pdf docs. +latex_elements = { + 'papersize': 'a4paper', + 'pointsize': '11pt', + 'preamble': latex_preamble} + +latex_documents = [ + ('index', + 'dpdk_doc.tex', + '', + '', + 'manual')] + + +# Temp class to override the default Latex formatter in order to modify the +# font size in the code/verbatim blocks. +class CustomLatexFormatter(LatexFormatter): + + def __init__(self, **options): + + super(CustomLatexFormatter, self).__init__(**options) + + # Use the second smallest font size for code/verbatim blocks. + self.verboptions = r'formatcom=\footnotesize' + +# Replace the default latex formatter. +PygmentsBridge.latex_formatter = CustomLatexFormatter