Skip to content

Commit 377b1ec

Browse files
committed
ai(rules[AGENTS]): Add comprehensive doctest guidelines
why: Ensure AI agents write real, executable doctests instead of using workarounds what: - Add Doctests section with critical rules - Document available doctest_namespace fixtures (inherited from libvcs) - Prohibit # doctest: +SKIP workaround - Add vcspull-specific doctest patterns for config handling
1 parent 1c00432 commit 377b1ec

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,39 @@ type
153153
"""
154154
```
155155

156+
### Doctests
157+
158+
**All functions and methods MUST have working doctests.** Doctests serve as both documentation and tests.
159+
160+
**CRITICAL RULES:**
161+
- Doctests MUST actually execute - never comment out function calls or similar
162+
- Doctests MUST NOT be converted to `.. code-block::` as a workaround (code-blocks don't run)
163+
- If you cannot create a working doctest, **STOP and ask for help**
164+
165+
**Available tools for doctests:**
166+
- `doctest_namespace` fixtures (inherited from libvcs): `tmp_path`, `create_git_remote_repo`, `create_hg_remote_repo`, `create_svn_remote_repo`
167+
- Ellipsis for variable output: `# doctest: +ELLIPSIS`
168+
- Update `conftest.py` to add new fixtures to `doctest_namespace`
169+
170+
**`# doctest: +SKIP` is NOT permitted** - it's just another workaround that doesn't test anything. If a VCS binary might not be installed, pytest already handles skipping via `skip_if_binaries_missing`. Use the fixtures properly.
171+
172+
**Using fixtures in doctests:**
173+
```python
174+
>>> from vcspull.config import extract_repos
175+
>>> config = {'~/code/': {'myrepo': 'git+https://github.com/user/repo'}}
176+
>>> repos = extract_repos(config) # doctest: +ELLIPSIS
177+
>>> len(repos)
178+
1
179+
```
180+
181+
**When output varies, use ellipsis:**
182+
```python
183+
>>> repo_dir = tmp_path / 'repo' # tmp_path from doctest_namespace
184+
>>> repo_dir.mkdir()
185+
>>> repo_dir # doctest: +ELLIPSIS
186+
PosixPath('.../repo')
187+
```
188+
156189
### Testing
157190

158191
#### Using libvcs Fixtures

0 commit comments

Comments
 (0)