|
| 1 | +# opencode-python-docs |
| 2 | + |
| 3 | +OpenCode plugin for Python documentation lookup via DevDocs. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +Add to `~/.config/opencode/opencode.json`: |
| 8 | + |
| 9 | +```json |
| 10 | +{ "plugin": ["opencode-python-docs"] } |
| 11 | +``` |
| 12 | + |
| 13 | +## Features |
| 14 | + |
| 15 | +- **Search** Python stdlib, language reference, tutorials, and more |
| 16 | +- **Fetch** full documentation as clean Markdown |
| 17 | +- **Cache** with intelligent TTL-based garbage collection |
| 18 | +- **Multiple versions** supported: 3.14, 3.13, 3.12, 3.11, 3.10, 3.9 |
| 19 | + |
| 20 | +## Tools |
| 21 | + |
| 22 | +### `python_docs` |
| 23 | + |
| 24 | +Search Python documentation index. |
| 25 | + |
| 26 | +| Argument | Type | Description | |
| 27 | +| ---------- | ------ | ------------- | |
| 28 | +| `query` | string | Search query (e.g., 'asyncio', 'pathlib') | |
| 29 | +| `version` | string? | Python version (default: 3.14) | |
| 30 | +| `type` | string? | Filter by doc type | |
| 31 | +| `limit` | number? | Max results (default: 20) | |
| 32 | + |
| 33 | +**Example:** |
| 34 | + |
| 35 | +```text |
| 36 | +python_docs query="asyncio" version="3.12" |
| 37 | +``` |
| 38 | + |
| 39 | +### `fetch_python_doc` |
| 40 | + |
| 41 | +Fetch full documentation as Markdown. |
| 42 | + |
| 43 | +| Argument | Type | Description | |
| 44 | +| ---------- | ------ | ------------- | |
| 45 | +| `path` | string | Doc path from search results | |
| 46 | +| `version` | string? | Python version (default: 3.14) | |
| 47 | +| `anchor` | string? | Jump to specific section by anchor ID | |
| 48 | +| `offset` | number? | Character offset for pagination (default: 0) | |
| 49 | +| `limit` | number? | Max characters to return (default: 12000) | |
| 50 | + |
| 51 | +**Example:** |
| 52 | + |
| 53 | +```text |
| 54 | +fetch_python_doc path="library/asyncio" |
| 55 | +``` |
| 56 | + |
| 57 | +**Pagination example:** |
| 58 | + |
| 59 | +```text |
| 60 | +# First chunk |
| 61 | +fetch_python_doc path="library/asyncio" offset=0 limit=5000 |
| 62 | +
|
| 63 | +# Continue reading |
| 64 | +fetch_python_doc path="library/asyncio" offset=5000 limit=5000 |
| 65 | +``` |
| 66 | + |
| 67 | +## Caching |
| 68 | + |
| 69 | +- **Index cache**: 24 hours TTL |
| 70 | +- **Doc cache**: 7 days TTL |
| 71 | +- **Location**: `~/.cache/opencode/python-docs/` |
| 72 | +- **Garbage collection**: Runs on startup and server reconnect |
| 73 | + |
| 74 | +## Development |
| 75 | + |
| 76 | +```bash |
| 77 | +git clone https://github.com/yriveiro/opencode-python-docs |
| 78 | +cd opencode-python-docs |
| 79 | +bun install |
| 80 | +bun run build |
| 81 | +``` |
| 82 | + |
| 83 | +### Scripts |
| 84 | + |
| 85 | +| Command | Description | |
| 86 | +| --------- | ------------- | |
| 87 | +| `bun run build` | Build the plugin | |
| 88 | +| `bun run typecheck` | Run TypeScript type checking | |
| 89 | +| `bun run test` | Run tests | |
| 90 | +| `bun run format` | Format code with Biome | |
| 91 | +| `bun run lint` | Run Biome linter | |
| 92 | +| `bun run check` | Run all checks (lint + format) | |
| 93 | + |
| 94 | +## License |
| 95 | + |
| 96 | +MIT |
0 commit comments