-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
46 lines (37 loc) · 1.15 KB
/
makefile
File metadata and controls
46 lines (37 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Makefile for code formatting using Black
# -------- reusable macro --------
define run_black_cmd
ifndef el
$(error "Please provide a file path using el=<file_path>")
else
@echo "$(1) $(el)..." // file path
@black $(2) $(el) // flag passed to black
@echo "$(1) $(el) complete."
endif
endef
# -------- Global target --------
format-all:
@echo "Formatting all source files..."
@black .
@echo "Formatting complete."
check-formatting-all:
@echo "Checking code format..."
@black --check . || true
@echo "Format check complete."
get-formatting-status-all:
@echo "Getting formatting status..."
@black --diff --color .
@echo "Formatting status complete."
# -------- Targeting a specific file --------
format-file:
$(call run_black_cmd,Formatting,)
check-formatting-file:
$(call run_black_cmd,Checking formatting,--check --color)
get-formatting-status-file:
$(call run_black_cmd,Getting formatting status,--diff --color)
# -------- Clean all --------
clean-code: check-formatting-all get-formatting-status-all format-all
@echo "Code cleaned and formatted, you can commit the changes now."
# --------- Serve documentation ---------
documentation:
@mkdocs serve