https://github.com/shini4i/pre-commit-makefile
pre-commit hook to update README with Makefile targets description
https://github.com/shini4i/pre-commit-makefile
makefile pre-commit pre-commit-hooks
Last synced: 4 months ago
JSON representation
pre-commit hook to update README with Makefile targets description
- Host: GitHub
- URL: https://github.com/shini4i/pre-commit-makefile
- Owner: shini4i
- License: mit
- Created: 2023-09-20T19:55:28.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-05T16:39:03.000Z (about 1 year ago)
- Last Synced: 2024-12-05T17:20:54.955Z (about 1 year ago)
- Topics: makefile, pre-commit, pre-commit-hooks
- Language: Go
- Homepage:
- Size: 48.8 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🛠pre-commit-makefile ðŸ›
This project allows users to automatically update their README.md with descriptions of Makefile targets.



[](https://codecov.io/gh/shini4i/pre-commit-makefile)
[](https://goreportcard.com/report/github.com/shini4i/pre-commit-makefile)

## Prerequisites
To use this project, you need to install `pre-commit-makefile` binary. You can do this by running:
```bash
brew install shini4i/tap/pre-commit-makefile
````
Or by downloading the desired version from [releases](https://github.com/shini4i/pre-commit-makefile/releases) page.
The expected `Makefile` format is the following:
```makefile
.PHONY: help
help: ## print this help
@echo "Usage: make [target]"
@grep -E '^[a-z.A-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: test
test: ## run tests
@go test -v ./... -count=1
```
> **Note**
The content after `##` will be used as a target description
## Configuration
To start using this project, add the following to your `.pre-commit-config.yaml`:
```yaml
repos:
- repo: https://github.com/shini4i/pre-commit-makefile
rev: v0.2.2
hooks:
- id: makefile-validator
- id: makefile-readme-updater
```
## Validator
Currently, the validator is limited to checking if the `Makefile` targets have relevant `.PHONY` definitions.
No additional configuration is required.
## Readme Updater
The following comment markers should be added to your `README.md`:
```markdown
```
The dynamically generated content will be placed between the markers.
Additionally, it is possible to override a few settings by adding the following arguments to your `.pre-commit-config.yaml`:
```yaml
args:
- --readme-path=docs/README.md
- --section-name=## Usage
```
#### Example
The `Makefile` in this repository will produce the following output:
To install dependencies run:
```bash
make install-deps
```
To build project binary run:
```bash
make build
```
To run tests run:
```bash
make test
```
To run tests with coverage run:
```bash
make test-coverage
```
To remove build artifacts run:
```bash
make clean
```
> **Note**
The generated content will be placed under `## Makefile targets` section.
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.