Skip to content

Commit

Permalink
Merge branch 'upsidedownlabs:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
bhawnasehgal authored Apr 25, 2024
2 parents d0ab803 + 83395f7 commit bd95017
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 15 deletions.
42 changes: 28 additions & 14 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import os
import sys
import yaml
from pathlib import Path
from typing import Any, Dict
import pydata_sphinx_theme
Expand All @@ -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
Expand Down Expand Up @@ -164,13 +184,7 @@
}

# -- Options for LaTeX output --
latex_documents = []

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"))
}
41 changes: 41 additions & 0 deletions conf.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
sphinx-copybutton==0.5.2
pyyml==0.0.2

0 comments on commit bd95017

Please sign in to comment.