Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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.

101 changes: 101 additions & 0 deletions .github/workflows/latex-python-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
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 (Ruff)
run: |
set -e

echo "Checking .py files formatting..."
PY_FAILED=0
for file in $(find . -name "*.py" -not -path "*/.*"); do
if ! ruff format --check --config ./pyproject.toml "$file"; then
echo "::error file=$file::Formatting check failed for $file."
PY_FAILED=1
fi
done

echo "Checking .ipynb files formatting..."
NB_FAILED=0
for file in $(find . -name "*.ipynb" -not -path "*/.*"); do
if ! ruff format --check --config ./pyproject.toml "$file"; then
echo "::error file=$file::Formatting check failed for $file."
echo "TIP: There is likely a trailing newline at the end of a code cell."
ruff format --diff --config ./pyproject.toml "$file"
NB_FAILED=1
fi
done

if [ $PY_FAILED -ne 0 ] || [ $NB_FAILED -ne 0 ]; then
echo "Formatting check failed. You can check by running 'ruff format .' locally."
exit 1
fi

echo "All files passed formatting!"

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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,6 @@ _site/
# Ignore folders generated by Bundler
.bundle/
vendor/

# Ignore folders generated by ruff
.ruff_cache/
47 changes: 47 additions & 0 deletions .latexindent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
onlyOneBackUp: 1
maxNumberOfBackUps: 1
backupExtension: .libak

defaultIndent: "\t"
lookAtTheseModifyLineBreaks:
environments: 1
commands: 0
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
condenseMultipleBlankLinesInto: 1

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"
]
}
23 changes: 23 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"latex-workshop.formatting.latexindent.path": "latexindent",
"latex-workshop.formatting.latexindent.args": [
"-m",
"-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.

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