mirror of
https://github.com/flynx/photobook.git
synced 2025-11-01 03:40:10 +00:00
added support for stripping docs out of code...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
d150751cac
commit
709d3222fd
@ -17,6 +17,7 @@ printhelp(){
|
|||||||
echo " -h | --help Show this message and exit"
|
echo " -h | --help Show this message and exit"
|
||||||
echo " -p | --prefix PREFIX"
|
echo " -p | --prefix PREFIX"
|
||||||
echo " Set the doc comment PREFIX (default: \"%\")"
|
echo " Set the doc comment PREFIX (default: \"%\")"
|
||||||
|
echo " -s | --strip Strip docs out"
|
||||||
echo
|
echo
|
||||||
echo "This will:"
|
echo "This will:"
|
||||||
echo " - read the INPUT"
|
echo " - read the INPUT"
|
||||||
@ -39,6 +40,10 @@ printhelp(){
|
|||||||
echo "a unified location in docs, effectively decoupling the source and doc"
|
echo "a unified location in docs, effectively decoupling the source and doc"
|
||||||
echo "structure when needed."
|
echo "structure when needed."
|
||||||
echo
|
echo
|
||||||
|
echo "Strip mode is the reverse of of the default, it will strip out docs"
|
||||||
|
echo "and empty lines."
|
||||||
|
echo
|
||||||
|
echo "NOTE: stripping will not remove non-doc comments."
|
||||||
echo "NOTE: the idea of keeping latex docs in a latex file is far simpler"
|
echo "NOTE: the idea of keeping latex docs in a latex file is far simpler"
|
||||||
echo " than all the stuff crammed into .dtx, at least for my needs:"
|
echo " than all the stuff crammed into .dtx, at least for my needs:"
|
||||||
echo " - keep the code readable"
|
echo " - keep the code readable"
|
||||||
@ -70,6 +75,10 @@ while true ; do
|
|||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-s|--strip)
|
||||||
|
STRIP_DOC=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
# handle unknown options...
|
# handle unknown options...
|
||||||
-*|--*)
|
-*|--*)
|
||||||
@ -97,6 +106,8 @@ MODULE=${MODULE/.*/}
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
# do the work...
|
# do the work...
|
||||||
|
|
||||||
|
# make docs...
|
||||||
|
if [ -z $STRIP_DOC ] ; then
|
||||||
cat "$INPUT" \
|
cat "$INPUT" \
|
||||||
| egrep '(^%'$PREFIX'|^\\edef\\'$MODULE'@[A-Z][A-Z]+)' \
|
| egrep '(^%'$PREFIX'|^\\edef\\'$MODULE'@[A-Z][A-Z]+)' \
|
||||||
| sed 's/^\(\\edef\\\)'$MODULE'@/%'$PREFIX'\1/' \
|
| sed 's/^\(\\edef\\\)'$MODULE'@/%'$PREFIX'\1/' \
|
||||||
@ -107,6 +118,14 @@ cat "$INPUT" \
|
|||||||
| cut -c 3- - \
|
| cut -c 3- - \
|
||||||
> "$OUTPUT"
|
> "$OUTPUT"
|
||||||
|
|
||||||
|
# make stripped code...
|
||||||
|
else
|
||||||
|
cat "$INPUT" \
|
||||||
|
| egrep -v '%'$PREFIX'' \
|
||||||
|
| egrep -v '^(\s*%)?\s*$' \
|
||||||
|
> "$OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user