mirror of
				https://github.com/flynx/photobook.git
				synced 2025-10-31 19:30:08 +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,15 +106,25 @@ MODULE=${MODULE/.*/} | |||||||
| #---------------------------------------------------------------------- | #---------------------------------------------------------------------- | ||||||
| # do the work... | # do the work... | ||||||
| 
 | 
 | ||||||
| cat "$INPUT" \ | # make docs... | ||||||
| 	| egrep '(^%'$PREFIX'|^\\edef\\'$MODULE'@[A-Z][A-Z]+)' \ | if [ -z $STRIP_DOC ] ; then | ||||||
| 	| sed 's/^\(\\edef\\\)'$MODULE'@/%'$PREFIX'\1/' \ | 	cat "$INPUT" \ | ||||||
| 	| sed 's/%'$PREFIX'%%%% \(.*\)/%'$PREFIX'\\subsubsection{\1}\\label{subsubsec:\1}/' \ | 		| egrep '(^%'$PREFIX'|^\\edef\\'$MODULE'@[A-Z][A-Z]+)' \ | ||||||
| 	| sed 's/%'$PREFIX'%%% \(.*\)/%'$PREFIX'\\subsection{\1}\\label{subsec:\1}/' \ | 		| sed 's/^\(\\edef\\\)'$MODULE'@/%'$PREFIX'\1/' \ | ||||||
| 	| sed 's/%'$PREFIX'%% \(.*\)/%'$PREFIX'\\section{\1}\\label{sec:\1}/' \ | 		| sed 's/%'$PREFIX'%%%% \(.*\)/%'$PREFIX'\\subsubsection{\1}\\label{subsubsec:\1}/' \ | ||||||
| 	| sed 's/%'$PREFIX'\s\+>>\s\+\(.*\)/%'$PREFIX'\\begin{verbatim} \1 \\end{verbatim}/' \ | 		| sed 's/%'$PREFIX'%%% \(.*\)/%'$PREFIX'\\subsection{\1}\\label{subsec:\1}/' \ | ||||||
| 	| cut -c 3- - \ | 		| sed 's/%'$PREFIX'%% \(.*\)/%'$PREFIX'\\section{\1}\\label{sec:\1}/' \ | ||||||
| 	> "$OUTPUT" | 		| sed 's/%'$PREFIX'\s\+>>\s\+\(.*\)/%'$PREFIX'\\begin{verbatim} \1 \\end{verbatim}/' \ | ||||||
|  | 		| cut -c 3- - \ | ||||||
|  | 		> "$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