Skip to content

Commit b3cccba

Browse files
dev: Makefile tasks to run local mkdocs server & megalinter
`make docs` builds book and runs in a local server on port 7777 `make lint` runs megalinter lint tools from documentation image (requires Docker running)
1 parent d64c735 commit b3cccba

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

Makefile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# ------------------------------------------
2+
# Practicalli: Makefile
3+
#
4+
# Consistent set of targets to support local book development
5+
# ------------------------------------------
6+
7+
# .PHONY: ensures target used rather than matching file name
8+
# https://makefiletutorial.com/#phony
9+
.PHONY: all clean docs lint pre-commit-check test
10+
11+
# ------- Makefile Variables --------- #
12+
# run help if no target specified
13+
.DEFAULT_GOAL := help
14+
15+
# Column the target description is printed from
16+
HELP-DESCRIPTION-SPACING := 24
17+
18+
# Tool Commands
19+
MEGALINTER_RUNNER := npx mega-linter-runner --flavor documentation --env "'MEGALINTER_CONFIG=.github/config/megalinter.yaml'" --remove-container
20+
21+
# Makefile file and directory name wildcard
22+
EDN-FILES := $(wildcard *.edn)
23+
# ------------------------------------ #
24+
25+
# ------ Quality Checks ------------ #
26+
pre-commit-check: lint
27+
28+
lint: ## Run MegaLinter with custom configuration (node.js required)
29+
$(info --------- MegaLinter Runner ---------)
30+
$(MEGALINTER_RUNNER)
31+
32+
lint-fix: ## Run MegaLinter with custom configuration (node.js required)
33+
$(info --------- MegaLinter Runner ---------)
34+
$(MEGALINTER_RUNNER) --fix
35+
36+
lint-clean: ## Clean MegaLinter report information
37+
$(info --------- MegaLinter Clean Reports ---------)
38+
- rm -rf ./megalinter-reports
39+
# ------------------------------------ #
40+
41+
# --- Documentation Generation ------ #
42+
docs: ## Build and run mkdocs in local server
43+
$(info --------- Mkdocs Local Server ---------)
44+
mkdocs serve --dev-addr localhost:7777
45+
46+
docs-changed: ## Build only changed files and run mkdocs in local server
47+
$(info --------- Mkdocs Local Server ---------)
48+
mkdocs serve --dirtyreload --dev-addr localhost:7777
49+
50+
docs-build: ## Build mkdocs
51+
$(info --------- Mkdocs Local Server ---------)
52+
mkdocs build
53+
# ------------------------------------ #
54+
55+
# ------------ Help ------------------ #
56+
# Source: https://nedbatchelder.com/blog/201804/makefile_help_target.html
57+
58+
help: ## Describe available tasks in Makefile
59+
@grep '^[a-zA-Z]' $(MAKEFILE_LIST) | \
60+
sort | \
61+
awk -F ':.*?## ' 'NF==2 {printf "\033[36m %-$(HELP-DESCRIPTION-SPACING)s\033[0m %s\n", $$1, $$2}'
62+
# ------------------------------------ #
63+

0 commit comments

Comments
 (0)