Skip to content

Commit 7475d46

Browse files
committed
feat: readthedocs documentation
1 parent 64086aa commit 7475d46

25 files changed

+3115
-5
lines changed

.github/workflows/dependabot.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Dependabot configuration file
2+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
3+
4+
version: 2
5+
updates:
6+
# Enable version updates for Python
7+
- package-ecosystem: "pip"
8+
# Look for requirements files in the root directory
9+
directory: "/"
10+
# Check for updates once a week (Monday)
11+
schedule:
12+
interval: "weekly"
13+
day: "monday"
14+
# Group dependencies to consolidate PRs
15+
groups:
16+
dev-dependencies:
17+
patterns:
18+
- "black"
19+
- "isort"
20+
- "ruff"
21+
- "mypy"
22+
- "pytest*"
23+
- "bandit"
24+
- "pre-commit"
25+
production-dependencies:
26+
patterns:
27+
- "*"
28+
exclude-patterns:
29+
- "black"
30+
- "isort"
31+
- "ruff"
32+
- "mypy"
33+
- "pytest*"
34+
- "bandit"
35+
- "pre-commit"
36+
# Maximum number of open PRs
37+
open-pull-requests-limit: 10
38+
# Prefix PR titles
39+
commit-message:
40+
prefix: "deps"
41+
include: "scope"
42+
# Add labels to PRs
43+
labels:
44+
- "dependencies"
45+
- "automerge"
46+
# Allow automatic merging
47+
reviewers:
48+
- "DiogoRibeiro7"
49+
assignees:
50+
- "DiogoRibeiro7"
51+
52+
# Enable version updates for GitHub Actions
53+
- package-ecosystem: "github-actions"
54+
directory: "/"
55+
schedule:
56+
interval: "weekly"
57+
day: "monday"
58+
open-pull-requests-limit: 10
59+
commit-message:
60+
prefix: "ci"
61+
include: "scope"
62+
labels:
63+
- "dependencies"
64+
- "github_actions"
65+
- "automerge"
66+
reviewers:
67+
- "DiogoRibeiro7"
68+
assignees:
69+
- "DiogoRibeiro7"
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Docstring Coverage
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
docstring-coverage:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.12"
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
26+
- name: Check docstring coverage
27+
run: |
28+
python scripts/check_docstring_coverage.py --min-coverage 80
29+
30+
- name: Generate docstring coverage badge
31+
run: |
32+
python -c "
33+
import re
34+
import subprocess
35+
import json
36+
37+
# Run the docstring coverage script and capture output
38+
result = subprocess.run(
39+
['python', 'scripts/check_docstring_coverage.py', '--dir', 'src'],
40+
capture_output=True,
41+
text=True
42+
)
43+
44+
# Extract the overall coverage percentage
45+
match = re.search(r'Overall docstring coverage: (\d+\.\d+)%', result.stdout)
46+
if match:
47+
coverage = float(match.group(1))
48+
49+
# Determine badge color
50+
color = 'red'
51+
if coverage >= 90:
52+
color = 'brightgreen'
53+
elif coverage >= 80:
54+
color = 'green'
55+
elif coverage >= 70:
56+
color = 'yellowgreen'
57+
elif coverage >= 60:
58+
color = 'yellow'
59+
elif coverage >= 50:
60+
color = 'orange'
61+
62+
# Create badge URL
63+
badge_url = f'https://img.shields.io/badge/docstring%20coverage-{coverage:.1f}%25-{color}'
64+
65+
# Update README.md
66+
with open('README.md', 'r') as f:
67+
readme = f.read()
68+
69+
# Look for existing docstring coverage badge
70+
docstring_badge_pattern = r'!\[Docstring Coverage\]\(https://img\.shields\.io/badge/docstring%20coverage-[\d\.]+%25-[a-z]+\)'
71+
if re.search(docstring_badge_pattern, readme):
72+
# Replace existing badge
73+
readme = re.sub(docstring_badge_pattern, f'![Docstring Coverage]({badge_url})', readme)
74+
else:
75+
# Look for badge section to add to
76+
badge_section = re.search(r'(!\[[^\]]+\]\([^\)]+\)[ \t]*)+', readme)
77+
if badge_section:
78+
# Add to existing badges
79+
end_pos = badge_section.end()
80+
readme = readme[:end_pos] + f' ![Docstring Coverage]({badge_url})' + readme[end_pos:]
81+
else:
82+
# Add after first line
83+
first_line_end = readme.find('\\n')
84+
if first_line_end != -1:
85+
readme = readme[:first_line_end+1] + f'\\n![Docstring Coverage]({badge_url})\\n' + readme[first_line_end+1:]
86+
else:
87+
readme = readme + f'\\n\\n![Docstring Coverage]({badge_url})\\n'
88+
89+
with open('README.md', 'w') as f:
90+
f.write(readme)
91+
92+
print(f'Updated README.md with docstring coverage badge: {coverage:.1f}%')
93+
else:
94+
print('Could not extract docstring coverage percentage')
95+
"
96+
97+
- name: Commit updated README with docstring coverage badge
98+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
99+
run: |
100+
git config user.name "github-actions[bot]"
101+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
102+
git add README.md
103+
git diff --quiet && git diff --staged --quiet || (
104+
git commit -m "docs: update docstring coverage badge [skip ci]"
105+
git push
106+
)
107+
108+
permissions:
109+
contents: write

