forked from martinthomson/i-d-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-readme.sh
executable file
·80 lines (64 loc) · 2.15 KB
/
setup-readme.sh
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env bash
# Usage: $0 <user> <repo> [draftxml ...]
user="$1"
repo="$2"
shift 2
githubio="https://${user}.github.io/${repo}/#go"
function fixup_other_md() {
markdown=(LICENSE.md CONTRIBUTING.md)
s='s~{WG_NAME}~'"$1"'~g'
s="$s"';s~{GITHUB_USER}~'"$user"'~g'
s="$s"';s~{GITHUB_REPO}~'"$repo"'~g'
sed -i~ -e "$s" "${markdown[@]}"
for i in "${markdown[@]}"; do
rm -f "$i"~
done
}
first=true
for d in "$@"; do
fullname="${d%.xml}"
author=$(echo "${fullname}" | cut -f 2 -d - -)
wg=$(echo "${fullname}" | cut -f 3 -d - -)
wgupper=$(echo "${wg}" | tr 'a-z' 'A-Z')
title=$(sed -e '/<title[^>]*>/,/<\/title>/{s/.*<title[^>]*>//;/<\/title>/{s/<\/title>.*//;H;x;q;};H;};d' "$d" | tr '\r\n' ' ' | sed -e 's/^[ \t]*//;s/[ \t]*$//;s/[ \t][ \t]*/ /g')
if "$first"; then
fixup_other_md "$wg"
if [ "$author" = "ietf" ]; then
status="Working Group"
status_full="IETF [${wgupper} Working Group](https://datatracker.ietf.org/wg/${wg}/documents/) Internet-Draft"
else
status="Individual"
status_full="individual Internet-Draft"
fi
if [ $# -gt 1 ]; then
echo "# ${wgupper} Drafts"
status_full="${status_full}s"
else
echo "# $title"
status_full="the ${status_full}, \"${title}\""
fi
echo
echo "This is the working area for ${status_full}."
first=false
fi
if [ $# -gt 1 ]; then
echo
echo "## $title"
fi
echo
echo "* [Editor's Copy](${githubio}.${fullname}.html)"
echo "* [${status} Draft](https://tools.ietf.org/html/${fullname})"
echo "* [Compare Editor's Copy to ${status} Draft](${githubio}.${fullname}.diff)"
done
cat <<EOF
## Building the Draft
Formatted text and HTML versions of the draft can be built using \`make\`.
\`\`\`sh
$ make
\`\`\`
This requires that you have the necessary software installed. See
[the instructions](https://github.com/martinthomson/i-d-template/blob/master/doc/SETUP.md).
## Contributing
See the
[guidelines for contributions](https://github.com/${user}/${repo}/blob/master/CONTRIBUTING.md).
EOF