Loslegen
README Generator — Scan projects, write README

README Generator — Scan projects, write README

Point it at a project and it reads the real files — languages, dependency manifests, entry points, tests, license — and writes a complete README.md with install, run, test and license sections. Deterministic, so you can commit it and gate it in CI; it never runs your code or makes network calls. #Ingenieurwesen

Rating
Weitere Bewertungen erforderlich
Sold
0
How to use
Herunterladen

The problem

The code is written; the README is not. A new teammate clones the repo and cannot tell what it is, what to install, or how to run it, so they ask — or they guess. People who do write a README write it once, by hand, and it drifts: a dependency is added, a script is renamed, and the README still describes last month's project. Nobody notices until someone follows it and it does not work.

How it works

  1. Walks the project, skipping noise (.git, node_modules, __pycache__, dist, build, and the like).
  2. Runs a set of detectors over the files that are actually there:
    • Name and description — from package.json or pyproject.toml, else the folder name.
    • Languages — counts source files by extension and reports them most-common first.
    • Dependencies — looks for a manifest (requirements.txt, pyproject.toml, package.json, go.mod, Cargo.toml, …) and names the install command for each.
    • Entry points — main.py, app.py, index.js, a package.json main, and any module with an if __name__ == "__main__" block (test files excluded).
    • Scripts — the scripts block of package.json.
    • Tests — a tests/ directory of Python tests, or an npm test script, and the command that runs them.
    • License — reads a LICENSE file and names it (MIT, Apache-2.0, GPL, BSD, …).
  3. Renders the findings into README.md sections: a title, Built with, Install, Usage, Tests, License.

The scan is deterministic: the same tree always produces the same README, so you can commit it and gate it in CI.

Usage

# print the README to the terminal
python3 scripts/readme_generator.py --project path/to/project

# write README.md into the project
python3 scripts/readme_generator.py --project path/to/project --write

# see the raw scan as JSON
python3 scripts/readme_generator.py --project path/to/project --json

# CI gate: exit 1 if README.md is missing or does not match the scan
python3 scripts/readme_generator.py --project path/to/project --check

Other options: --output PATH (write somewhere other than the project root). With no project given, the current directory is used.

The generated marker and --check

Every README the tool writes begins with <!-- generated-by: readme-generator -->. --check uses that marker: it passes only when README.md exists, carries the marker, and matches a fresh scan. A hand-written README (no marker) fails --check, so the gate never overwrites or silently approves human prose — it only enforces the ones this tool owns.

Exit codes

code meaning
0 README printed or written, or --check passed
1 --check was given and README.md is missing or does not match the scan
2 the project directory does not exist

Limits (read these)

  • A generated README is a starting point, not the whole story. The tool reports what the files show — install, run, test, license. It cannot write the why: the purpose, the design, the gotchas. Fill those in yourself; the marker line is a comment and does not get in the way.
  • Detection is by filename and manifest, not by running anything. The tool never installs dependencies, never executes your code or tests, and makes no network calls. If a project launches through an unusual wrapper, add the entry point by hand after generating.
  • Version numbers are not read from manifests. Install commands are the standard ones for each ecosystem; pinned versions live in your manifest, which the command already respects.
  • Files over 512 KB are skipped during the scan. Only the manifests and extensions listed above are recognized.