File size: 13,759 Bytes
aacc0cb 69c00d1 aacc0cb 09eacb0 aacc0cb 69c00d1 09eacb0 aacc0cb 09eacb0 aacc0cb 09eacb0 aacc0cb 69c00d1 aacc0cb 69c00d1 aacc0cb 69c00d1 aacc0cb 69c00d1 aacc0cb 69c00d1 aacc0cb 69c00d1 aacc0cb 69c00d1 aacc0cb 69c00d1 aacc0cb 69c00d1 aacc0cb 69c00d1 aacc0cb 69c00d1 aacc0cb 69c00d1 aacc0cb 69c00d1 aacc0cb 69c00d1 aacc0cb 69c00d1 aacc0cb 69c00d1 aacc0cb 69c00d1 aacc0cb 69c00d1 aacc0cb 09eacb0 69c00d1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | <!-- ======================================================== -->
## Table Of Contents
<!-- ======================================================== -->
1. [Development](#1-development)
2. [Maintainer Workflow](#2-maintainer-workflow)
1. [Maintainer Loop](#maintainer-loop)
2. [Repository Routing](#repository-routing)
3. [Before Editing](#before-editing)
4. [Releases](#releases)
3. [Implementation Standards](#3-implementation-standards)
1. [Source Editing Rules](#source-editing-rules)
2. [Documentation Authoring](#documentation-authoring)
4. [Documentation Standards](#4-documentation-standards)
1. [Heading Structure](#heading-structure)
2. [Markdown Formatting Rules](#markdown-formatting-rules)
3. [GitHub Callouts](#github-callouts)
4. [Link And Backlink Rules](#link-and-backlink-rules)
5. [Static Figure Rules](#static-figure-rules)
5. [Verification And Commit](#5-verification-and-commit)
1. [Verification](#verification)
2. [Review Checklist](#review-checklist)
3. [Commit Checklist](#commit-checklist)
<br>
# 1. Development
Use this file before changing `kscrape`.
<br>
# 2. Maintainer Workflow
<!-- ======================================================== -->
## Maintainer Loop
<!-- ======================================================== -->
The maintainer loop is:
1. Read [AGENTS.md](../AGENTS.md), this file, and the relevant docs chapter.
2. Check the current worktree.
3. Locate the source owner for the behavior.
4. Edit the smallest source surface that owns the behavior.
5. Run focused verification.
6. Run broader verification when shared behavior changes.
7. Review the Git diff.
8. Commit.
> [!NOTE]
> Related links:
> - Use [How-To User Guides](How-To-User-Guides.md) for user-facing command recipes.
> - Use [References](References.md) for exact paths, commands, and public surfaces.
> - Use [Explanations](Explanations.md) for the project model behind the workflow.
<br>
<!-- ======================================================== -->
## Repository Routing
<!-- ======================================================== -->
Put changes where the repository already has an owner.
| Change Type | Owner |
|---|---|
| Runtime package behavior | [src/kscrape](../src/kscrape) |
| Release checks | [src/kscrape_dev](../src/kscrape_dev) |
| Tests | [tests](../tests) |
| Small user-facing examples | [examples](../examples) when the directory exists |
| Static assets | [assets](../assets) |
| Documentation | [docs](.) |
| Project metadata and dependency declarations | [pyproject.toml](../pyproject.toml) |
| Development recipes | [justfile](../justfile) |
| Local agent guidance | [AGENTS.md](../AGENTS.md) |
Ask before creating a new top-level directory when one of these owners is a
reasonable fit.
> [!NOTE]
> Related: use [project paths](References.md#project-paths) for source file
> owners and [package layout](Explanations.md#package-layout) for import
> boundaries.
<br>
<!-- ======================================================== -->
## Before Editing
<!-- ======================================================== -->
Run these checks before a non-trivial change:
```bash
git status --short
rg --files
```
Then read the source owner and nearby files. A CLI change usually requires
checking `src/kscrape/cli/app.py`, the wrapper in `src/kscrape/main.py`, tests,
README, and docs references.
> [!IMPORTANT]
> Do not weaken production contracts to make a test easier. Add or reuse a
> dedicated test helper when a test needs lighter setup.
<br>
<!-- ======================================================== -->
## Releases
<!-- ======================================================== -->
`CHANGELOG.md` is the source for tag notes. Before a release, move every entry
from `[Unreleased]` into a new `# [MAJOR.MINOR.PATCH] - YYYY-MM-DD` section,
add its table-of-contents link, and leave a complete empty `[Unreleased]`
section above it.
Before the first release command, create and commit the generated dependency
files:
```bash
just lock
git add uv.lock pylock.toml
git commit -m "Lock project dependencies"
```
Run the local rehearsal first:
```bash
just release-check
```
To create the checked version commit and local tag without publishing:
```bash
just release-prepare patch
```
Push it only after reviewing the result:
```bash
just release-push vMAJOR.MINOR.PATCH
```
`release-push` atomically sends `main` and the annotated tag to the configured
Hugging Face remote. It creates no GitHub Release and does not publish to PyPI.
> [!WARNING]
> `just release` creates the version commit and annotated tag, then atomically
> pushes `main` and the tag. It returns after the push without waiting for a
> hosted build.
<br>
# 3. Implementation Standards
<!-- ======================================================== -->
## Source Editing Rules
<!-- ======================================================== -->
Follow these rules for normal edits:
- Keep runtime behavior in [src/kscrape](../src/kscrape).
- Keep CLI behavior in `src/kscrape/cli/app.py`; keep `src/kscrape/main.py`
wrapper-only.
- Keep tests in [tests](../tests).
- Reuse existing helpers before adding new helpers.
- Keep `__init__.py` files limited to imports and module docstrings.
- Prefer exact domain attributes over defensive probes against strict objects.
- Document public behavior with Sphinx-style docstrings.
- Update docs when a change affects setup, usage, CLI behavior, public APIs,
environment variables, or user-visible workflows.
> [!NOTE]
> Related: use [public interfaces](References.md#public-interfaces) for the
> names that need stable documentation.
<br>
<!-- ======================================================== -->
## Documentation Authoring
<!-- ======================================================== -->
When editing docs:
1. Keep [docs/README.md](README.md) as the reading map.
2. Put procedures in [How-To User Guides](How-To-User-Guides.md).
3. Put maintainer workflow in [Development](Development.md).
4. Put exact names in [References](References.md).
5. Put system concepts in [Explanations](Explanations.md).
6. Use separator comments before major sections.
7. Add direct links to source files when a reader may need to edit them.
8. Add `[!NOTE]` related-link callouts from concept sections to task recipes.
9. Use [figure visual tokens](References.md#figure-visual-tokens) before
choosing reusable figure colors, strokes, fills, and typography.
10. Update figure assets when prose changes a diagrammed concept.
> [!NOTE]
> Related links:
> - Use [Markdown formatting rules](#markdown-formatting-rules) for docs layout.
> - Use [link and backlink rules](#link-and-backlink-rules) for related-link callouts.
> - Use [static figure rules](#static-figure-rules) for docs assets.
> - Use [figure visual tokens](References.md#figure-visual-tokens) before adding
> reusable figure colors, strokes, fills, or typography.
<br>
# 4. Documentation Standards
<!-- ======================================================== -->
## Heading Structure
<!-- ======================================================== -->
Long docs files may use multiple `#` headings. Use them for major document
parts, not only for the file title. The table of contents must mirror the real
structure so a reader can tell which sections are sequences, which sections are
tool groups, and which sections are independent references.
| Level | Use |
|---|---|
| `#` | Major document parts, for example `First-Time Setup`, `Common Workflows`, or `Failure Model`. |
| `##` | Recipes or concept chapters inside a major part. |
| `###` | Ordered substeps inside a large recipe. |
Avoid a flat file where every section is a `##` peer. A long sequence should
be one recipe with substeps, not a cluster of unrelated recipes.
<br>
<!-- ======================================================== -->
## Markdown Formatting Rules
<!-- ======================================================== -->
- Start every major docs file with a compact table of contents.
- Make the ToC match the heading hierarchy.
- Use the repository terms from [Repository Terms](README.md#repository-terms).
- Use exact technical names: source paths, environment variables, CLI commands,
config attributes, and file names.
- Avoid generic advice such as "check settings". Name the value to inspect,
such as `KSCRAPE_USER_AGENT`, `VIRTUAL_ENV`, or `src/kscrape`.
- Use separator comments before major sections:
```md
<!-- ======================================================== -->
## Section Title
<!-- ======================================================== -->
```
- Use centralized reference links near the bottom of a file when a link is
reused:
```md
<!-- --- URLs --------------------------------------------------- -->
[`uv`]: https://github.com/astral-sh/uv
```
- Use `<details>` dropdowns for long examples inside procedural docs:
````md
<details><summary> <u> <i> Longer command sequence </i> </u> </summary>
<blockquote>
```bash
just sync
just test
```
</blockquote></details>
````
<br>
<!-- ======================================================== -->
## GitHub Callouts
<!-- ======================================================== -->
Use callouts to mark the job a paragraph does. GitHub renders only the fixed
labels `TIP`, `NOTE`, `IMPORTANT`, `WARNING`, and `CAUTION`.
### Callout Syntax
````md
> [!TIP]
> Explanation text goes here.
>
> ```bash
> just sync
> ```
````
### Callout Types
> [!TIP]
> Optional advice that improves speed, clarity, or workflow.
> [!NOTE]
> Helpful context that is not required to complete the task.
> [!IMPORTANT]
> Required prerequisites, environment variables, version constraints, or
> architecture rules.
> [!WARNING]
> Risks, deprecated behavior, high-cost operations, or temporary bugs.
> [!CAUTION]
> Destructive or security-relevant actions.
<br>
<!-- ======================================================== -->
## Link And Backlink Rules
<!-- ======================================================== -->
- Prefer relative links.
- Link to exact chapters when the target section matters.
- Use `[!NOTE]` callouts for return links from concept and reference sections.
- Start one-line related-link callouts with `Related:`.
- Start multi-link related-link callouts with `Related links:`.
- Add a short purpose phrase for every related link so the reader knows why it
matters.
- Do not use standalone backlink labels in prose.
- Add return links from explanations to the relevant how-to recipes and
references.
- Add reference links from recipes when exact paths, config keys, or
environment variables matter.
- Link to source files directly when a user may need to edit them.
- After moving docs, check file links, image links, and local anchors together.
<br>
<!-- ======================================================== -->
## Static Figure Rules
<!-- ======================================================== -->
Static docs figures live in [assets](assets/). This project starts with one
small static SVG. Put repeatable figure builders with their source code and
keep only generated SVG or PNG assets here.
1. Change the figure builder for generated figures.
2. Edit a small one-off SVG directly only when no builder exists.
3. Keep the canvas transparent.
4. Keep black text on a readable surface fill so GitHub dark mode remains
legible.
5. Use neutral strokes for outlines and edges.
6. Use [figure visual tokens](References.md#figure-visual-tokens) for theme
names and values.
Embed SVG files in Markdown with a centered table:
```md
|  |
|:--:|
| **Fig. N - Figure Title:** Caption sentence. |
```
> [!NOTE]
> Related links:
> - Use [documentation authoring](#documentation-authoring) before expanding
> the docs structure or adding new figure assets.
> - Use [References: figure visual tokens](References.md#figure-visual-tokens)
> before choosing reusable visual styles.
<br>
# 5. Verification And Commit
<!-- ======================================================== -->
## Verification
<!-- ======================================================== -->
For Python changes:
```bash
ruff format .
ruff check .
pyright
python -m pytest
```
For docs-only changes:
```bash
git diff --check
rg -n "TO[D]O|FIX[M]E|content[R]eference|oai[c]ite" README.md docs
python -c "import pathlib, xml.etree.ElementTree as ET; [ET.parse(p) for p in pathlib.Path('docs/assets').glob('*.svg')]"
```
> [!NOTE]
> The exact command depends on the local environment. If a command is not
> installed, state that in the final report and verify the closest safe
> surface.
<!-- ======================================================== -->
## Review Checklist
<!-- ======================================================== -->
Before finishing, review:
- The change is in the existing owner file or directory.
- New names match existing terminology.
- Docs link to exact files and chapters.
- Tests cover the changed behavior.
- The diff has no unrelated formatting churn.
- New comments follow the local comment style.
> [!NOTE]
> Related: use [Development: before editing](#before-editing) before widening
> the scope of a change.
<!-- ======================================================== -->
## Commit Checklist
<!-- ======================================================== -->
Before committing:
1. Run focused tests for the touched area.
2. Run broader checks when shared behavior changed.
3. Review `git diff --check`.
4. Review `git status --short`.
5. Write a commit message that names the user-facing behavior.
> [!NOTE]
> Related: use [How-To User Guides: run tests](How-To-User-Guides.md#run-tests)
> for the short command recipe.
|