diff --git a/Makefile b/Makefile index b3e3353..a58f7a4 100644 --- a/Makefile +++ b/Makefile @@ -51,10 +51,10 @@ DOC := ./scripts/cls2tex.sh # NOTE: this is a bit ugly, but allot less so than trying to push \verb # into a LaTeX macro/env and then getting it out again in one pice... %-meta.tex: %.sty - $(DOC) $< $@ M + $(DOC) -p M $< $@ %-meta.tex: %.cls - $(DOC) $< $@ M + $(DOC) -p M $< $@ diff --git a/photobook.cls b/photobook.cls index b253796..e8bf0c0 100644 --- a/photobook.cls +++ b/photobook.cls @@ -151,9 +151,9 @@ %% be aligned relative to a page, it can fill a page, a cell can even be %% horizontally split to fill several pages (how spreads are implemented). %% -%% On top of the |cell|, page and spread concepts |photobook| also builds -%% a set of configurable high level macros/templates for common use cases -%% like full bleed image spreads, etc. +%% On top of the |cell|, page, and spread concepts, |photobook| also builds +%% a set of configurable high level macros and templates for common use +%% cases like full bleed image spreads, etc. % % %%%% Usage diff --git a/scripts/cls2tex.sh b/scripts/cls2tex.sh index 408354a..a085ba5 100755 --- a/scripts/cls2tex.sh +++ b/scripts/cls2tex.sh @@ -1,16 +1,36 @@ #!/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 - echo "Usage: $(basename $0) [-h|--help] INPUT OUTPUT [PREFIX]" + printusage + echo + echo "Options:" + echo " -h | --help Show this message and exit" + echo " -p | --prefix PREFIX" + echo " Set the doc comment PREFIX (default: \"%\")" echo echo "This will:" + echo " - read the INPUT" echo " - keep lines starting with \\def\\@[A-Z]\\+" echo " - keep lines starting with '%%'" echo " - %%%%% Text -> \\subsection(Text)" echo " - %%%% Text -> \\section(Text)" echo " - %% >> code -> \\begin{verbatim}code\\end{verbatim}" + echo " - write the result to OUTPUT" echo echo "PREFIX can replace the second \"%\" in the above patterns to make it" echo "possible to integrate multiple layers of documentation in one file" @@ -28,13 +48,29 @@ printhelp(){ echo " in both the repo and in installed form, so .dtx is not used." } -# args/defaults... + +# defaults... +PREFIX=% + +# args... while true ; do case $1 in -h|--help) printhelp exit ;; + -p|--prefix) + shift + PREFIX=$1 + shift + continue + ;; + + # handle unknown options... + -*|--*) + printerror "unknown option \"$1\"" + exit + ;; *) break @@ -46,11 +82,12 @@ INPUT=$1 OUTPUT=$2 -PREFIX=$3 -if [ -z $PREFIX ] ; then - PREFIX=% +if [ -z $INPUT ] || [ -z $OUTPUT ] ; then + printerror "need both INPUT and OUTPUT present." + exit fi + # generate the module name... MODULE=$(basename "$INPUT") MODULE=${MODULE/.*/}