Skip to content

Commit 69c2d58

Browse files
authored
Merge pull request #4 from SyntaxAerror/pdoc
Add documentations with pdoc
2 parents 73cb2eb + 439af67 commit 69c2d58

File tree

4 files changed

+47
-3
lines changed

4 files changed

+47
-3
lines changed

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pytest==8.4.1
22
pytest-cov==6.2.1
33
pdoc==15.0.4
4-
flake8==7.3.0
4+
flake8==7.3.0
5+
pdoc==15.0.4

stat_log_db/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ dependencies = [
1515
dev = [
1616
"pytest==8.4.1",
1717
"pytest-cov==6.2.1",
18-
"flake8==7.3.0"
18+
"flake8==7.3.0",
19+
"pdoc==15.0.4"
1920
]
2021

2122
[project.scripts]

tests/test_tools.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,19 @@ def test_test_style():
193193
assert "Running style tests" in out
194194
assert "flake8" in out
195195

196+
# def test_doc_generate_html():
197+
# """Test -d h (generate HTML documentation)."""
198+
# code, out = run_tools(['-d', 'h'])
199+
# assert code == 0
200+
# assert 'Generating HTML documentation' in out
201+
202+
203+
def test_doc_invalid_arg():
204+
"""Test -d with invalid argument."""
205+
code, out = run_tools(['-d', 'x'])
206+
assert code == 1
207+
assert ("Unsupported argument" in out) or ("Invalid doc mode" in out)
208+
196209

197210
@pytest.mark.skipif(GITHUB_ACTIONS, reason="Skipping test on GitHub Actions")
198211
def test_clean():

tools.sh

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ supported_installation_opts="d n"
55
install=""
66
uninstall=0
77
clean=0
8+
supported_doc_opts="h s"
9+
doc=""
810
supported_test_opts="p t a d s"
911
test=""
1012

11-
while getopts ":i:t:chu" flag; do
13+
while getopts ":i:t:d:chu" flag; do
1214
case "${flag}" in
1315
i) if [[ " $supported_installation_opts " =~ " $OPTARG " ]]; then
1416
install="$OPTARG"
@@ -24,6 +26,12 @@ while getopts ":i:t:chu" flag; do
2426
echo "Unsupported argument '$OPTARG' for '-$flag'. Please specify one of: $supported_test_opts" >&2 && exit 1;
2527
fi
2628
;;
29+
d) if [[ " $supported_doc_opts " =~ " $OPTARG " ]]; then
30+
doc="$OPTARG"
31+
else
32+
echo "Unsupported argument '$OPTARG' for '-$flag'. Please specify one of: $supported_doc_opts" >&2 && exit 1;
33+
fi
34+
;;
2735
h) cat README.md && exit 0;;
2836
:)
2937
echo "Option -$OPTARG requires an argument" >&2; exit 1;;
@@ -80,6 +88,27 @@ if [ -n "$test" ]; then
8088
esac
8189
fi
8290

91+
# Documentation [-d]
92+
if [ -n "$doc" ]; then
93+
case "$doc" in
94+
h)
95+
echo "Generating HTML documentation..."
96+
if [ ! -d "stat_log_db/docs" ]; then
97+
mkdir -p stat_log_db/docs
98+
fi
99+
pdoc --output-dir stat_log_db/docs stat_log_db
100+
;;
101+
s)
102+
echo "Hosting documentation..."
103+
pdoc stat_log_db --host localhost
104+
;;
105+
*)
106+
echo "Invalid doc mode '$doc'. Use one of: $supported_doc_opts" >&2
107+
exit 1
108+
;;
109+
esac
110+
fi
111+
83112
# Clean artifacts [-c]
84113
if [ $clean -eq 1 ]; then
85114
echo "Cleaning up workspace..."

0 commit comments

Comments
 (0)