Skip to content

Latest commit

Β 

History

History
102 lines (85 loc) Β· 3.68 KB

File metadata and controls

102 lines (85 loc) Β· 3.68 KB

readme-update πŸ¦€

PyPI Downloads

Tired of updating documentation?

This tool updates your README.md with a one line description for each of the python scripts in a directory you point it to (and recursively). It adds the text for lines that start with "Description: " and "Link: ". It ignores any that don't have the description.

You can supply alternative --table-fields to create a table with columns for the provided fields. The --link-fields argument is used to signal which of the --table-fields should be rendered as links like this [Link](this/is/the/link).

The idea is that links should link to higher level documentation (if it exists).

This can be used as a pre-commit for python projects with standalone scripts for specific processes.

It will update in place if the # Scripts block exists or else it will append it to the end of the README.md

example_usage.py shows how to call the script from python.

Here is an example output from the tool:

Scripts

Name Description Link
example1.py This is an example file that links to my own github. Link
example2.py Some other description.
example3.py Link
::

Installation

pip install readme-update

Or

uv add readme-update

Usage

Assuming its is run from this location.

root/
  scripts/
    example_script.py
  README.md
uv run -m update_readme \
--scripts-root "./scripts" \
--readme-path "./README.md"

Args

Argument Type Required Default Description
--scripts-root str βœ… Path to the root of the scripts to scan
--readme-path str ❌ './README.md' Path to the README file that will be modified
--table-fields list ❌ ["Description", "Link"] Fields to dynamically add to the README.md table.
--link-fields list ❌ ["Link"] Which of the provided table fields should be rendered as links.

Ret codes

RetCode int description
NoModification 0 The Repo Map reflects the current state of the repo.
ModifiedReadme 1 The README was updated.
NoPyFiles 2 No python files found at the scripts-root location.
FailedParsingFile 3 Failed to read README file
FailedToWriteReadme 4 The given README.md path does not match the expected basename.
InvalidLinkFields 5 The given link_fields are not a subset of the given table_fields.

Repo map

β”œβ”€β”€ .github
β”‚   └── workflows
β”‚       β”œβ”€β”€ ci.yaml
β”‚       └── publish.yaml
β”œβ”€β”€ python
β”‚   └── update_readme
β”‚       β”œβ”€β”€ __init__.py
β”‚       └── __main__.py
β”œβ”€β”€ scripts
β”‚   β”œβ”€β”€ example1.py
β”‚   β”œβ”€β”€ example2.py
β”‚   └── example3.py
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ core
β”‚   β”‚   β”œβ”€β”€ adapters.rs
β”‚   β”‚   β”œβ”€β”€ domain.rs
β”‚   β”‚   └── mod.rs
β”‚   β”œβ”€β”€ api.rs
β”‚   └── lib.rs
β”œβ”€β”€ tests
β”‚   └── integration_tests.rs
β”œβ”€β”€ .pre-commit-config.yaml
β”œβ”€β”€ Cargo.lock
β”œβ”€β”€ Cargo.toml
β”œβ”€β”€ README.md
β”œβ”€β”€ pyproject.toml
└── uv.lock
::