Skip to content

Commit 8e778e7

Browse files
committed
Add workflow for pdoc API documentation
1 parent 14160b1 commit 8e778e7

File tree

8 files changed

+69
-10
lines changed

8 files changed

+69
-10
lines changed

.github/workflows/docs.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: website
2+
3+
# build the documentation whenever there are new commits on main
4+
on:
5+
push:
6+
branches:
7+
- main
8+
# Alternative: only build for tags.
9+
# tags:
10+
# - '*'
11+
12+
# security: restrict permissions for CI jobs.
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
# Build the documentation and upload the static HTML files as an artifact.
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v5
22+
with:
23+
persist-credentials: false
24+
- uses: actions/setup-python@v6
25+
with:
26+
python-version: '3.13'
27+
28+
# ADJUST THIS: install all dependencies (including pdoc)
29+
- run: pip install -e .
30+
- run: pip install pdoc
31+
# ADJUST THIS: build your documentation into docs/.
32+
# We use a custom build script for pdoc itself, ideally you just run `pdoc -o docs/ ...` here.
33+
- run: pdoc -o ./docs -d google ./jmu_pytest_utils
34+
35+
- uses: actions/upload-pages-artifact@v4
36+
with:
37+
path: docs/
38+
39+
# Deploy the artifact to GitHub pages.
40+
# This is a separate job so that only actions/deploy-pages has the necessary permissions.
41+
deploy:
42+
needs: build
43+
runs-on: ubuntu-latest
44+
permissions:
45+
pages: write
46+
id-token: write
47+
environment:
48+
name: github-pages
49+
url: ${{ steps.deployment.outputs.page_url }}
50+
steps:
51+
- id: deployment
52+
uses: actions/deploy-pages@v4

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- run postsetup.sh at the end of setup.sh (#11)
1414
- optional test file argument for builder.py (#12)
1515
- type hints for all API functions (#13)
16+
- API documentation website built with pdoc
1617

1718
### Changed
1819

jmu_pytest_utils/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"""A pytest plugin for building and running Gradescope autograders.
2+
3+
Source: https://github.com/JMU-CS/jmu_pytest_utils/
4+
"""

jmu_pytest_utils/audit.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""Static analysis of student code.
22
3-
https://docs.python.org/3/library/ast.html#node-classes
4-
https://saligrama.io/blog/gradescope-autograder-security/
3+
References:
4+
- https://docs.python.org/3/library/ast.html#node-classes
5+
- https://saligrama.io/blog/gradescope-autograder-security/
56
"""
67

78
import ast

jmu_pytest_utils/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ class redirect_stdin:
155155
def __init__(self, user_input: str) -> None:
156156
self._old_input = None
157157
self._old_stdin = None
158-
self.user_input = user_input
158+
self._user_input = user_input
159159

160160
def __enter__(self):
161161
self._old_input = builtins.input
162162
self._old_stdin = sys.stdin
163163
builtins.input = _input
164-
sys.stdin = io.StringIO(self.user_input)
164+
sys.stdin = io.StringIO(self._user_input)
165165

166166
def __exit__(self, exc_type, exc_val, exc_tb):
167167
builtins.input = self._old_input

jmu_pytest_utils/decorators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def required() -> Callable[[F], F]:
1212
If a required test fails, the remaining tests are hidden.
1313
1414
Returns:
15-
The original function with attribute set.
15+
The original function with required attribute set.
1616
"""
1717
def wrapper(f: F) -> F:
1818
f.required = True
@@ -27,7 +27,7 @@ def weight(value: int) -> Callable[[F], F]:
2727
value: The number of points the test is worth.
2828
2929
Returns:
30-
The original function with attribute set.
30+
The original function with weight attribute set.
3131
"""
3232
def wrapper(f: F) -> F:
3333
f.weight = value

jmu_pytest_utils/meta.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def get_username(default: str = "username") -> str:
1212
default: Value to return if metadata not found.
1313
1414
Returns:
15-
The student's email address up to the @ symbol.
15+
The student's email address before the @ symbol.
1616
"""
1717
try:
1818
with open("/autograder/submission_metadata.json") as file:
@@ -66,7 +66,7 @@ def submission_closed() -> bool:
6666
"""Check if the current time is outside the user's submission window.
6767
6868
Returns:
69-
The opposite of submission_open() with default arguments.
69+
The opposite of `submission_open()` with default arguments.
7070
"""
7171
return not submission_open()
7272

jmu_pytest_utils/plugin.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""Generate the final results.json file for Gradescope.
22
3-
https://docs.pytest.org/en/stable/reference/reference.html
4-
https://gradescope-autograders.readthedocs.io/en/latest/specs/
3+
References:
4+
- https://docs.pytest.org/en/stable/reference/reference.html
5+
- https://gradescope-autograders.readthedocs.io/en/latest/specs/
56
"""
67

78
import json

0 commit comments

Comments
 (0)