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
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pytest==8.4.1
pytest-cov==6.2.1
pdoc==15.0.4
flake8==7.3.0
flake8==7.3.0
pdoc==15.0.4
3 changes: 2 additions & 1 deletion stat_log_db/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ dependencies = [
dev = [
"pytest==8.4.1",
"pytest-cov==6.2.1",
"flake8==7.3.0"
"flake8==7.3.0",
"pdoc==15.0.4"
]

[project.scripts]
Expand Down
13 changes: 13 additions & 0 deletions tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,19 @@ def test_test_style():
assert "Running style tests" in out
assert "flake8" in out

# def test_doc_generate_html():
# """Test -d h (generate HTML documentation)."""
# code, out = run_tools(['-d', 'h'])
# assert code == 0
# assert 'Generating HTML documentation' in out


def test_doc_invalid_arg():
"""Test -d with invalid argument."""
code, out = run_tools(['-d', 'x'])
assert code == 1
assert ("Unsupported argument" in out) or ("Invalid doc mode" in out)


@pytest.mark.skipif(GITHUB_ACTIONS, reason="Skipping test on GitHub Actions")
def test_clean():
Expand Down
31 changes: 30 additions & 1 deletion tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ supported_installation_opts="d n"
install=""
uninstall=0
clean=0
supported_doc_opts="h s"
doc=""
supported_test_opts="p t a d s"
test=""

while getopts ":i:t:chu" flag; do
while getopts ":i:t:d:chu" flag; do
case "${flag}" in
i) if [[ " $supported_installation_opts " =~ " $OPTARG " ]]; then
install="$OPTARG"
Expand All @@ -24,6 +26,12 @@ while getopts ":i:t:chu" flag; do
echo "Unsupported argument '$OPTARG' for '-$flag'. Please specify one of: $supported_test_opts" >&2 && exit 1;
fi
;;
d) if [[ " $supported_doc_opts " =~ " $OPTARG " ]]; then
doc="$OPTARG"
else
echo "Unsupported argument '$OPTARG' for '-$flag'. Please specify one of: $supported_doc_opts" >&2 && exit 1;
fi
;;
h) cat README.md && exit 0;;
:)
echo "Option -$OPTARG requires an argument" >&2; exit 1;;
Expand Down Expand Up @@ -80,6 +88,27 @@ if [ -n "$test" ]; then
esac
fi

# Documentation [-d]
if [ -n "$doc" ]; then
case "$doc" in
h)
echo "Generating HTML documentation..."
if [ ! -d "stat_log_db/docs" ]; then
mkdir -p stat_log_db/docs
fi
pdoc --output-dir stat_log_db/docs stat_log_db
;;
s)
echo "Hosting documentation..."
pdoc stat_log_db --host localhost
;;
*)
echo "Invalid doc mode '$doc'. Use one of: $supported_doc_opts" >&2
exit 1
;;
esac
fi

# Clean artifacts [-c]
if [ $clean -eq 1 ]; then
echo "Cleaning up workspace..."
Expand Down