Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github action to check for docs generator build errors during PRs #317

Merged
merged 8 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/generate_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Apt update
run: sudo apt update
- name: Install prereqs
run: sudo apt install python3-pip inkscape texlive-latex-extra -y
- name: Pip installs
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/generate_docs_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build docs to check for errors

on:
pull_request:
# only runs on PRs that target main
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Apt update
run: sudo apt update
- name: Install prereqs
run: sudo apt install python3-pip inkscape texlive-latex-extra -y
- name: Pip installs
run: sudo pip install pylatex
- name: Install a more recent version of Pandoc than available from apt or pip (to get svg support)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Install a more recent version of Pandoc than available from apt or pip (to get svg support)
# Install a more recent version of Pandoc than available from apt or pip (to get svg support)
- name: Upgrade Pandoc

run: |
wget "https://github.com/jgm/pandoc/releases/download/3.2/pandoc-3.2-linux-amd64.tar.gz"
tar -xvf pandoc-3.2-linux-amd64.tar.gz
sudo cp pandoc-3.2/bin/pandoc /usr/local/bin
- name: Build docs
run: python3 docs-generator.py
- name: Check if docs are generated
run: ls -la
- name: Check pandoc version
run: pandoc -v
9 changes: 6 additions & 3 deletions docs-generator.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run black and isort on this when you get a chance.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pylatex import Document, Section, Subsection, Subsubsection, Package, Tabular, Figure
from pylatex import Document, Section, Subsection, Subsubsection, Package, Tabular, Figure, Command
from pylatex.utils import bold, NoEscape
import json
import time
Expand Down Expand Up @@ -58,6 +58,7 @@ def gen_fields(doc, d):

geometry_options = {"tmargin": "1in", "lmargin": "1in", "rmargin": "1in", "bmargin": "1in"}
doc = Document(geometry_options=geometry_options)
doc.preamble.append(Command('title', 'SigMF')) # doesn't actually show up anywhere, but was causing a warning when not included
doc.packages.append(Package("underscore")) # makes it so _ never means math mode!
doc.packages.append(Package("xcolor", options=["table"])) # allows for \rowcolors
doc.packages.append(Package("listings"))
Expand Down Expand Up @@ -213,6 +214,8 @@ def gen_fields(doc, d):
with open("main.css", "w") as f:
f.write(css_string)

# Generate HTML
# Generate HTML from tex with Pandoc
css_url = "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
subprocess.run(f"pandoc sigmf-spec.tex -f latex -t html -s -o sigmf-spec.html --toc --toc-depth=3 -c {css_url} -c main.css".split())
pandoc_out = subprocess.run(f"pandoc sigmf-spec.tex -f latex -t html -s -o sigmf-spec.html --toc --toc-depth=3 -c {css_url} -c main.css".split(), capture_output = True, text = True)
if len(pandoc_out.stderr):
raise Exception("Pandoc error: " + pandoc_out.stderr)