Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
Commit 8f92b487 authored by Deepak Khatri's avatar Deepak Khatri :dog:
Browse files

Control PDF build with conf.yml

parent 13df619b
Branches
Tags
1 merge request!89Docs updates - chapter restructuring, images, and more
{% for board_path in boards_path %}
{% if board_path+'/' in pagename %}
{% set pdf_name = board_path.split('/')[-1] %}
{% for pdf_path in pdf_paths %}
{% if pdf_path+'/' in pagename %}
{% set pdf_name = '-'.join(pdf_path.split('/')[1:]) %}
<a role="button" href="{{docs_url}}/{{pdf_name}}.pdf" target="_blank">
<i class="fa-solid fa-download"></i> Download PDF
</a>
......
......@@ -18,8 +18,7 @@ distribution. In the box you will find:
:align: center
:alt: BeagleBone AI Overview
.. tip:: For board files, 3D model, regulatory docs and more, you can checkout
`BeagleBona-AI repository on OpenBeagle <https://openbeagle.org/beagleboard/beaglebone-ai/>`_.
.. tip:: For board files, 3D model, regulatory docs and more, you can checkout `BeagleBona-AI repository on OpenBeagle <https://openbeagle.org/beagleboard/beaglebone-ai/>`_.
What’s Not in the Box
**********************
......
......@@ -7,22 +7,52 @@
import os
import sys
import re
import yaml
from pathlib import Path
import pydata_sphinx_theme
from sphinx.ext.imgconverter import ImagemagickConverter
# -- Project information --
project = 'BeagleBoard Docs'
copyright = '2024, BeagleBoard.org Foundation'
author = 'BeagleBoard.org Foundation'
ImagemagickConverter.conversion_rules.append(('image/webp', 'image/png'))
sys.path.append(str(Path(".").resolve()))
rst_epilog =""
# Add latest images to rst_epilog
rst_epilog =""
rst_epilog_path = "_static/epilog/"
for (dirpath, dirnames, filenames) in os.walk(rst_epilog_path):
for filename in filenames:
with open(dirpath + filename) as f:
rst_epilog += f.read()
rst_epilog += f.read()
# Configure PDF build and sidebar links
latex_documents = []
pdf_paths = []
pdf_list = []
with open('conf.yml', 'r') as conf_file:
conf_data = yaml.safe_load(conf_file)
pdf_build_all = True
if(conf_data["pdf_build"] != "all"):
pdf_list = conf_data["pdf_build"].split(",")
pdf_build_all = False
for type, data in conf_data.items():
# Boards
if(type == "boards"):
for board, data in conf_data["boards"].items():
name = board
path = data['path']
pdf = data.get('pdf', False)
if(pdf and (name in pdf_list or pdf_build_all)):
pdf_paths.append(path)
tex_name = '-'.join(path.split('/')[1:])
latex_documents.append((path+"/index", tex_name+".tex", "", author, "manual"))
# Board OSHWA certification information
oshw_logos_path = "_static/images/oshw/"
......@@ -35,21 +65,16 @@ for (dirpath, dirnames, filenames) in os.walk(oshw_logos_path):
path = path.replace('@','/')
oshw_details.append([board, path, oshw_id])
print(oshw_details)
# Unique boards path information
boards_path = []
for board, path, oshw_id in oshw_details:
for (dirpath, dirnames, filenames) in os.walk("boards"):
if '/'+path+'/' in dirpath+'/':
if path+'/' not in dirpath:
boards_path.append(dirpath)
boards_path = set(boards_path)
print(boards_path)
# -- Project information --
project = 'BeagleBoard Docs'
copyright = '2024, BeagleBoard.org Foundation'
author = 'BeagleBoard.org Foundation'
# boards_path = []
# for board, path, oshw_id in oshw_details:
# for (dirpath, dirnames, filenames) in os.walk("boards"):
# if '/'+path+'/' in dirpath+'/':
# if path+'/' not in dirpath:
# boards_path.append(dirpath)
# boards_path = set(boards_path)
# print(boards_path)
# -- General configuration --
......@@ -93,8 +118,7 @@ todo_include_todos = True
# Update (HTML) supported_image_types selection priority order
from sphinx.builders.html import StandaloneHTMLBuilder
StandaloneHTMLBuilder.supported_image_types = ['image/webp', 'image/jpg',
'image/jpeg', 'image/svg+xml', 'image/png', 'image/gif']
StandaloneHTMLBuilder.supported_image_types = ['image/webp', 'image/jpg', 'image/jpeg', 'image/svg+xml', 'image/png', 'image/gif']
# Update (PDF) supported_image_types selection priority order
from sphinx.builders.latex import LaTeXBuilder
......@@ -282,13 +306,12 @@ html_context = {
"edit_page_provider_name": "OpenBeagle",
"my_vcs_site": "https://openbeagle.org/docs/docs.beagleboard.io/-/edit/main/",
"oshw_details": oshw_details,
"boards_path": boards_path
"pdf_paths": pdf_paths
}
# -- Options for LaTeX output --
latex_engine = "xelatex"
latex_logo = "_static/images/logo-latex.pdf"
latex_documents = []
latex_elements = {
"papersize": "a4paper",
"maketitle": open("_static/latex/title.tex").read(),
......@@ -303,8 +326,4 @@ latex_elements = {
r"HeaderFamily=\rmfamily\bfseries",
)
),
}
for board_path in boards_path:
board_tex_name = board_path.split('/')[-1]
latex_documents.append((board_path+"/index", board_tex_name+".tex", "", author, "manual"))
\ No newline at end of file
}
\ No newline at end of file
conf.yml 0 → 100644
# YAML file to configure PDF build and sidebar links
# PDF buils configuration
#
# all: If you want to build PDFs of all the listed boards, books, projects, etc.
#
# name1,name2,name3: If you want to build PDF for specific boards, books, projects, etc.
# Example: pdf_build: BeagleBone Black,BeagleBone AI-64
# Note: there is now space after comma!
pdf_build: all
# Boards
boards:
BeagleBone Black:
path: boards/beaglebone/black
pdf: True
BeagleBone AI-64:
path: boards/beaglebone/ai-64
pdf: True
# Books
books:
BeagleBone Cookbook:
path: books/beaglebone-cookbook
......@@ -36,3 +36,4 @@ sphinxcontrib-svg2pdfconverter==1.2.2
sphinxcontrib-youtube==1.4.1
tornado==6.4
urllib3==2.1.0
pyyaml>=3.13
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment