|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +Guide for AI agents (and developers) on how to install, build, and test the Wikipedia-API project. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- **Python 3.10+** (supported: 3.10, 3.11, 3.12, 3.13, 3.14) |
| 8 | +- **Virtual environment** already set up in `.venv/` |
| 9 | + |
| 10 | +## Virtual Environment |
| 11 | + |
| 12 | +**Always activate the virtual environment before running any command:** |
| 13 | + |
| 14 | +```bash |
| 15 | +source .venv/bin/activate |
| 16 | +``` |
| 17 | + |
| 18 | +## Install |
| 19 | + |
| 20 | +Install all dependencies (runtime, dev, docs, build): |
| 21 | + |
| 22 | +```bash |
| 23 | +make requirements-all |
| 24 | +``` |
| 25 | + |
| 26 | +Or install individual dependency groups: |
| 27 | + |
| 28 | +- **Runtime dependencies:** `make requirements` (installs `requirements.txt` — `requests`) |
| 29 | +- **Dev dependencies:** `make requirements-dev` (installs `requirements-dev.txt` — black, coverage, flake8, isort, mypy, pre-commit, tox, etc.) |
| 30 | +- **Doc dependencies:** `make requirements-doc` (installs `requirements-doc.txt` — sphinx) |
| 31 | +- **Build dependencies:** `make requirements-build` (installs `requirements-build.txt` — rst2html, setuptools, wheel) |
| 32 | + |
| 33 | +## Build |
| 34 | + |
| 35 | +Build the source distribution package: |
| 36 | + |
| 37 | +```bash |
| 38 | +make build-package |
| 39 | +``` |
| 40 | + |
| 41 | +Generate PyPI HTML documentation preview: |
| 42 | + |
| 43 | +```bash |
| 44 | +make pypi-html |
| 45 | +``` |
| 46 | + |
| 47 | +Generate Sphinx HTML documentation: |
| 48 | + |
| 49 | +```bash |
| 50 | +make html |
| 51 | +``` |
| 52 | + |
| 53 | +## Test |
| 54 | + |
| 55 | +### Run Unit Tests |
| 56 | + |
| 57 | +```bash |
| 58 | +make run-tests |
| 59 | +``` |
| 60 | + |
| 61 | +This runs `python3 -m unittest discover tests/ '*test.py'`. All test files are in the `tests/` directory and follow the `*test.py` naming pattern. |
| 62 | + |
| 63 | +### Run Tests with Coverage |
| 64 | + |
| 65 | +```bash |
| 66 | +make run-coverage |
| 67 | +``` |
| 68 | + |
| 69 | +Produces a coverage report and `coverage.xml` for the `wikipediaapi` package. |
| 70 | + |
| 71 | +### Run Tests Across Python Versions (tox) |
| 72 | + |
| 73 | +```bash |
| 74 | +make run-tox |
| 75 | +``` |
| 76 | + |
| 77 | +Runs the test suite against Python 3.10–3.14 via tox. |
| 78 | + |
| 79 | +## Lint & Type Checking |
| 80 | + |
| 81 | +### Run All Pre-commit Hooks |
| 82 | + |
| 83 | +```bash |
| 84 | +make run-pre-commit |
| 85 | +``` |
| 86 | + |
| 87 | +This runs isort, black, flake8, mypy, pyupgrade, and other checks (trailing whitespace, YAML validation, etc.). |
| 88 | + |
| 89 | +### Run Individual Checks |
| 90 | + |
| 91 | +- **Type checking:** `make run-type-check` (runs `mypy ./wikipediaapi`) |
| 92 | +- **Linting:** `make run-flake8` (runs `flake8 --max-line-length=100 wikipediaapi tests`) |
| 93 | + |
| 94 | +## Pre-release Check |
| 95 | + |
| 96 | +Run the full validation suite (pre-commit, type check, flake8, coverage, pypi-html, tox, example): |
| 97 | + |
| 98 | +```bash |
| 99 | +make pre-release-check |
| 100 | +``` |
| 101 | + |
| 102 | +## Project Structure |
| 103 | + |
| 104 | +- `wikipediaapi/` — Main package (single `__init__.py` module) |
| 105 | +- `tests/` — Unit tests (`*test.py` files, `mock_data.py` for test fixtures) |
| 106 | +- `setup.py` — Package metadata and build configuration |
| 107 | +- `Makefile` — All build, test, and release commands |
| 108 | +- `requirements.txt` — Runtime dependencies |
| 109 | +- `requirements-dev.txt` — Development dependencies |
| 110 | +- `requirements-doc.txt` — Documentation dependencies |
| 111 | +- `requirements-build.txt` — Build/packaging dependencies |
| 112 | +- `tox.ini` — Multi-Python test configuration |
| 113 | +- `.pre-commit-config.yaml` — Pre-commit hook definitions |
0 commit comments