/
doc.m4
171 lines (151 loc) · 4.43 KB
/
doc.m4
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
dnl vim:ts=32:sw=32:mps+=⟦\:⟧
dnl
divert(-1)changequote(⟦,⟧)
__AUTHOR(⟦Josef Kubin⟧, ⟦2020,01,20⟧)
___DESCR(⟦extracts headers from all source files and creates short documentation⟧)
__REASON(⟦solution for cryptic short filenames⟧)
___USAGE(⟦m4 doc.m4 file1.m4 file2.sed file3.abc …⟧)
# ---- 8< ---- 8< ---- 8< ---- 8< ----
# this section may be in a separated file for another language
# for example: m4 lang_cs.m4 doc.m4 file1.m4 file2.sed file3.abc …
# for example: m4 lang_sk.m4 doc.m4 file1.m4 file2.sed file3.abc …
# for example: m4 lang_en.m4 doc.m4 file1.m4 file2.sed file3.abc …
# …
#
# file headers
define(⟦__AUTHOR_NAME⟧, ⟦Author⟧)
define(⟦__CREATION_DATE⟧, ⟦Started⟧)
define(⟦__FILE_NAME⟧, ⟦File⟧)
define(⟦__AUTHOR_NOTE⟧, ⟦Note⟧)
define(⟦__THANKS_CAPT⟧, ⟦Thanks⟧)
define(⟦___DESCR_CAPT⟧, ⟦Description⟧)
define(⟦__REASON_CAPT⟧, ⟦Reason⟧)
define(⟦___USAGE_CAPT⟧, ⟦Usage⟧)
# conversion from month numbers to months names
define(⟦01⟧, ⟦January⟧)
define(⟦02⟧, ⟦February⟧)
define(⟦03⟧, ⟦March⟧)
define(⟦04⟧, ⟦April⟧)
define(⟦05⟧, ⟦May⟧)
define(⟦06⟧, ⟦June⟧)
define(⟦07⟧, ⟦July⟧)
define(⟦08⟧, ⟦August⟧)
define(⟦09⟧, ⟦September⟧)
define(⟦10⟧, ⟦October⟧)
define(⟦11⟧, ⟦November⟧)
define(⟦12⟧, ⟦December⟧)
# British: day-month-year
define(⟦CONVERT_DATE_TO_ANOTHER_FORMAT⟧, ⟦alias_ifdef(⟦$2⟧, ⟦__CREATION_DATE: alias_format(⟦%d⟧, ⟦$3⟧) alias_indir(⟦$2⟧) $1
⟧)⟧)
# American: month-day-year
#define(⟦CONVERT_DATE_TO_ANOTHER_FORMAT⟧, ⟦alias_ifdef(⟦$2⟧, ⟦__CREATION_DATE: alias_indir(⟦$2⟧) alias_format(⟦%d⟧, ⟦$3⟧)th, $1
#⟧)⟧)
# end of a language specific section
# ---- 8< ---- 8< ---- 8< ---- 8< ----
# counter for input files
# A → β
define(⟦alias_COUNTER_val⟧, 0)
define(⟦alias_COUNTER⟧, ⟦alias_define(⟦alias_COUNTER_val⟧, alias_incr(alias_COUNTER_val))alias_COUNTER_val⟧)
# A → β
define(⟦__AUTHOR⟧, ⟦
alias_divert(2)alias_dnl
---
__FILE_NAME ⟦#⟧alias_COUNTER: alias___file__
alias_ifelse(⟦$1⟧, ⟦⟧, ⟦⟧, ⟦__AUTHOR_NAME: $1
⟧)alias_dnl
CONVERT_DATE_TO_ANOTHER_FORMAT($2)alias_dnl
alias_ifelse(⟦$3⟧, ⟦⟧, ⟦⟧, ⟦__AUTHOR_NOTE: $3
⟧)alias_dnl
alias_divert(-1)
⟧)
# A → β
# β
define(⟦__THANKS⟧, ⟦
alias_ifelse(⟦$1⟧, ⟦⟧, ⟦⟧, ⟦
alias_divert(2)alias_dnl
$0_CAPT: $1
alias_divert(-1)
⟧)
⟧)
# A → β
define(⟦___DESCR⟧, defn(⟦__THANKS⟧))
define(⟦__REASON⟧, defn(⟦__THANKS⟧))
define(⟦___USAGE⟧, defn(⟦__THANKS⟧))
# comment out this paragraph if you do not like it (note the right unpaired bracket)
divert(0)dnl
⟦#⟧ vim:wrap:spell:spelllang=en
# DO NOT EDIT! This file is generated automatically!
⟦#⟧ generated: esyscmd(⟦date '+%Y%m%d-%T'⟧)dnl
divert(2)dnl
#
# To update, run:
# ~]$ make doc
divert(-1)
# adds the total number of files at the end of all file processing
m4wrap(⟦
alias_divert(1)alias_dnl
⟦#⟧ total number of files: alias_COUNTER_val
⟧)
# creates aliases for needed keywords (the built-in keywords will be turned off)
# A → β
define(⟦alias___file__⟧, defn(⟦__file__⟧))
define(⟦alias_define⟧, defn(⟦define⟧))
define(⟦alias_divert⟧, defn(⟦divert⟧))
define(⟦alias_dnl⟧, defn(⟦dnl⟧))
define(⟦alias_format⟧, defn(⟦format⟧))
define(⟦alias_ifdef⟧, defn(⟦ifdef⟧))
define(⟦alias_ifelse⟧, defn(⟦ifelse⟧))
define(⟦alias_incr⟧, defn(⟦incr⟧))
define(⟦alias_indir⟧, defn(⟦indir⟧))
# disable one-line comments (M4 can process symbols in the comments) and turn off all M4 keywords
changecom
undefine(
⟦__file__⟧,
⟦__gnu__⟧,
⟦__line__⟧,
⟦__os2__⟧,
⟦__program__⟧,
⟦__unix__⟧,
⟦__windows__⟧,
⟦builtin⟧,
⟦changecom⟧,
⟦changequote⟧,
⟦changeword⟧,
⟦debugfile⟧,
⟦debugmode⟧,
⟦decr⟧,
⟦define⟧,
⟦defn⟧,
⟦divert⟧,
⟦divnum⟧,
⟦dnl⟧,
⟦dumpdef⟧,
⟦errprint⟧,
⟦esyscmd⟧,
⟦eval⟧,
⟦format⟧,
⟦ifdef⟧,
⟦ifelse⟧,
⟦include⟧,
⟦incr⟧,
⟦index⟧,
⟦indir⟧,
⟦len⟧,
⟦m4exit⟧,
⟦m4wrap⟧,
⟦maketemp⟧,
⟦patsubst⟧,
⟦popdef⟧,
⟦pushdef⟧,
⟦regexp⟧,
⟦shift⟧,
⟦sinclude⟧,
⟦substr⟧,
⟦syscmd⟧,
⟦sysval⟧,
⟦traceoff⟧,
⟦traceon⟧,
⟦translit⟧,
⟦undefine⟧,
⟦undivert⟧,
)