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

add docs-generating script that allows for specifying input and output path #1466

Merged
merged 9 commits into from
Dec 22, 2024
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
33 changes: 33 additions & 0 deletions .github/workflows/docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Script to generate docs based on given input directory (first argument)
and output directory (second argument)"""
import os
import subprocess
import sys
import glob
import nbformat

code_path = sys.argv[1]
out_path = sys.argv[2]

for notebook_path in glob.glob(f"{code_path}/examples/PySDM_examples/*/*.ipynb"):
with open(notebook_path, encoding="utf8") as fin:
with open(notebook_path + ".badges.md", "w", encoding="utf8") as fout:
fout.write(nbformat.read(fin, nbformat.NO_CONVERT).cells[0].source)
subprocess.run(
[
sys.executable,
"-We",
"-m",
"pdoc",
"-o",
f"{out_path}/html",
"PySDM",
"examples/PySDM_examples",
"-t",
"docs/templates",
"--math",
"--mermaid",
],
env={**os.environ, "PDOC_ALLOW_EXEC": "1"},
check=True,
)
12 changes: 3 additions & 9 deletions .github/workflows/pdoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,11 @@ jobs:
pip install -e .
pip install -e examples

python - <<EOF
import glob, nbformat
for notebook_path in glob.glob('examples/PySDM_examples/*/*.ipynb'):
with open(notebook_path, encoding="utf8") as fin:
with open(notebook_path + ".badges.md", 'w') as fout:
fout.write(nbformat.read(fin, nbformat.NO_CONVERT).cells[0].source)
EOF
PDOC_ALLOW_EXEC=1 python -We -m pdoc -o html PySDM examples/PySDM_examples -t docs/templates --math --mermaid
python -We .github/workflows/docs.py . .

- if: ${{ github.ref == 'refs/heads/main' && matrix.platform == 'ubuntu-latest' }}
uses: JamesIves/[email protected]
with:
branch: pdoc
folder: html
clean: true
clean: true
Loading