.readthedocs.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# .readthedocs.yaml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Set the OS, Python version and other tools
9+
build:
10+
os: ubuntu-22.04
11+
tools:
12+
python: "3.12"
13+
jobs:
14+
post_create_environment:
15+
# Install poetry
16+
- pip install poetry
17+
# Tell poetry to not use a virtual environment
18+
- poetry config virtualenvs.create false
19+
post_install:
20+
# Install dependencies with poetry
21+
- poetry install --with docs
22+
23+
# Build documentation in the docs/ directory with Sphinx
24+
sphinx:
25+
configuration: docs/conf.py
26+
27+
# Optionally build your docs in additional formats such as PDF
28+
formats:
29+
- pdf
30+
- epub
31+
32+
# Optionally declare the Python requirements required to build your docs
33+
python:
34+
install:
35+
- method: pip
36+
path: .
37+
extra_requirements:
38+
- docs

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
77
## [Unreleased]
88

99
### Added
10+
1011
- Enhanced development tooling with Black, isort, Bandit, and pre-commit hooks
1112
- Added tox.ini for multi-environment testing
1213
- Added .editorconfig for consistent coding style
@@ -17,27 +18,32 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1718
- Improved GitHub issue and PR templates
1819

1920
### Changed
21+
2022
- Updated Makefile with additional commands for development tasks
2123
- Enhanced pyproject.toml with more comprehensive configurations
2224
- Improved code quality settings with stricter linting rules
2325

2426
### Fixed
27+
2528
- Fixed GitHub Actions permissions for the code coverage workflow
2629

2730
## [0.1.1] - 2025-08-14
2831

2932
### Added
33+
3034
- Initial package structure
3135
- Basic hello function
3236
- Testing setup with pytest
3337
- Automated dependency management scripts
3438

3539
### Changed
40+
3641
- Updated pyproject.toml to use modern Poetry configuration
3742

3843
## [0.1.0] - 2025-08-01
3944

4045
### Added
46+
4147
- Initial release
4248
- Basic project structure
4349
- MIT License

Makefile

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help install format lint type-check test test-cov clean build publish-test publish setup dev-install security docs tox
1+
.PHONY: help install format lint type-check test test-cov clean build publish-test publish setup dev-install security docs tox docs-api docs-build docs-live
22

33
help:
44
@echo "Available commands:"
@@ -12,20 +12,23 @@ help:
1212
@echo " make test-cov Run tests with coverage"
1313
@echo " make tox Run tests in multiple Python environments"
1414
@echo " make security Run security checks with bandit"
15-
@echo " make docs Generate documentation"
15+
@echo " make docs Generate documentation with pdoc"
16+
@echo " make docs-api Generate Sphinx API documentation"
17+
@echo " make docs-build Build Sphinx documentation"
18+
@echo " make docs-live Run a live server for Sphinx documentation"
1619
@echo " make clean Remove build artifacts"
1720
@echo " make build Build package"
1821
@echo " make publish-test Publish to TestPyPI"
1922
@echo " make publish Publish to PyPI"
2023

2124
install:
22-
poetry install --no-dev
25+
poetry install --without dev,docs
2326

2427
dev-install:
25-
poetry install
28+
poetry install --with dev
2629

2730
setup:
28-
poetry install
31+
poetry install --with dev
2932
pre-commit install
3033

3134
format:
@@ -54,10 +57,23 @@ security:
5457
docs:
5558
poetry run python scripts/generate_docs.py
5659

60+
docs-api:
61+
cd docs && python make_api_docs.py
62+
63+
docs-build:
64+
poetry install --with docs
65+
cd docs && $(MAKE) html
66+
67+
docs-live:
68+
poetry install --with docs
69+
cd docs && $(MAKE) livehtml
70+
5771
clean:
5872
rm -rf build/
5973
rm -rf dist/
6074
rm -rf *.egg-info
75+
rm -rf docs/_build/
76+
rm -rf docs/api/
6177
find . -type d -name __pycache__ -exec rm -rf {} +
6278
find . -type f -name "*.pyc" -delete
6379

docs/Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile clean livehtml apidoc
16+
17+
# Clean build files
18+
clean:
19+
rm -rf $(BUILDDIR)/*
20+
rm -rf api/*
21+
22+
# Generate API documentation
23+
apidoc:
24+
python make_api_docs.py
25+
26+
# Build documentation with live reload
27+
livehtml:
28+
sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)/html" $(SPHINXOPTS) $(O) --open-browser
29+
30+
# Catch-all target: route all unknown targets to Sphinx using the new
31+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
32+
%: Makefile
33+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

0 commit comments

Comments
 (0)