Skip to content

Commit 11068af

Browse files
committed
fix(convert-formula.sh): fix reST underlining during conversion
Assuming the Python convention for section headings of: = for sections - for subsections ^ for subsubsections " for paragraphs as described at https://devguide.python.org/documenting/#sections
1 parent 84cb63f commit 11068af

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

bin/convert-formula.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,18 @@ sedi() {
2525
fi
2626
}
2727

28+
repeat_char() {
29+
printf %"${NEW_NAME_LENGTH}"s | tr " " "$1"
30+
}
31+
2832
args() {
2933
if [ $# -ne 1 ]; then
3034
usage
3135
exit 1
3236
fi
3337
NEW_NAME=$1
3438
NEW_NAME_PYSAFE=$(echo "$NEW_NAME" | sed 's/-/__/g')
39+
NEW_NAME_LENGTH=${#NEW_NAME}
3540
if echo "$NEW_NAME" | grep -E --quiet --invert-match '^[a-z0-9_-]+$'; then
3641
usage
3742
exit 1
@@ -78,6 +83,16 @@ convert_formula() {
7883
sedi "/^\( \)TEMPLATE\(:\)$/s//\1${NEW_NAME_PYSAFE}\2/" "$filename"
7984
done
8085

86+
# Where a section heading contains TEMPLATE, ensure the length of underlining
87+
# on the following line matches the length of the new formula name
88+
sedi "/TEMPLATE/{
89+
n
90+
s/========/$(repeat_char =)/
91+
s/--------/$(repeat_char -)/
92+
s/\^^^^^^^^/$(repeat_char ^)/"'
93+
s/""""""""/'"$(repeat_char \")/
94+
}" docs/README.rst docs/map.jinja.rst
95+
8196
# Replace all other instances of TEMPLATE with the regular new formula name
8297
grep --recursive --files-with-matches --exclude-dir=.git TEMPLATE . \
8398
| while read -r filename; do

0 commit comments

Comments
 (0)