-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions2table.sed
More file actions
executable file
·45 lines (33 loc) · 945 Bytes
/
options2table.sed
File metadata and controls
executable file
·45 lines (33 loc) · 945 Bytes
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
#!/bin/sed -Enf
# Print table header at the beginning
1 {
# Save pattern space (current line)
x
# Empty pattern space
z
# Put table header into pattern space and print it out
s,^,|Configuration name|Default value|Description|,p
# Substitute all characters except "|" with "-" and print out (header separator)
s,[^|],-,gp
# Restore pattern space
x
}
# Process only lines starting with "Config."
/^Config\./ {
# Remove "Config." string
s,,,
# Prepare line with "config_variable", "default_value", "description"
# :numeric value
s,^([^ =]+) *= *([^ ']*) *// *(.*)$,| \1 | `\2` | \3 |,
# :string value
s,^([^ =]+) *= *'([^']*)' *// *(.*)$,| \1 | `\2` | \3 |,
# Escape closing and opening "`" in code (expects no spaces inside ``)
# Set label "a"
:a
# Escape ` in code (single part)
s,``([^ `]+)``,`` `\1` ``,
# When substitution was made, goto "a" (try again)
ta
# Print out table
p
}