diff --git a/Makefile b/Makefile index a58f7a4..667b002 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ DOC := ./scripts/cls2tex.sh # NOTE: .sty and .cls are essentially the same in terms of documentation # generation... -# XXX should these depend on $(DOC) ??? +# XXX should these depend on the $(DOC) script ??? %.tex: %.sty %-meta.tex $(DOC) $< $@ diff --git a/scripts/cls2tex.sh b/scripts/cls2tex.sh index 3bcd9ce..fae8024 100755 --- a/scripts/cls2tex.sh +++ b/scripts/cls2tex.sh @@ -1,18 +1,8 @@ #!/usr/bin/env bash +#---------------------------------------------------------------------- SCRIPT_NAME=$(basename $0) -printusage(){ - echo "Usage:" - echo " $SCRIPT_NAME [OPTIONS] INPUT OUTPUT" -} - -printerror(){ - echo Error: $@ - echo - printusage -} - printhelp(){ echo "Generate docs from latex package/class" echo @@ -48,11 +38,24 @@ printhelp(){ echo " in both the repo and in installed form, so .dtx is not used." } +printusage(){ + echo "Usage:" + echo " $SCRIPT_NAME [OPTIONS] INPUT OUTPUT" +} + +printerror(){ + echo Error: $@ + echo + printusage +} + + + +#---------------------------------------------------------------------- +# Args and defaults... -# defaults... PREFIX=% -# args... while true ; do case $1 in -h|--help) @@ -91,7 +94,10 @@ fi MODULE=$(basename "$INPUT") MODULE=${MODULE/.*/} + +#---------------------------------------------------------------------- # do the work... + cat "$INPUT" \ | egrep '(^%'$PREFIX'|^\\edef\\'$MODULE'@[A-Z][A-Z]+)' \ | sed 's/^\(\\edef\\\)'$MODULE'@/%'$PREFIX'\1/' \ @@ -103,4 +109,5 @@ cat "$INPUT" \ > "$OUTPUT" -# vim:set ts=4 sw=4 nowrap : +#---------------------------------------------------------------------- +# vim:set ts=4 sw=4 nowrap :