|
| 1 | +# Contributing |
| 2 | + |
| 3 | +Thanks for helping improve Python By Example. |
| 4 | + |
| 5 | +## Editing examples |
| 6 | + |
| 7 | +Examples live in: |
| 8 | + |
| 9 | +```text |
| 10 | +src/example_sources/*.md |
| 11 | +``` |
| 12 | + |
| 13 | +Each example has: |
| 14 | + |
| 15 | +- TOML frontmatter with `slug`, `title`, `section`, `summary`, and `doc_path` |
| 16 | +- exactly one `:::program` block with the full editable program |
| 17 | +- one or more `:::cell` blocks with prose, Python source, and expected output |
| 18 | +- optional `:::note` blocks |
| 19 | + |
| 20 | +Use `doc_path`, not full versioned Python docs URLs. The active docs version comes from: |
| 21 | + |
| 22 | +```text |
| 23 | +src/example_sources/manifest.toml |
| 24 | +``` |
| 25 | + |
| 26 | +Do not edit generated files by hand: |
| 27 | + |
| 28 | +```text |
| 29 | +src/example_sources_data.py |
| 30 | +src/asset_manifest.py |
| 31 | +public/*.css/js fingerprinted copies |
| 32 | +``` |
| 33 | + |
| 34 | +Regenerate them with: |
| 35 | + |
| 36 | +```bash |
| 37 | +make build |
| 38 | +``` |
| 39 | + |
| 40 | +## Before opening a pull request |
| 41 | + |
| 42 | +Start the local Worker for browser-backed checks: |
| 43 | + |
| 44 | +```bash |
| 45 | +uv run --group workers pywrangler dev --port 9696 |
| 46 | +``` |
| 47 | + |
| 48 | +Then run: |
| 49 | + |
| 50 | +```bash |
| 51 | +make verify |
| 52 | +scripts/check_example_migration_parity.py |
| 53 | +scripts/format_examples.py --check |
| 54 | +make verify-python-version VERSION=3.13 |
| 55 | +git diff --check |
| 56 | +``` |
| 57 | + |
| 58 | +For example-only changes, also run: |
| 59 | + |
| 60 | +```bash |
| 61 | +make verify-examples |
| 62 | +make check-generated |
| 63 | +``` |
| 64 | + |
| 65 | +## Style expectations |
| 66 | + |
| 67 | +- Keep examples compact and language-tour focused. |
| 68 | +- Prefer practical names and output that proves the concept. |
| 69 | +- Keep source/output cells executable and deterministic. |
| 70 | +- Do not add task-cookbook examples to the language tour. |
| 71 | +- Link to official Python 3.13 documentation through `doc_path`. |
0 commit comments