diff --git a/conf.py b/conf.py index 3c0a260f..7413756d 100644 --- a/conf.py +++ b/conf.py @@ -8,6 +8,7 @@ import os import sys +import yaml from pathlib import Path from typing import Any, Dict import pydata_sphinx_theme @@ -18,14 +19,33 @@ copyright = '2024, Upside Down Labs' author = 'Upside Down Labs' -# PDF path exploration -MAX_DEPTH = 2 -walk_dirpaths = ['hardware', 'kits'] +# Configure PDF build and sidebar links +latex_documents = [] pdf_paths = [] -for walk_dirpath in walk_dirpaths: - for (dirpath, dirnames, filenames) in os.walk(walk_dirpath, topdown=True): - if dirpath.count('/') == MAX_DEPTH: - pdf_paths.append(dirpath[:]) + +with open('conf.yml', 'r') as conf_file: + conf_data = yaml.safe_load(conf_file) + + pdf_build_all = True + pdf_build = [] + if(conf_data["pdf_build"] != "all"): + for name in conf_data["pdf_build"].split(","): + pdf_build.append(name.lstrip()) + pdf_build_all = False + + for type, data in conf_data.items(): + # Hardware + if(type == "hardware"): + for board, data in conf_data["hardware"].items(): + name = board + path = data['path'] + pdf = data.get('pdf', False) + + # PDF build details + if(pdf and (name in pdf_build or pdf_build_all)): + pdf_paths.append(path) + tex_name = '-'.join(path.split('/')[1:]) + latex_documents.append((path+"/index", tex_name+".tex", "", author, "manual")) # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration @@ -164,13 +184,8 @@ } # -- Options for LaTeX output -- -latex_documents = [] - +latex_engine = "xelatex" latex_elements = { "papersize": "a4paper", "preamble": open("_static/latex/preamble.tex").read(), -} - -for pdf_path in pdf_paths: - board_tex_name = pdf_path.split('/')[-1] - latex_documents.append((pdf_path+"/index", board_tex_name+".tex", "", author, "manual")) \ No newline at end of file +} \ No newline at end of file diff --git a/conf.yml b/conf.yml new file mode 100644 index 00000000..067eb23a --- /dev/null +++ b/conf.yml @@ -0,0 +1,41 @@ +# YAML file to configure PDF builds and sidebar links + +# PDF builds configuration +# +# all: If you want to build PDFs of all the listed hardware, guides, experiments, etc. +# +# name1, name2, name3: If you want to build PDF for specific hardware, guides, experiments, etc. +# Example: pdf_build: BioAmp EXG Pill, BioAmp v1.5 + +pdf_build: all + +# Hardware +# +# Example: +# hardware: +# name: +# path: First level hardware documentation path for hardware 'index.rst' +# pdf: True/False (optional, False if this 'pdf:' option is not added) + +hardware: + BioAmp EXG Pill: + path: hardware/bioamp/bioamp-exg-pill + pdf: True + BioAmp v1.5: + path: hardware/bioamp/bioamp-v1.5 + pdf: True + Muscle BioAmp BisCute: + path: hardware/bioamp/muscle-bioamp-biscute + pdf: True + Muscle BioAmp Blip: + path: hardware/bioamp/muscle-bioamp-blip + pdf: True + Muscle BioAmp Candy: + path: hardware/bioamp/muscle-bioamp-candy + pdf: True + Muscle BioAmp Patchy: + path: hardware/bioamp/muscle-bioamp-patchy + pdf: True + Muscle BioAmp Shield: + path: hardware/bioamp/muscle-bioamp-shield + pdf: True diff --git a/requirements.txt b/requirements.txt index de07cc88..1946d97f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,5 @@ docutils==0.20.1 pydata-sphinx-theme==0.15.2 sphinx_design==0.5.0 sphinxcontrib-youtube==1.4.1 -sphinx-copybutton==0.5.2 \ No newline at end of file +sphinx-copybutton==0.5.2 +pyyml==0.0.2 \ No newline at end of file