Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 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
29 changes: 0 additions & 29 deletions .github/workflows/latex-ci.yml

This file was deleted.

81 changes: 81 additions & 0 deletions .github/workflows/latex-python-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: LaTeX + Python CI
on:
pull_request:
branches:
- main
jobs:
format-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install latexindent binary
run: |
set -e
curl -L -o latexindent-linux \
https://github.com/cmhughes/latexindent.pl/releases/latest/download/latexindent-linux
chmod +x latexindent-linux
sudo mv latexindent-linux /usr/local/bin/latexindent
echo "latexindent installed at:"
which latexindent || echo "latexindent not found on PATH"

echo "latexindent verbose version info:"
latexindent -vv

- name: Check LaTeX formatting with latexindent (dry-run)
run: |
set -e
for ext in tex sty cls; do
for file in $(find . -name "*.${ext}" || true); do
formatted=$(latexindent -l=.latexindent.yml -o=- "$file")
original=$(cat "$file")
if [ "$formatted" != "$original" ]; then
echo "::error file=$file::File is not properly formatted. Please run latexindent locally."
exit 1
fi
done
done
echo "All LaTeX files are properly formatted!"


- name: Install Python format tools
run: |
python -m pip install --upgrade pip
pip install ruff

- name: Check Python + Notebook formatting with Ruff (dry-run)
run: |
set -e
for file in $(find . \( -name "*.py" -o -name "*.ipynb" \) ); do
if ! ruff format --diff --config=./pyproject.toml "$file"; then
echo "::error file=$file::File is not properly formatted."
exit 1
fi
done
echo "All Python (.py, .ipynb) files are properly formatted!"

build:
needs: format-check
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tex:
- test/testLecture.tex
- test/testExercise.tex
- test/testExam.tex
steps:
- uses: actions/checkout@v4

- name: Submodule-like setup
run: |
mkdir -p ../course_template
rsync -av --exclude='.git' . ../course_template/
mkdir -p ../../course_template
ln -s "$PWD/theme" ../../course_template/theme || true
ln -s "$PWD/style" ../../course_template/style || true

- uses: xu-cheng/latex-action@v3
with:
root_file: ${{ matrix.tex }}
args: -pdf -interaction=nonstopmode -halt-on-error -shell-escape
46 changes: 46 additions & 0 deletions .latexindent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
onlyOneBackUp: 1
maxNumberOfBackUps: 1
backupExtension: .libak

defaultIndent: ' '
lookAtTheseModifyLineBreaks:
environments: 1
commands: 1
ifElseFi: 1
items: 1
specialBeginEnd: 1

indentAfterHeadings:
section:
indentAfterThisHeading: 1
level: 1
subsection:
indentAfterThisHeading: 1
level: 2
subsubsection:
indentAfterThisHeading: 1
level: 3

alignAtAmpersand:
environments:
aligned: 1
matrix: 1
tabular: 1
array: 1
spacesAfterAmpersand: 1

modifyLineBreaks:
yaml: 1
preserveBlankLines: 0

noAdditionalIndent:
comment: 1
verbatim: 1
lstlisting: 1

preamble:
indentPreamble: 1

maximumIndentation:
environments: 10
commands: 10
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"James-Yu.latex-workshop",
"charliermarsh.ruff"
]
}
22 changes: 22 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"latex-workshop.formatting.latexindent.path": "latexindent",
"latex-workshop.formatting.latexindent.args": [
"-l=%WORKSPACE_FOLDER%/.latexindent.yml",
"%TMPFILE%",
"-o=%TMPFILE%"
],
"editor.formatOnSave": true,
"latex-workshop.formatting.latex": "latexindent",
"ruff.configuration": "./pyproject.toml",
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
"editor.defaultFormatter": "charliermarsh.ruff"
},
"notebook.formatOnSave.enabled": true,
"notebook.codeActionsOnSave": {
"notebook.source.organizeImports": "explicit"
}
}
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,12 @@ This allows you to use the LaTeX classes provided in the course template reposit
- All example themes contain a six-color palette designed to provide improved readability and accessibility for generated documents
- This color palette is taken from ["Communicating Effectively in Color" by J. W. Kimball in IEEE Power Electronics Magazine](https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=10839151&isnumber=10839145).

### Contributing

- We recommend using [VSCode](https://code.visualstudio.com/) as code editor.
- [Ruff](https://github.com/astral-sh/ruff) should be installed.

```python
pip install ruff
```
- It is expected that [LaTeX Workshop](https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop) extension and [Ruff](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) extension is installed so that formatting of the code is achieved automatically.
Loading