Compare commits

...

1 Commits

Author SHA1 Message Date
c8be6ff19d Added sphinx latex templates for customizing PDF output 2024-08-06 09:08:14 +00:00
7 changed files with 333 additions and 0 deletions

View File

@ -131,3 +131,5 @@ latex_documents = [
{% endif -%} {% endif -%}
] ]
# Path for the latex templates
templates_path = ['_templates']

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,74 @@
\begin{savenotes}
\sphinxatlongtablestart
\sphinxthistablewithglobalstyle
<% if 'booktabs' in table.styles -%>
\sphinxthistablewithbooktabsstyle
<% endif -%>
<% if 'borderless' in table.styles -%>
\sphinxthistablewithborderlessstyle
<% endif -%>
<% if 'standard' in table.styles -%>
\sphinxthistablewithstandardstyle
<% endif -%>
<% if 'vlines' in table.styles -%>
\sphinxthistablewithvlinesstyle
<% endif -%>
<% if 'novlines' in table.styles -%>
\sphinxthistablewithnovlinesstyle
<% endif -%>
<% if 'colorrows' in table.styles -%>
\sphinxthistablewithcolorrowsstyle
<% endif -%>
<% if 'nocolorrows' in table.styles -%>
\sphinxthistablewithnocolorrowsstyle
<% endif -%>
\makeatletter
<%- if table.align in ('center', 'default') %>
\LTleft \@totalleftmargin plus1fill
\LTright\dimexpr\columnwidth-\@totalleftmargin-\linewidth\relax plus1fill
<%- elif table.align == 'left' %>
\LTleft \@totalleftmargin
\LTright\dimexpr\columnwidth-\@totalleftmargin-\linewidth\relax plus1fill
<%- elif table.align == 'right' %>
\LTleft \@totalleftmargin plus1fill
\LTright\dimexpr\columnwidth-\@totalleftmargin-\linewidth\relax
<%- endif %>
\makeatother
\begin{longtable}<%= table.get_colspec() %>
<%- if table.caption -%>
\sphinxthelongtablecaptionisattop
\caption{<%= ''.join(table.caption) %>\strut}<%= labels %>\\*[\sphinxlongtablecapskipadjust]
<% elif labels -%>
\noalign{\phantomsection<%= labels %>}%
<% endif -%>
\sphinxtoprule
<%= ''.join(table.header) -%>
<%- if table.header -%>
\sphinxmidrule
<% endif -%>
\endfirsthead
\multicolumn{<%= table.colcount %>}{c}{\sphinxnorowcolor
\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} <%= _('continued from previous page') %>}}%
}\\
\sphinxtoprule
<%= ''.join(table.header) -%>
<%- if table.header -%>
\sphinxmidrule
<% endif -%>
\endhead
\sphinxbottomrule
\multicolumn{<%= table.colcount %>}{r}{\sphinxnorowcolor
\makebox[0pt][r]{\sphinxtablecontinued{<%= _('continues on next page') %>}}%
}\\
\endfoot
\endlastfoot
\sphinxtableatstartofbodyhook
<%= ''.join(table.body) -%>
\sphinxbottomrule
\end{longtable}
\sphinxtableafterendhook
\sphinxatlongtableend
\end{savenotes}

View File

@ -0,0 +1,21 @@
%
% sphinxmessages.sty
%
% message resources for Sphinx
%
\ProvidesPackage{sphinxmessages}[2019/01/04 v2.0 Localized LaTeX macros (Sphinx team)]
\renewcommand{\literalblockcontinuedname}{<%= _('continued from previous page') | e %>}
\renewcommand{\literalblockcontinuesname}{<%= _('continues on next page') | e %>}
\renewcommand{\sphinxnonalphabeticalgroupname}{<%= _('Non-alphabetical') | e %>}
\renewcommand{\sphinxsymbolsname}{<%= _('Symbols') | e %>}
\renewcommand{\sphinxnumbersname}{<%= _('Numbers') | e %>}
\def\pageautorefname{<%= _('page') | e %>}
<%= addtocaptions %>{\renewcommand{\figurename}{<%= figurename[0] | e | eabbr %>}}
\def\fnum@figure{\figurename\thefigure{}<%= figurename[1] | e %>}
<%= addtocaptions %>{\renewcommand{\tablename}{<%= tablename[0] | e | eabbr %>}}
\def\fnum@table{\tablename\thetable{}<%= tablename[1] | e %>}
<%= addtocaptions %>{\renewcommand{\literalblockname}{<%= literalblockname[0].strip() %>}}

View File

