Merge pull request #254 from revarbat/revarbat_dev

Index and Cheat Sheet generation script improvements.
This commit is contained in:
Revar Desmera
2020-08-31 18:56:13 -07:00
committed by GitHub
3 changed files with 41 additions and 14 deletions

View File

@@ -26,7 +26,7 @@ function columnize
hdrln1="| $(ucase $1) " hdrln1="| $(ucase $1) "
hdrln2='|:-----' hdrln2='|:-----'
n=1 n=1
while [[ $n < $maxcols ]] ; do while [[ $n -lt $maxcols ]] ; do
hdrln1+=' | &nbsp;' hdrln1+=' | &nbsp;'
hdrln2+=' |:------' hdrln2+=' |:------'
n=$(($n+1)) n=$(($n+1))
@@ -34,7 +34,7 @@ function columnize
hdrln1+=' |' hdrln1+=' |'
hdrln2+=' |' hdrln2+=' |'
n=0 n=0
while [[ $n < $maxrows ]] ; do while [[ $n -lt $maxrows ]] ; do
lines[$n]="" lines[$n]=""
n=$(($n+1)) n=$(($n+1))
done done
@@ -56,7 +56,7 @@ function columnize
echo $hdrln1 echo $hdrln1
echo $hdrln2 echo $hdrln2
n=0 n=0
while [[ $n < $maxrows ]] ; do while [[ $n -lt $maxrows ]] ; do
echo "| ${lines[$n]} |" echo "| ${lines[$n]} |"
n=$(($n+1)) n=$(($n+1))
done done
@@ -67,6 +67,11 @@ function mkconstindex
sed 's/([^)]*)//g' | sed 's/[^a-zA-Z0-9_.:$]//g' | awk -F ':' '{printf "[%s](%s#%s)\n", $3, $1, $3}' sed 's/([^)]*)//g' | sed 's/[^a-zA-Z0-9_.:$]//g' | awk -F ':' '{printf "[%s](%s#%s)\n", $3, $1, $3}'
} }
function mkconstindex2
{
sed 's/ *=.*$//' | sed 's/[^a-zA-Z0-9_.:$]//g' | awk -F ':' '{printf "[%s](%s#%s)\n", $2, $1, $2}'
}
function mkotherindex function mkotherindex
{ {
sed 's/([^)]*)//g' | sed 's/[^a-zA-Z0-9_.:$]//g' | awk -F ':' '{printf "[%s()](%s#%s)\n", $3, $1, $3}' sed 's/([^)]*)//g' | sed 's/[^a-zA-Z0-9_.:$]//g' | awk -F ':' '{printf "[%s()](%s#%s)\n", $3, $1, $3}'
@@ -80,9 +85,11 @@ CHEAT_FILES=$(grep '^include' std.scad | sed 's/^.*<\([a-zA-Z0-9.]*\)>/\1/'|grep
echo '( [Alphabetic Index](Index) )' echo '( [Alphabetic Index](Index) )'
echo echo
for f in $CHEAT_FILES ; do for f in $CHEAT_FILES ; do
#echo "### $f"
( (
egrep -H 'Constant: ' $f | mkconstindex (
grep -H 'Constant: ' $f | mkconstindex
grep -H '^[A-Z$][A-Z0-9_]* *=.*//' $f | mkconstindex2
) | sort -u
egrep -H 'Function: |Function&Module: |Module: ' $f | mkotherindex egrep -H 'Function: |Function&Module: |Module: ' $f | mkotherindex
) | columnize $f ) | columnize $f
echo echo

View File

@@ -6,16 +6,18 @@ function ucase
echo "$1" | tr '[:lower:]' '[:upper:]' echo "$1" | tr '[:lower:]' '[:upper:]'
} }
function lcase function lcase
{ {
echo "$1" | tr '[:upper:]' '[:lower:]' echo "$1" | tr '[:upper:]' '[:lower:]'
} }
function mkindex
function alphaindex
{ {
TMPFILE=$(mktemp -t $(basename $0).XXXXXX) || exit 1
sed 's/([^)]*)//g' | sed 's/[^a-zA-Z0-9_.:$]//g' | awk -F ':' '{printf "- [%s](%s#%s)\n", $3, $1, $3}' | sort -d -f -u >> $TMPFILE
alpha="A B C D E F G H I J K L M N O P Q R S T U V W X Y Z" alpha="A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
TMPFILE=$(mktemp -t $(basename $0).XXXXXX) || exit 1
sort -d -f >> $TMPFILE
for a in $alpha; do for a in $alpha; do
echo -n "[$a](#$(lcase "$a")) " echo -n "[$a](#$(lcase "$a")) "
done done
@@ -33,13 +35,31 @@ function mkindex
} }
function constlist
{
sed 's/([^)]*)//g' | sed 's/[^a-zA-Z0-9_.:$]//g' | awk -F ':' '{printf "- [%s](%s#%s) (in %s)\n", $3, $1, $3, $1}'
}
function constlist2
{
sed 's/ *=.*$//' | sed 's/[^a-zA-Z0-9_.:$]//g' | awk -F ':' '{printf "- [%s](%s#%s) (in %s)\n", $2, $1, $2, $1}'
}
function funclist
{
sed 's/([^)]*)//g' | sed 's/[^a-zA-Z0-9_.:$]//g' | awk -F ':' '{printf "- [%s()](%s#%s) (in %s)\n", $3, $1, $3, $1}'
}
( (
echo "## Belfry OpenScad Library Index" echo "## Belfry OpenScad Library Index"
( (
grep 'Constant: ' *.scad (
grep 'Function: ' *.scad grep 'Constant: ' *.scad | constlist
grep 'Function&Module: ' *.scad grep '^[A-Z]* *=.*//' *.scad | constlist2
grep 'Module: ' *.scad ) | sort -u
) | mkindex egrep 'Function: |Function&Module: |Module: ' *.scad | sort -u | funclist
) | sort | alphaindex
) > BOSL2.wiki/Index.md ) > BOSL2.wiki/Index.md

View File

@@ -8,7 +8,7 @@
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
BOSL_VERSION = [2,0,415]; BOSL_VERSION = [2,0,417];
// Section: BOSL Library Version Functions // Section: BOSL Library Version Functions