Added sphinx latex templates for customizing PDF output
Some checks failed
gl/check check status: failure (c8be6ff19d056f79bc8fd17d57b236bbaaa0aa87)

This commit is contained in:
2024-08-06 09:08:14 +00:00
parent 5773230496
commit c8be6ff19d
7 changed files with 333 additions and 0 deletions

View File

@ -15,8 +15,10 @@
import argparse
import logging
import os.path
import pathlib
import requests
import shutil
import subprocess
from git import exc
@ -48,6 +50,7 @@ def process_repositories(args, service):
env = Environment(
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")
tox_ini_template = env.get_template("tox.ini.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}")
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():
logging.info(f"Path for document {doc['title']} does not exist")
conf_py_path.parent.mkdir(parents=True, exist_ok=True)