readme refactor

This commit is contained in:
ed
2022-10-24 18:48:12 +02:00
parent 4b2b4ed52d
commit 75e5e53276
5 changed files with 230 additions and 167 deletions

View File

@@ -231,11 +231,11 @@ def hashfile(fn):
def unpack():
"""unpacks the tar yielded by `data`"""
name = "pe-copyparty."
name = "pe-copyparty"
try:
name += str(os.geteuid())
name += "." + str(os.geteuid())
except:
name += "0"
pass
tag = "v" + str(STAMP)
top = tempfile.gettempdir()

44
scripts/toc.sh Executable file
View File

@@ -0,0 +1,44 @@
#!/bin/bash
set -e
for f in README.md docs/devnotes.md; do
cat $f | awk '
function pr() {
if (!h) {return};
if (/^ *[*!#|]/||!s) {
printf "%s\n",h;
h=0;
return
};
if (/.../) {
printf "%s - %s\n",h,$0;
h=0
};
};
/^#/{s=1;pr()} /^#* *(install on android|dev env setup|just the sfx|complete release|optional gpl stuff)|`$/{s=0}
/^#/{
lv=length($1);
sub(/[^ ]+ /,"");
bab=$0;
gsub(/ /,"-",bab);
gsub(/\./,"",bab);
h=sprintf("%" ((lv-1)*4+1) "s [%s](#%s)", "*",$0,bab);
next
}
!h{next}
{sub(/ .*/,"");sub(/[:;,]$/,"")}
{pr()}
' > toc
grep -E '^#+ [^ ]+ toc$' -B1000 -A2 <$f >p1
h2="$(awk '/^#+ [^ ]+ toc$/{o=1;next} o&&/^#/{print;exit}' <$f)"
grep -F "$h2" -B2 -A999999 <$f >p2
(cat p1; grep -F "${h2#* }" -A1000 <toc; cat p2) >$f
rm p1 p2 toc
done