Skip to content

Commit a80e435

Browse files
committed
Rename option COLOR_ENCODING to OUTPUT_FORMAT
1 parent 923b072 commit a80e435

5 files changed

Lines changed: 23 additions & 20 deletions

File tree

Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ TEST_RECIPES_DIR := $(TEST_DIR)/recipes
44

55
TESTS := $(notdir $(wildcard $(TEST_RECIPES_DIR)/*))
66

7-
## if set, debug info is generated in an org file
8-
DEBUG :=
9-
107
## Supported awk variants:
118
AWK := awk
129
AWK_FLAGS :=
1310
AWK_BIN := $(TEST_DIR)/bin
1411
SUPPORTED_AWK_VARIANTS := awk mawk nawk bawk wak goawk
1512

13+
## {ansi, html}
14+
OUTPUT_FORMAT :=
15+
16+
## if set, debug info is generated in an org file
17+
DEBUG :=
18+
1619
## if set, the expected value of a test recipe is updated
1720
## e.g., `make test-default UPDATE_RECIPE=1`
1821
UPDATE_RECIPE :=
@@ -33,7 +36,7 @@ help: TESTS_SUB := <L:1,M:1>$$(TESTS):test-:$(wordlist 1,5,$(subst test-,,$(TEST
3336
help: VFLAGS := -v SUB='$(TESTS_SUB);$(AWK_SUB)' \
3437
-v DEBUG=$(DEBUG) \
3538
-v COLOR_BACKTICKS=33 \
36-
-v COLOR_ENCODING=$(COLOR_ENCODING)
39+
-v OUTPUT_FORMAT=$(OUTPUT_FORMAT)
3740
help: $(AWK_BIN)/$(AWK)
3841
@$< $(VFLAGS) $(AWK_FLAGS) -f makefile-doc.awk $(MAKEFILE_LIST)
3942

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ value"](https://www.gnu.org/software/make/manual/html_node/Simple-Assignment.htm
9595
The following options can be passed to `awk` using `-v option=value` (possible values
9696
are given in `{...}`, `(.)` shows the default)
9797

98+
+ `OUTPUT_FORMAT`: `{(ANSI), HTML}`
9899
+ `DEBUG`: `{(0), 1}` output debug info (in an org-mode format)
99100
+ `DEBUG_FILE`: debug info file
100101
+ `SUB`: see [Substitutions](#substitutions)
@@ -106,7 +107,6 @@ are given in `{...}`, `(.)` shows the default)
106107
* `OFFSET`: `{0, 1, (2), ...}` number of spaces to offset docs from anchors
107108
* `CONNECTED`: `{0, (1)}` ignore docs followed by an empty line
108109
+ Colors:
109-
+ `COLOR_ENCODING`: `{(ANSI), HTML}`
110110
+ `COLOR_DEFAULT`: (`34`: blue) for anchors whose docs start with `##`
111111
+ `COLOR_ATTENTION`: (`31`: red) for anchors whose docs start with `##!`
112112
+ `COLOR_DEPRECATED`: (`33`: yellow) for anchors whose docs start with `##%`

makefile-doc.awk

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# awk [-v option=value] -f makefile-doc.awk [Makefile ...]
1111
#
1212
# Options (possible values are given in {...}, (.) is the default):
13+
# + OUTPUT_FORMAT: {(ANSI), HTML}
1314
# + DEBUG: {(0), 1} output debug info (in an org-mode format)
1415
# + DEBUG_FILE: debug info file
1516
# + SUB: see below
@@ -33,7 +34,6 @@
3334
# * ##@ section (displayed in COLOR_SECTION)
3435
#
3536
# Color codes (https://en.wikipedia.org/wiki/ANSI_escape_code):
36-
# + COLOR_ENCODING: {(ANSI), HTML}
3737
# * COLOR_DEFAULT: (34) blue
3838
# * COLOR_ATTENTION: (31) red
3939
# * COLOR_DEPRECATED: (33) yellow
@@ -42,7 +42,7 @@
4242
# * COLOR_BACKTICKS: (0) disabled -- used for text in backticks in docs
4343
#
4444
# Colors are specified using the parameter in ANSI escape codes, e.g., the parameter
45-
# for blue is the 34 in `\033[34m`. When the COLOR_ENCODING is HTML, colors are
45+
# for blue is the 34 in `\033[34m`. When the OUTPUT_FORMAT is HTML, colors are
4646
# controlled using the class attribute e.g., the value for blue is "ansi34" etc.
4747
#
4848
# SUB:
@@ -583,9 +583,9 @@ function strip_start_end_spaces(string) {
583583
}
584584

585585
function define_color(parameter) {
586-
if (COLOR_ENCODING == "ANSI") {
586+
if (OUTPUT_FORMAT == "ANSI") {
587587
return "\033[" parameter "m"
588-
} else if (COLOR_ENCODING == "HTML") {
588+
} else if (OUTPUT_FORMAT == "HTML") {
589589
if (parameter) {
590590
return "<span class=\"ansi" parameter "\">"
591591
} else {
@@ -596,10 +596,10 @@ function define_color(parameter) {
596596

597597
# Updates global variables: COLOR_*, HTML_*
598598
function initialize_colors() {
599-
COLOR_ENCODING = COLOR_ENCODING == "" ? "ANSI" : toupper(COLOR_ENCODING)
600-
if (COLOR_ENCODING != "ANSI" && COLOR_ENCODING != "HTML") {
601-
print("Ignorring invalid COLOR_ENCODING: " COLOR_ENCODING " (using ANSI instead).")
602-
COLOR_ENCODING = "ANSI"
599+
OUTPUT_FORMAT = OUTPUT_FORMAT == "" ? "ANSI" : toupper(OUTPUT_FORMAT)
600+
if (OUTPUT_FORMAT != "ANSI" && OUTPUT_FORMAT != "HTML") {
601+
print("Ignorring invalid OUTPUT_FORMAT: " OUTPUT_FORMAT " (using ANSI instead).")
602+
OUTPUT_FORMAT = "ANSI"
603603
}
604604
COLOR_DEFAULT_CODE = define_color(COLOR_DEFAULT == "" ? 34 : COLOR_DEFAULT)
605605
COLOR_ATTENTION_CODE = define_color(COLOR_ATTENTION == "" ? 31 : COLOR_ATTENTION)
@@ -612,7 +612,7 @@ function initialize_colors() {
612612

613613
COLOR_RESET_CODE = define_color(0)
614614

615-
if (COLOR_ENCODING == "HTML") {
615+
if (OUTPUT_FORMAT == "HTML") {
616616
HTML_CLOSE_PRE = "</pre>"
617617
HTML_STYLE_AND_OPEN_PRE = "<head>\n <style type=\"text/css\">\n .ansi31 { color: #d70000; }\n .ansi32 { color: #5f8700; }\n .ansi33 { color: #af8700; }\n .ansi34 { color: #0087ff; }\n .ansi35 { color: #af005f; }\n </style>\n</head>\n<pre>"
618618
}
@@ -640,7 +640,7 @@ function print_help() {
640640
printf " DEPRECATED ([bool] show deprecated anchors): %s\n", DEPRECATED
641641
printf " OFFSET (offset of docs from anchors): %s\n", OFFSET
642642
printf " CONNECTED (ignore docs followed by an empty line): %s\n", CONNECTED
643-
printf " COLOR_ENCODING: %s\n", COLOR_ENCODING
643+
printf " OUTPUT_FORMAT: %s\n", OUTPUT_FORMAT
644644
printf " COLOR_: "
645645
printf "%sDEFAULT%s, ", COLOR_DEFAULT_CODE, COLOR_RESET_CODE
646646
printf "%sATTENTION%s, ", COLOR_ATTENTION_CODE, COLOR_RESET_CODE
@@ -1058,7 +1058,7 @@ END {
10581058
debug(DEBUG_INDENT_STACK " extracted_sub_params")
10591059
debug_indent_down()
10601060

1061-
if (COLOR_ENCODING == "HTML") {
1061+
if (OUTPUT_FORMAT == "HTML") {
10621062
print(HTML_STYLE_AND_OPEN_PRE)
10631063
}
10641064

@@ -1101,7 +1101,7 @@ END {
11011101
}
11021102
}
11031103

1104-
if (COLOR_ENCODING == "HTML") {
1104+
if (OUTPUT_FORMAT == "HTML") {
11051105
print(HTML_CLOSE_PRE)
11061106
}
11071107

test/Makefile.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ PADDING =
44
HEADER =
55
DEPRECATED =
66
COLOR_BACKTICKS =
7-
COLOR_ENCODING =
7+
OUTPUT_FORMAT =
88

99
AWK := awk
1010
AWK_FLAGS :=
@@ -20,7 +20,7 @@ help:
2020
-v CONNECTED=$(CONNECTED) \
2121
-v DEPRECATED=$(DEPRECATED) \
2222
-v COLOR_BACKTICKS=$(COLOR_BACKTICKS) \
23-
-v COLOR_ENCODING=$(COLOR_ENCODING) \
23+
-v OUTPUT_FORMAT=$(OUTPUT_FORMAT) \
2424
-f ../makefile-doc.awk $(MAKEFILE_LIST)
2525

2626
test-10: ##% some target

test/recipes/test-html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-v COLOR_ENCODING=html test/Makefile
1+
-v OUTPUT_FORMAT=html test/Makefile
22
<span class="ansi35">[test/Makefile] redefined docs of target: test-3</span>
33
<span class="ansi35">[test/Makefile] redefined docs of target: test-14</span>
44
<head>

0 commit comments

Comments
 (0)