config: Let "unset" delete built-in options too.
[elinks/elinks-j605.git] / doc / tools / conf2doc
blob99034bb293cb2f50888025a8fc2662947d2db525
1 #!/bin/sh
3 # Generate asciidoc from the features.conf file in the top-level direftory.
4 # Copyright (c) Jonas Fonseca <fonseca@diku.dk>, 2005
7 CONFFILE="$1"
8 TMPFILE=$(mktemp import-features.conf.XXXXXX) || exit 1
10 strip_comment()
12 echo "$1" | sed 's/^#\+\( \)*//'
15 print_line()
17 line="$1"
19 echo "$(strip_comment "$line")"
22 first_section=
23 config_default=
24 config_name="features.conf"
25 section_title=
26 section_mark="~"
27 first_section=
29 print_section()
31 if [ -n "$section_title" ]; then
32 # "### Feature configuration file"
33 if [ "$section_title" != "Notes for developers" ]; then
34 label=
35 if [ -n "$config_name" ]; then
36 section_title="$section_title (\`$config_name\`)"
37 label="[[$(echo $config_name | sed 's/_/-/g')]]"
39 cat << __END__
40 $label
41 $section_title
42 $(echo "$section_title" | tr 'A-Za-z -_`' "$section_mark")
43 $(cat $TMPFILE)
45 $config_default
47 __END__
49 echo > $TMPFILE
50 section_mark="^"
51 section_title=
52 config_name=
53 config_default=
57 cat "$CONFFILE" | while read line; do
58 case "$line" in
59 "### "*)
60 print_section
61 # Reset
62 section_title=$(strip_comment "$line")
64 CONFIG*)
65 config_name=$(echo "$line" | cut -d '=' -f 1)
66 print_section
68 "# Default:"*)
69 config_default=$(strip_comment "$line" | sed 's/Default://')
70 config_default="*Default:* $config_default"
72 ""|"# vim:"*)
73 # Ignore
75 "#"*)
76 line=$(strip_comment "$line")
77 echo "$line" >> $TMPFILE
79 esac
80 done
82 print_section
84 rm -f $TMPFILE
86 # vim: tabstop=4 shiftwidth=4 textwidth=76