Skip to content

Commit eb975b4

Browse files
authored
docs: update the contributing guide and agent rules (#1208)
Small cleanup of `CONTRIBUTING.md` and `.rules.md`: - Reword the YAML rule: leave values unquoted unless quotes are needed, then use double quotes. Crawlee and the SDK get the same rule. - Move the `from __future__ import annotations` bullet from "Comments and docstrings" to "Readability" and mention the `__init__.py` exception. - Under "Generated models", ask to point out a regeneration that adds a `pattern`, length limit, `maxItems` or `const` to a request model, since the client then rejects that input before sending the request. - Rename "Additional context" in `.rules.md` to "Related repositories" and name the repositories `review-references.yaml` covers. - State the full requirement for running the docs locally (Node.js 22.12 or newer and pnpm), and unwrap the two hard-wrapped paragraphs in "Linting the docs and website". *✍️ Drafted by Claude Code*
1 parent 557d562 commit eb975b4

2 files changed

Lines changed: 8 additions & 12 deletions

File tree

‎.rules.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ The OpenAPI spec can lag behind the API and omit fields, and a live response onl
4343
- A single resource's fields are in `PUBLISHED_*_FIELDS` in `src/packages/<area>-server/src/<resource>/<resource>.server.ts`.
4444
- A list endpoint has its own, usually smaller, `API_PUBLISHED_*_LIST_FIELDS` in `src/api/src/routes/<resource>/<resource>_list.ts`, and often builds each item inline. Don't assume a list item has the same fields as the single resource.
4545

46-
### Additional context
46+
### Related repositories
4747

48-
The code in this repository is based on and integrated with code from other repositories. The most important references are defined in [review references](./.github/review-references.yaml)
48+
[`.github/review-references.yaml`](.github/review-references.yaml) lists the related repositories (`apify-core`, `apify-client-js`, `apify-sdk-python`) and what to check in each when a change touches shared behavior.

‎CONTRIBUTING.md‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ We use [ruff](https://docs.astral.sh/ruff/) for linting and formatting, [ty](htt
3939

4040
### Readability
4141

42+
- Every module in `src/`, `tests/`, and `scripts/` except `__init__.py` has `from __future__ import annotations` as its first import.
4243
- Prefer a few simple statements over one dense line. Give intermediate values a name instead of nesting calls, comprehensions, and unpacking into a single long expression.
4344
- When replacing a call with an equivalent one, change only the call and keep the surrounding statements as they were.
4445

4546
### Comments and docstrings
4647

47-
- Every module starts with `from __future__ import annotations`.
4848
- Comments and docstrings describe what the code does now. The bug a change fixed, what a PR changed, and contrasts with removed behavior (`instead of ...`, `no longer ...`) belong in the commit message.
4949
- Don't explain language features in comments. A comment earns its place with a domain reason, an invariant the types can't express, or a non-obvious consequence for callers.
5050
- Use single backticks for code references, never RST-style double backticks.
@@ -64,14 +64,15 @@ We use [ruff](https://docs.astral.sh/ruff/) for linting and formatting, [ty](htt
6464

6565
### YAML
6666

67-
Use double quotes for quoted YAML values (`retries: "3"`). Keep single quotes when the value itself contains double quotes, and for string literals inside GitHub Actions expressions (`${{ ... }}`, `if:` conditions), where double quotes are invalid.
67+
Leave YAML values unquoted unless quotes are needed: a plain value that would change type (`"3.14"`, `"true"`, `""`), start with an indicator character (`"*"`, `"@apify/*"`), contain a colon followed by a space or a `#` preceded by one (`"a: b"`, `"a #b"`), or need an escape sequence (`"\n"`). Use double quotes then. Keep single quotes when the value itself contains double quotes, and for string literals inside GitHub Actions expressions (`${{ ... }}`, `if:` conditions), where double quotes are invalid.
6868

6969
## Generated models
7070

7171
`src/apify_client/_models.py`, `_typeddicts.py`, and `_literals.py` are generated from the Apify OpenAPI specification by [datamodel-code-generator](https://github.com/koxudaxi/datamodel-code-generator) and post-processed by `scripts/postprocess_generated_models.py`. Never edit them by hand; make lasting fixes in the post-processing script. The generator is configured under `[tool.datamodel-codegen]` in `pyproject.toml`, with field aliases in `datamodel_codegen_aliases.json`.
7272

7373
- `uv run poe generate-models` regenerates them from the published specification. `scripts/openapi_spec.py` describes how the specification version is recorded. Don't commit a regeneration that only moves that version.
7474
- `uv run poe generate-models-from-file <path>` generates them from a local specification, for trying out unpublished changes. Don't commit the result.
75+
- A regeneration that adds a `pattern`, a length or item-count limit (`minLength`/`maxLength`, `minItems`/`maxItems`), a numeric bound (`minimum`/`maximum`), or a `const` to a model makes the client raise a `ValidationError` on data that violates it: on request input before the request is sent, and on an API response while parsing it. Point it out in the PR, since the API may accept input or return data the client now rejects.
7576
- The nightly `Regenerate models` workflow opens a `chore:` PR when the models change. If the diff is user-facing, retitle it to `fix:` or `feat:` so it lands in the changelog and triggers a release.
7677

7778
## Documentation
@@ -91,28 +92,23 @@ A user-facing feature ships with its documentation in the same PR: a page in `do
9192

9293
Code examples in `docs/` come in `_sync.py` / `_async.py` pairs and have their own lint settings in `docs/pyproject.toml`. Never edit `website/versioned_docs/`: those snapshots are produced by the release automation and frozen against the code that shipped. Fix `docs/`, and the next release snapshot carries the change.
9394

94-
To run the documentation locally (requires Node.js):
95+
To run the documentation locally (requires Node.js 22.12 or newer and pnpm):
9596

9697
```sh
9798
uv run poe run-docs
9899
```
99100

100101
### Linting the docs and website
101102

102-
Markdown content (this guide, `README.md`, and the `docs/` folder) is checked with
103-
[markdownlint](https://github.com/DavidAnson/markdownlint). The Docusaurus website code is linted
104-
with [oxlint](https://oxc.rs/) in type-aware mode (types come from `website/tsconfig.json`) and
105-
formatted with [oxfmt](https://oxc.rs/). All of them run in CI.
106-
To run them locally (requires Node.js 22.12 or newer and pnpm), from the `website/` directory:
103+
Markdown content (this guide, `README.md`, and the `docs/` folder) is checked with [markdownlint](https://github.com/DavidAnson/markdownlint). The Docusaurus website code is linted with [oxlint](https://oxc.rs/) in type-aware mode (types come from `website/tsconfig.json`) and formatted with [oxfmt](https://oxc.rs/). All of them run in CI. To run them locally (requires Node.js 22.12 or newer and pnpm), from the `website/` directory:
107104

108105
```sh
109106
pnpm lint # lint Markdown and website code
110107
pnpm lint:fix # auto-fix both
111108
pnpm format # format the website code
112109
```
113110

114-
Doc images are committed as optimized `.webp`. To convert a new image, run
115-
`pnpm opt:images <path-to-image>` from the `website/` directory.
111+
Doc images are committed as optimized `.webp`. To convert a new image, run `pnpm opt:images <path-to-image>` from the `website/` directory.
116112

117113
## Commits
118114

0 commit comments

Comments
 (0)