@ -0,0 +1,54 @@
\begin{savenotes}\sphinxattablestart
\sphinxthistablewithglobalstyle
<% if 'booktabs' in table.styles -%>
\sphinxthistablewithbooktabsstyle
<% endif -%>
<% if 'borderless' in table.styles -%>
\sphinxthistablewithborderlessstyle
<% endif -%>
<% if 'standard' in table.styles -%>
\sphinxthistablewithstandardstyle
<% endif -%>
<% if 'vlines' in table.styles -%>
\sphinxthistablewithvlinesstyle
<% endif -%>
<% if 'novlines' in table.styles -%>
\sphinxthistablewithnovlinesstyle
<% endif -%>
<% if 'colorrows' in table.styles -%>
\sphinxthistablewithcolorrowsstyle
<% endif -%>
<% if 'nocolorrows' in table.styles -%>
\sphinxthistablewithnocolorrowsstyle
<% endif -%>
<% if table.align -%>
<%- if table.align in ('center', 'default') -%>
\centering
<%- elif table.align == 'left' -%>
\raggedright
<%- else -%>
\raggedleft
<%- endif %>
<%- else -%>
\centering
<%- endif %>
<% if table.caption -%>
\sphinxcapstartof{table}
\sphinxthecaptionisattop
\sphinxcaption{<%= ''.join(table.caption) %>}<%= labels %>
\sphinxaftertopcaption
<% elif labels -%>
\phantomsection<%= labels %>\nobreak
<% endif -%>
\begin{tabular}[t]<%= table.get_colspec() -%>
\sphinxtoprule
<%= ''.join(table.header) -%>
<%- if table.header -%>
\sphinxmidrule
<% endif -%>
\sphinxtableatstartofbodyhook
<%=- ''.join(table.body) -%>
\sphinxbottomrule
\end{tabular}
\sphinxtableafterendhook\par
\sphinxattableend\end{savenotes}

View File

@ -0,0 +1,54 @@
\begin{savenotes}\sphinxattablestart
\sphinxthistablewithglobalstyle
<% if 'booktabs' in table.styles -%>
\sphinxthistablewithbooktabsstyle
<% endif -%>
<% if 'borderless' in table.styles -%>
\sphinxthistablewithborderlessstyle
<% endif -%>
<% if 'standard' in table.styles -%>
\sphinxthistablewithstandardstyle
<% endif -%>
<% if 'vlines' in table.styles -%>
\sphinxthistablewithvlinesstyle
<% endif -%>
<% if 'novlines' in table.styles -%>
\sphinxthistablewithnovlinesstyle
<% endif -%>
<% if 'colorrows' in table.styles -%>
\sphinxthistablewithcolorrowsstyle
<% endif -%>
<% if 'nocolorrows' in table.styles -%>
\sphinxthistablewithnocolorrowsstyle
<% endif -%>
<% if table.align -%>
<%- if table.align in ('center', 'default') -%>
\centering
<%- elif table.align == 'left' -%>
\raggedright
<%- else -%>
\raggedleft
<%- endif %>
<%- else -%>
\centering
<%- endif %>
<% if table.caption -%>
\sphinxcapstartof{table}
\sphinxthecaptionisattop
\sphinxcaption{<%= ''.join(table.caption) %>}<%= labels %>
\sphinxaftertopcaption
<% elif labels -%>
\phantomsection<%= labels %>\nobreak
<% endif -%>
\begin{tabulary}{\linewidth}[t]<%= table.get_colspec() -%>
\sphinxtoprule
<%= ''.join(table.header) -%>
<%- if table.header -%>
\sphinxmidrule
<% endif -%>
\sphinxtableatstartofbodyhook
<%=- ''.join(table.body) -%>
\sphinxbottomrule
\end{tabulary}
\sphinxtableafterendhook\par
\sphinxattableend\end{savenotes}

View File

@ -15,8 +15,10 @@
import argparse import argparse
import logging import logging
import os.path
import pathlib import pathlib
import requests import requests
import shutil
import subprocess import subprocess
from git import exc from git import exc
@ -48,6 +50,7 @@ def process_repositories(args, service):
env = Environment( env = Environment(
loader=PackageLoader("otc_metadata"), autoescape=select_autoescape() loader=PackageLoader("otc_metadata"), autoescape=select_autoescape()
) )
metadata_path = os.path.dirname(os.path.abspath(os.path.dirname(__file__)))
conf_py_template = env.get_template("conf.py.j2") conf_py_template = env.get_template("conf.py.j2")
tox_ini_template = env.get_template("tox.ini.j2") tox_ini_template = env.get_template("tox.ini.j2")
zuul_yaml_template = env.get_template("zuul.yaml.j2") zuul_yaml_template = env.get_template("zuul.yaml.j2")
@ -130,6 +133,23 @@ def process_repositories(args, service):
logging.debug(f"Analyzing document {doc}") logging.debug(f"Analyzing document {doc}")
conf_py_path = pathlib.Path(copy_to, doc["rst_location"], "conf.py") conf_py_path = pathlib.Path(copy_to, doc["rst_location"], "conf.py")
latex_templates_src_path = pathlib.Path(metadata_path, "otc_metadata", "templates", "latex_templates")
latex_templates_dest_path = pathlib.Path(copy_to, doc["rst_location"], "_templates")
# Check if the latex destination path exists and is a directory
if not latex_templates_dest_path.exists():
logging.info(f"Path for latex templates in {doc['title']} does not exist")
latex_templates_dest_path.mkdir(parents=True, exist_ok=True)
# Delete all files in the latex destination directory
for file in latex_templates_dest_path.iterdir():
if file.is_file():
file.unlink()
# Add the new templates
for file in latex_templates_src_path.iterdir():
shutil.copy2(file, latex_templates_dest_path)
if not conf_py_path.exists(): if not conf_py_path.exists():
logging.info(f"Path for document {doc['title']} does not exist") logging.info(f"Path for document {doc['title']} does not exist")
conf_py_path.parent.mkdir(parents=True, exist_ok=True) conf_py_path.parent.mkdir(parents=True, exist_ok=True)