Last active
May 4, 2023 12:15
-
-
Save skigun/193d3de4723f8962c7c31000570a7447 to your computer and use it in GitHub Desktop.
How to document the Makefile with the Symfony style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.DEFAULT_GOAL := help | |
ifndef CI_JOB_ID | |
# COLORS | |
GREEN := $(shell tput -Txterm setaf 2) | |
YELLOW := $(shell tput -Txterm setaf 3) | |
WHITE := $(shell tput -Txterm setaf 7) | |
RESET := $(shell tput -Txterm sgr0) | |
TARGET_MAX_CHAR_NUM=30 | |
endif | |
help: | |
@echo "${GREEN}My Appplication${RESET} https://app.docker" | |
@awk '/^[a-zA-Z\-\_0-9]+:/ { \ | |
helpMessage = match(lastLine, /^## (.*)/); \ | |
if (helpMessage) { \ | |
helpCommand = substr($$1, 0, index($$1, ":")); helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ | |
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \ | |
} \ | |
isTopic = match(lastLine, /^###/); \ | |
if (isTopic) { printf "\n%s\n", $$1; } \ | |
} { lastLine = $$0 }' $(MAKEFILE_LIST) | |
# Lines below show an exemple of declaration for a beautiful self documented Makefile ! | |
################################# | |
Project: | |
## Install environment from scratch | |
install: xxx | |
## Start containers | |
start: xxx | |
################################# | |
RabbitMQ: | |
## Create RabbitMQ exchanges and queues and setup the bindings | |
rabbitmq: wait-rabbitmq xxx | |
## Purge all RabbitMQ queues | |
rabbitmq-purge: rabbitmq | |
################################# | |
Database: | |
db-create: xxx # will not be listed as available command | |
## Generate synchronised data | |
db-reload-fixtures: xxx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment