[dpdk-dev,v3,2/4] doc: Add Sphinx config to build pdf version of guides
Commit Message
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 <john.mcnamara@intel.com>
---
doc/guides/conf.py | 44 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 43 insertions(+), 1 deletions(-)
Comments
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of John McNamara
> Sent: Monday, February 2, 2015 1:16 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v3 2/4] doc: Add Sphinx config to build pdf version of guides
>
> 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 <john.mcnamara@intel.com>
> ---
> 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'
Hi John,
2014 should be 2015.
Regards,
Bernard.
>
> -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
> --
> 1.7.4.1
@@ -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