Skip to content

Commit b41c10a

Browse files
committed
Make issues_to_be_moved.sh script add each issue to TOC
1 parent c495091 commit b41c10a

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

bin/issues_to_be_moved.sh

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ usage()
1717
echo
1818
echo "Options:"
1919
echo "--help Print this usage and exit."
20+
echo "--no-toc Do not include each issue in table of contents"
2021
echo "--intros Read a block of HTML text from standard input"
2122
echo " as an introductory paragraph for each status."
2223
echo "--nad Include Tentatively NAD issues in the report."
@@ -37,10 +38,12 @@ die()
3738
intros=no
3839
nad=no
3940
ts=no
41+
toc=yes
4042
while [[ "$1" == --* ]]
4143
do
4244
case "$1" in
4345
--help) usage ; exit ;;
46+
--no-toc) toc=no ;;
4447
--intros) intros=yes ;;
4548
--nad) nad=yes ;;
4649
--ts) ts=yes ;;
@@ -89,7 +92,7 @@ dump_issues()
8992
count=$(echo "${issues[$st]}" | wc -w)
9093
echo "Processing $count $st issues ..." >&2
9194
test $count -ne 0 || continue
92-
printf '<h2 id="%s">%s Issues</h2>\n' "${anchors[$st]}" "$st"
95+
printf '<h2 id="%s">%s Issues</h2>\n\n' "${anchors[$st]}" "$st"
9396
if [ "$intros" = "yes" ]
9497
then
9598
echo "* Enter HTML text, followed by EOF (Ctrl-D on UNIX):" >&2
@@ -122,6 +125,33 @@ dump_issues()
122125
done
123126
}
124127

128+
dump_toc()
129+
{
130+
# for each status
131+
st="$1"
132+
133+
count=$(echo "${issues[$st]}" | wc -w)
134+
echo "Summarizing $count $st issues ..." >&2
135+
test $count -ne 0 || return
136+
echo "${issues[$st]}" | while read i
137+
do
138+
if [[ $ts = no ]]
139+
then
140+
match=$(grep -o '^<title>\[[^]]\+\.ts\.[^]]\+]' "xml/issue$i.xml")
141+
if [[ $match ]]
142+
then
143+
continue
144+
fi
145+
fi
146+
printf '<li><a href="#%d">%d</a>.\n' $i $i
147+
# Extracting just the <title> from the HTML is tricky, due to some
148+
# multiline titles like issue2642.html so extract from the XML instead.
149+
xpath -q -e '/issue/title/node()' xml/issue$i.xml \
150+
| sed -E -e 's;`([^`]+)`;<code>\1</code>;g' # replace backticks
151+
printf '\n</li>\n'
152+
done
153+
}
154+
125155
cat <<EOT
126156
<!DOCTYPE HTML>
127157
<html lang="en">
@@ -171,7 +201,14 @@ EOT
171201
for st in "${statuses[@]}"
172202
do
173203
[ -n "${issues[$st]}" ] || continue
174-
printf '<li><a href="#%s">%s Issues</a></li>\n' "${anchors[$st]}" "$st"
204+
printf '<li><a href="#%s">%s Issues</a>' "${anchors[$st]}" "$st"
205+
if [[ $toc = yes ]]
206+
then
207+
printf '\n<ul>\n'
208+
dump_toc "$st"
209+
printf '</ul>\n'
210+
fi
211+
printf '</li>\n'
175212
done
176213
echo '</ul>'
177214

0 commit comments

Comments
 (0)