feat(write-readme-py): adopt Saduko-style README layout
Extends the template and skill so a generated README matches the Saduko reference: logo block in the header table, multi-extras install, local- checks subsection, and an Apache-aware License block with attribution. - readme-py.template.md: add <logo-block>, <install-block>, <local-checks-preamble>, <local-section>, <license-block> placeholders; Project layout block trimmed to match Saduko's flatter form - SKILL.md: read every project.optional-dependencies group (not just dev), detect logo asset, detect local-* recipes, branch the License block on the licence string; refuse to invent author or repo URL - saduko-license-block.md: new topic file with the parameterised Apache 2.0 rights / requirements / attribution / bibtex template, token resolution table, and a minimal NOTICE companion
This commit is contained in:
parent
c3621678de
commit
a595106cc5
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: write-readme-py
|
name: write-readme-py
|
||||||
description: Generate a README.md for a Python project scaffolded by `/build-py-project`. Reads `pyproject.toml` and `justfile` from the current directory to populate name, description, dependencies, license, and task-runner commands. Materialises a README.md and stops on `jj diff` for review before any commit. Use when the user says "write readme", "/write-readme-py", "generate readme", "document the project" inside a Python project.
|
description: Generate a README.md for a Python project scaffolded by `/build-py-project`. Reads `pyproject.toml` and `justfile` from the current directory to populate logo, extras, license, attribution, and task-runner commands in a Saduko-style two-column layout (logo + TOC header, multi-extras install, Docker/local quality checks, Apache-aware License block). Materialises a README.md and stops on `jj diff` for review before any commit. Use when the user says "write readme", "/write-readme-py", "generate readme", "document the project" inside a Python project.
|
||||||
---
|
---
|
||||||
|
|
||||||
# write-readme-py
|
# write-readme-py
|
||||||
@ -13,31 +13,58 @@ description: Generate a README.md for a Python project scaffolded by `/build-py-
|
|||||||
|
|
||||||
1. **Read sources.**
|
1. **Read sources.**
|
||||||
- `pyproject.toml` → `project.name`, `project.description`,
|
- `pyproject.toml` → `project.name`, `project.description`,
|
||||||
`project.dependencies`, `dependency-groups.dev`, `project.license`.
|
`project.dependencies`, `project.optional-dependencies` (every group,
|
||||||
|
not just `dev`), `project.license`, `project.authors[0]`,
|
||||||
|
`project.urls.Repository` (fall back to `Homepage`).
|
||||||
- `justfile` → each recipe name plus the comment line(s) above it.
|
- `justfile` → each recipe name plus the comment line(s) above it.
|
||||||
Group by section comments (lines like `# ── Docker ───`).
|
Group by section comments (lines like `# ── Docker ───`).
|
||||||
|
Detect `local-*` recipes separately for the Local subsection.
|
||||||
|
- `assets/` → first match of `<name>.png`, `<name>.svg`, `<name>.jpg`
|
||||||
|
becomes the logo. Missing is fine — skip the `<img>` tag.
|
||||||
|
|
||||||
2. **Refuse to invent.** If `project.description` is empty, ask the user
|
2. **Refuse to invent.** If `project.description` is empty, ask for one
|
||||||
for a one-line description before writing. Do not fabricate
|
line before writing. Do not fabricate dependency versions, deps not
|
||||||
dependency versions, deps not listed, or recipes not in the justfile.
|
listed, recipes not in the justfile, an author, or a repo URL.
|
||||||
|
|
||||||
3. **Materialise `README.md`** from
|
3. **Materialise `README.md`** from
|
||||||
[`readme-py.template.md`](readme-py.template.md), substituting:
|
[`readme-py.template.md`](readme-py.template.md), substituting:
|
||||||
- `<project.name>`, `<project.description>`, `<project.license.text>`
|
- `<project.name>`, `<project.description>`, `<package_name>` (the
|
||||||
- `<core-deps-csv>`, `<dev-deps-csv>`
|
`project.name` with hyphens → underscores).
|
||||||
|
- `<logo-block>` → `<img src="assets/<name>.<ext>" alt="<name> logo" width="200"/>`
|
||||||
|
if the asset exists; empty string otherwise.
|
||||||
|
- `<install-block>` → one `uv pip install -e ".[<group>]"` line per
|
||||||
|
optional-dependencies group, each annotated with the group's deps in
|
||||||
|
a trailing comment. Lead with `uv pip install -e "."` for the core.
|
||||||
- `<docker-section>`, `<lint-fmt-section>`, `<typecheck-section>`,
|
- `<docker-section>`, `<lint-fmt-section>`, `<typecheck-section>`,
|
||||||
`<test-section>`, `<combined-section>` — built from the justfile.
|
`<test-section>`, `<combined-section>` — built from the justfile.
|
||||||
Omit any section whose recipes are absent.
|
Omit any section whose recipes are absent.
|
||||||
|
- `<local-checks-preamble>` → ` Use \`local-*\` variants if you have
|
||||||
|
\`uv\` installed locally.` when any `local-*` recipes exist; empty
|
||||||
|
otherwise.
|
||||||
|
- `<local-section>` → a `# Local (requires uv)` block listing each
|
||||||
|
`local-*` recipe; empty if none.
|
||||||
|
- `<license-block>` →
|
||||||
|
- **Apache 2.0**: full rights / requirements / attribution / bibtex
|
||||||
|
block (see [`saduko-license-block.md`](saduko-license-block.md)),
|
||||||
|
substituting `<project.name>`, `<author>`, `<author-surname>`,
|
||||||
|
`<author-given>`, `<year>`, `<repo-url>`.
|
||||||
|
- **Anything else**: one line — `<project.name> is licensed under
|
||||||
|
<project.license.text>.`
|
||||||
|
|
||||||
4. **Stop.** Tell the user:
|
4. **Stop.** Tell the user:
|
||||||
> "Review the Installation section — the `[dev]` extras may need
|
> "Review the Installation extras and the License block — extras must
|
||||||
> adjustment if you've added optional dependency groups beyond `dev`.
|
> match `project.optional-dependencies`; the License block defaults to
|
||||||
> When satisfied, describe with [`/jj-atomic`](../../productivity/jj-atomic/SKILL.md)."
|
> Apache 2.0 wording only when `project.license` says so. Drop a
|
||||||
|
> `assets/<name>.png` if you want the logo to render. When satisfied,
|
||||||
|
> describe with [`/jj-atomic`](../../productivity/jj-atomic/SKILL.md)."
|
||||||
|
|
||||||
## Guardrails
|
## Guardrails
|
||||||
- **Never** invent dependency versions or recipe descriptions.
|
- **Never** invent dependency versions, recipe descriptions, author
|
||||||
|
names, or repo URLs.
|
||||||
- **Never** commit. Stop after writing the file.
|
- **Never** commit. Stop after writing the file.
|
||||||
- **Omit sections** with no source data instead of hallucinating.
|
- **Omit sections** with no source data instead of hallucinating.
|
||||||
|
- **License wording is license-specific.** Only emit the rich Saduko
|
||||||
|
attribution block for Apache 2.0; other licenses get the one-liner.
|
||||||
|
|
||||||
## Out of scope
|
## Out of scope
|
||||||
- R projects. The R counterpart (`write-readme-r`) is not yet written.
|
- R projects. The R counterpart (`write-readme-r`) is not yet written.
|
||||||
@ -45,6 +72,9 @@ description: Generate a README.md for a Python project scaffolded by `/build-py-
|
|||||||
analyses is the planned interface.
|
analyses is the planned interface.
|
||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
- [`saduko-license-block.md`](saduko-license-block.md) — the Apache 2.0
|
||||||
|
rights / requirements / attribution / bibtex template, lifted from the
|
||||||
|
Saduko reference and parameterised.
|
||||||
- [`../../scaffold/build-py-project/SKILL.md`](../../scaffold/build-py-project/SKILL.md)
|
- [`../../scaffold/build-py-project/SKILL.md`](../../scaffold/build-py-project/SKILL.md)
|
||||||
— produces the `pyproject.toml` + `justfile` this skill reads.
|
— produces the `pyproject.toml` + `justfile` this skill reads.
|
||||||
- [`../dev-python/SKILL.md`](../dev-python/SKILL.md) — the workflow
|
- [`../dev-python/SKILL.md`](../dev-python/SKILL.md) — the workflow
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="40%" align="center">
|
<td width="40%" align="center">
|
||||||
|
<logo-block>
|
||||||
<h3><project.name></h3>
|
<h3><project.name></h3>
|
||||||
<p><project.description></p>
|
<p><project.description></p>
|
||||||
</td>
|
</td>
|
||||||
@ -10,7 +11,7 @@
|
|||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
- [Installation](#installation)
|
- [Installation](#installation)
|
||||||
- [Docker](#docker)
|
- [Docker (dev)](#docker-dev)
|
||||||
- [Quality checks](#quality-checks)
|
- [Quality checks](#quality-checks)
|
||||||
- [Project layout](#project-layout)
|
- [Project layout](#project-layout)
|
||||||
- [License](#license)
|
- [License](#license)
|
||||||
@ -24,14 +25,12 @@
|
|||||||
Requires Python ≥ 3.11. Install with [uv](https://docs.astral.sh/uv/):
|
Requires Python ≥ 3.11. Install with [uv](https://docs.astral.sh/uv/):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
uv pip install -e "." # core: <core-deps-csv>
|
<install-block>
|
||||||
uv pip install -e ".[dev]" # + dev tools: <dev-deps-csv>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Docker
|
## Docker (dev)
|
||||||
|
|
||||||
Uses [just](https://github.com/casey/just) as a task runner.
|
Uses [just](https://github.com/casey/just) as a task runner. Run `just --list` for the full set of recipes.
|
||||||
Run `just --list` for the full set of recipes.
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
<docker-section>
|
<docker-section>
|
||||||
@ -39,7 +38,7 @@ Run `just --list` for the full set of recipes.
|
|||||||
|
|
||||||
## Quality checks
|
## Quality checks
|
||||||
|
|
||||||
All checks run inside Docker via `just`.
|
All checks run inside Docker.<local-checks-preamble>
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Linting
|
# Linting
|
||||||
@ -52,22 +51,20 @@ All checks run inside Docker via `just`.
|
|||||||
<test-section>
|
<test-section>
|
||||||
|
|
||||||
# Combined
|
# Combined
|
||||||
<combined-section>
|
<combined-section><local-section>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Project layout
|
## Project layout
|
||||||
|
|
||||||
```
|
```
|
||||||
src/<package_name>/ # library source
|
src/<package_name>/ # library source
|
||||||
__init__.py
|
tests/ # test suite
|
||||||
tests/
|
docker-compose.yml
|
||||||
fixtures/ # real data fixtures for tests
|
Dockerfile
|
||||||
Dockerfile # base / production / development stages
|
justfile
|
||||||
docker-compose.yml # dev + production services
|
pyproject.toml
|
||||||
justfile # task runner
|
|
||||||
pyproject.toml # dependencies and tool config
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
<project.name> is licensed under <project.license.text>.
|
<license-block>
|
||||||
|
|||||||
71
skills/engineering/write-readme-py/saduko-license-block.md
Normal file
71
skills/engineering/write-readme-py/saduko-license-block.md
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
# Apache 2.0 License block (Saduko-style)
|
||||||
|
|
||||||
|
Emit this block as `<license-block>` in `readme-py.template.md` **only**
|
||||||
|
when `project.license` resolves to Apache 2.0. For any other licence,
|
||||||
|
emit the one-liner `<project.name> is licensed under <project.license.text>.`
|
||||||
|
instead.
|
||||||
|
|
||||||
|
Substitute every angle-bracketed token; if a token can't be resolved
|
||||||
|
(missing author, no `project.urls.Repository`), ask the user — do not
|
||||||
|
invent.
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
<project.name> is licensed under the Apache License 2.0.
|
||||||
|
|
||||||
|
You are free to:
|
||||||
|
- Use <project.name> for any purpose (commercial or non-commercial)
|
||||||
|
- Modify and distribute the code
|
||||||
|
- Use it in proprietary software
|
||||||
|
- Patent protection included
|
||||||
|
|
||||||
|
### Requirements:
|
||||||
|
- Include the LICENSE and NOTICE files
|
||||||
|
- Preserve copyright notices
|
||||||
|
- State any changes you made
|
||||||
|
|
||||||
|
### Attribution
|
||||||
|
When using <project.name>, we appreciate attribution such as:
|
||||||
|
|
||||||
|
In your project:
|
||||||
|
> Powered by <project.name> by <author>
|
||||||
|
|
||||||
|
In academic papers:
|
||||||
|
```bibtex
|
||||||
|
@software{<project.name>,
|
||||||
|
author = {<author-surname>, <author-given>},
|
||||||
|
title = {<project.name>: <project.description>},
|
||||||
|
year = {<year>},
|
||||||
|
url = {<repo-url>}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Full license: See LICENSE and NOTICE files.
|
||||||
|
```
|
||||||
|
|
||||||
|
## Token resolution
|
||||||
|
|
||||||
|
| Token | Source |
|
||||||
|
|---|---|
|
||||||
|
| `<project.name>` | `pyproject.toml` → `project.name` |
|
||||||
|
| `<project.description>` | `pyproject.toml` → `project.description` |
|
||||||
|
| `<author>` | `project.authors[0].name` (full name as given) |
|
||||||
|
| `<author-surname>` | last whitespace-separated token of `<author>` |
|
||||||
|
| `<author-given>` | everything before `<author-surname>` |
|
||||||
|
| `<year>` | current year (UTC) |
|
||||||
|
| `<repo-url>` | `project.urls.Repository`, fall back to `Homepage` |
|
||||||
|
|
||||||
|
## NOTICE file
|
||||||
|
|
||||||
|
The block references a `NOTICE` file. If the repo does not already have
|
||||||
|
one, write a minimal `NOTICE` alongside the README:
|
||||||
|
|
||||||
|
```
|
||||||
|
<project.name>
|
||||||
|
Copyright <year> <author>
|
||||||
|
|
||||||
|
This product includes software developed by <author>.
|
||||||
|
```
|
||||||
|
|
||||||
|
The Apache 2.0 licence does not *require* a NOTICE file unless the
|
||||||
|
upstream `LICENSE` says it does, but the attribution block references it,
|
||||||
|
so emit one to keep the README honest.
|
||||||
Loading…
x
Reference in New Issue
Block a user