Skip to content

Commit be82b89

Browse files
committed
docs: add section anchors to config.ini in references.txt; change format
Added section anchors for each section of config.ini in the reference.html file. This makes it easier to link to the right section of the config file when discussing config.ini settings. Getting this to work using the initial sed implementation was going to be a nightmare, so rewrote it in awk. The pre-section comments are now separated by a blank line from the section marker. Also rst directives no longer have blank lines between them.
1 parent e86dfb2 commit be82b89

File tree

3 files changed

+74
-51
lines changed

3 files changed

+74
-51
lines changed

doc/Makefile

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,8 @@ tracker_config.txt: ../roundup/configuration.py
66
python3 ../roundup/scripts/roundup_admin.py \
77
genconfig _temp_config.txt
88

9-
## format and add directives to config file
10-
# 1. delete first 8 lines of comments (1,8d)
11-
# Some sections have a comment block before the section
12-
# [main] Put the comment block with the section marker
13-
# after the index/code directives. To do this:
14-
# 2. Store all comment and blank lines in the hold space
15-
# (H). Delete the current line and continue with the
16-
# next line (d).
17-
# 3. When we see a section marker, append the section
18-
# marker to the hold space (H). substitute for the
19-
# section marker index and code directives
20-
# (s/.../.../) using the section name (\1) for the
21-
# index. Print the directives (p). Empty (zero) the
22-
# pattern space (z). Pull the hold space to the
23-
# pattern space (x) (which also empties the hold space
24-
# because of (z). Print the new pattern space
25-
# [comments and section marker] (p). Delete the patern
26-
# space and process next input line (d).
27-
# 4. For any other line, append the line to the hold
28-
# space (H). Zero out the pattern buffer (z). Swap the
29-
# hold space and pattern space [comments and setting
30-
# line] (x).
31-
#
32-
# Automatically print the pattern space after the last
33-
# command because we are not using 'sed -n'.
34-
#
35-
# The last sed command indents every line that is not
36-
# empty or does not start with '..' (a directive) with
37-
# two spaces.
38-
# The cat -s squeezes adjacent blank lines to 1 blank
39-
# line.
40-
@sed -e '1,8d' \
41-
-e '/^\#\|^$$/{H;d}' \
42-
-e '/^\[\([a-z]*\)\]/{H; s/^\[\([a-z]*\)\]/\n.. index:: config.ini; sections \1\n\n.. code:: ini/; p; z; x; p; d}' \
43-
-e '/./{H;z;x}' \
44-
_temp_config.txt | \
45-
sed -e '/^\.\.\|^$$/!s/^/ /' | \
46-
cat -s > tracker_config.txt
9+
awk -f format_config.awk _temp_config.txt | \
10+
cat -s > tracker_config.txt
4711
rm -f _temp_config.txt
4812

4913
## generate html versions of man pages for inclusion in documentation

doc/format_config.awk

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#! /bin/awk
2+
3+
# delete first 8 lines
4+
NR < 9 {next}
5+
6+
# When we see a section [label]:
7+
# emit section index marker,
8+
# emit section anchor
9+
# set up for code formating
10+
# emit any comments/blank line that are accumulated before the
11+
# section marker
12+
# print the indented section marker
13+
#
14+
# zero the accumulator and the variable that prevents large blocks
15+
# of empty lines.
16+
/^\[([a-z]*)\]/ { match($0, /^\[([a-z]*)\].*/, section_match);
17+
section = section_match[1];
18+
print("\n\n.. index:: config.ini; sections " section);
19+
print(".. _`config-ini-section-" section "`:");
20+
print(".. code:: ini\n");
21+
if (accumulate) {
22+
print(" " accumulate "\n");
23+
}
24+
print(" " $0);
25+
accumulate = "";
26+
prev_line_is_blank = 0;
27+
}
28+
29+
# if the line is a setting line (even if commented out)
30+
# print the accumulated comments/blank lines and the setting line
31+
# zero the accumulator and the variable that prevents blocks of blank lines
32+
# get the next input line
33+
/^#?[a-z0-9_-]* =/ { print accumulate "\n " $0;
34+
accumulate = "";
35+
prev_line_is_blank = 0;
36+
next;
37+
}
38+
39+
# accumulate comment lines and indent them
40+
/^#/ { accumulate = accumulate "\n " $0; prev_line_is_blank = 0;}
41+
42+
# accumulate a blank line only if the previous line was not blank.
43+
/^$/ { if (! prev_line_is_blank) {accumulate = accumulate $0};
44+
prev_line_is_blank = 1;
45+
}

doc/tracker_config.txt

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
.. index:: config.ini; sections main
3-
3+
.. _`config-ini-section-main`:
44
.. code:: ini
55

66
[main]
@@ -184,7 +184,7 @@
184184
password_pbkdf2_default_rounds = 2000000
185185

186186
.. index:: config.ini; sections tracker
187-
187+
.. _`config-ini-section-tracker`:
188188
.. code:: ini
189189

190190
[tracker]
@@ -231,7 +231,7 @@
231231
language =
232232

233233
.. index:: config.ini; sections web
234-
234+
.. _`config-ini-section-web`:
235235
.. code:: ini
236236

237237
[web]
@@ -595,8 +595,8 @@
595595
# as is. It removes any whitespace at the end of the
596596
# line, so a newline can be put in the file.
597597
#
598-
# Default: 3CpCdT9GrdQv7SCn24DTIQTwAoBguqhAopZnXRZA38w=
599-
secret_key = 3CpCdT9GrdQv7SCn24DTIQTwAoBguqhAopZnXRZA38w=
598+
# Default: DWmbKgVUy6fF5D2Y5TD5Az+dnHhMYKCCpJzIY3H8nsU=
599+
secret_key = DWmbKgVUy6fF5D2Y5TD5Az+dnHhMYKCCpJzIY3H8nsU=
600600

601601
# This is used to sign/validate json web tokens
602602
# (JWT). Even if you don't use JWTs it must not be
@@ -624,11 +624,13 @@
624624
jwt_secret = disabled
625625

626626
.. index:: config.ini; sections rdbms
627-
627+
.. _`config-ini-section-rdbms`:
628628
.. code:: ini
629629

630+
630631
# Settings in this section (except for backend) are used
631632
# by RDBMS backends only.
633+
632634
[rdbms]
633635

634636
# Database backend.
@@ -767,10 +769,12 @@
767769
serverside_cursor = yes
768770

769771
.. index:: config.ini; sections sessiondb
770-
772+
.. _`config-ini-section-sessiondb`:
771773
.. code:: ini
772774

775+
773776
# Choose configuration for session and one time key storage.
777+
774778
[sessiondb]
775779

776780
# Set backend for storing one time key (otk) and session data.
@@ -800,7 +804,7 @@
800804
redis_url = redis://localhost:6379/0?health_check_interval=2
801805

802806
.. index:: config.ini; sections logging
803-
807+
.. _`config-ini-section-logging`:
804808
.. code:: ini
805809

806810
[logging]
@@ -836,12 +840,14 @@
836840
disable_loggers = no
837841

838842
.. index:: config.ini; sections mail
839-
843+
.. _`config-ini-section-mail`:
840844
.. code:: ini
841845

846+
842847
# Outgoing email options.
843848
# Used for nosy messages, password reset and registration approval
844849
# requests.
850+
845851
[mail]
846852

847853
# The email domain that admin_email, issue_tracker and
@@ -942,10 +948,12 @@
942948
add_authoremail = yes
943949

944950
.. index:: config.ini; sections mailgw
945-
951+
.. _`config-ini-section-mailgw`:
946952
.. code:: ini
947953

954+
948955
# Roundup Mail Gateway options
956+
949957
[mailgw]
950958

951959
# Keep email citations when accepting messages.
@@ -1087,10 +1095,12 @@
10871095
keep_real_from = no
10881096

10891097
.. index:: config.ini; sections pgp
1090-
1098+
.. _`config-ini-section-pgp`:
10911099
.. code:: ini
10921100

1101+
10931102
# OpenPGP mail processing options
1103+
10941104
[pgp]
10951105

10961106
# Enable PGP processing. Requires gpg. If you're planning
@@ -1137,10 +1147,12 @@
11371147
require_incoming = signed
11381148

11391149
.. index:: config.ini; sections nosy
1140-
1150+
.. _`config-ini-section-nosy`:
11411151
.. code:: ini
11421152

1153+
11431154
# Nosy messages sending
1155+
11441156
[nosy]
11451157

11461158
# Send nosy messages to the author of the message.
@@ -1190,10 +1202,12 @@
11901202
max_attachment_size = 9223372036854775807
11911203

11921204
.. index:: config.ini; sections markdown
1193-
1205+
.. _`config-ini-section-markdown`:
11941206
.. code:: ini
11951207

1208+
11961209
# Markdown rendering options.
1210+
11971211
[markdown]
11981212

11991213
# If yes/true, render single new line characters in markdown

0 commit comments

Comments
 (0)