#!/bin/bash
# Copyright (C) 2004 by Nathan (Acorn) Pooley
#
# do_doc
#
#@DOC@ script for creating documentation files in html format
#
ddir="ju_gadget_docs"
docstr='@DO'"C@"
do_code=1
if [[ $1 = '-nosource' ]] ; then
do_code=0
fi
_abort() {
if [[ -n $1 ]] ; then
echo "$*"
fi
echo "Aborting"
exit 1
}
_verb() {
echo "do_doc: $*"
}
if [[ ! -d $ddir ]] ; then
mkdir $ddir
fi
if [[ ! -d $ddir ]] ; then
_abort "Could not create directory '$ddir'"
fi
if [[ ! -a Docs ]] ; then
ln -s $ddir Docs
fi
if (( do_code )) ; then
_verb "deleting old documents"
for i in $ddir/*
do
echo "<html><body><h1>DELETED</h1></body></html>" > $i
done
fi
_verb "making documents in '$ddir'"
_docname() {
echo -n "$1" | \
sed -e 's|\.|_|g' \
-e 's|\.htm$||' \
-e 's|\.html$||' \
-e 's|$|.html|'
}
_html_begin() {
typeset title=""
typeset title2=""
if [[ -n $1 ]] ; then
title="JU DRUID Development Docs: $*"
title2="<a href=\"druid.html\">DRUID Development Docs:</a> $*"
else
title="JU DRUID Development Documentation"
title2="$title"
title2="<a href=\"index.html\">$title:</a>"
fi
echo "<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">"
echo "<html>"
echo "<head>"
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">"
echo "<meta name=\"Author\" content=\"tohtml by Acorn\">"
echo "<title>$title</title>"
echo "</head>"
echo "<body text=\"#330000\" bgcolor=\"#FFCC00\" link=\"#CC0000\" vlink=\"#660066\" alink=\"#660066\">"
echo "<h1>$title2</h1>"
}
_html_end() {
echo "<center>"
echo "<hr WIDTH=\"100%\"></center>"
echo "<p>"
echo "This file Copyright (C) 2004 by Nathan (Acorn) Pooley<br>"
echo "<a href="druid_devel.html">Go to DRUID Development page</a><br>"
echo "<a href="druid.html">Go to DRUID page</a><br>"
echo "<a href="index.html">Go to JU Gadgets page</a><br>"
echo "<a href="http://www.fobik.org/JU">Go to Justice Unlimited homepage</a><br>"
echo "<a href="http://www.rawbw.com/~acorn">Go to Acorn's personal webpage</a><br>"
echo "File created by do_doc at `date`"
echo "</p>"
echo "</body>"
echo "</html>"
}
_html_code_begin() {
typeset title="$1"
typeset color="$2"
if [[ -z $color ]] ; then
color='#FFCCFF'
fi
echo "<table CELLSPACING=5 CELLPADDING=0 WIDTH=\"100%\">"
if [[ -n $title ]] ; then
echo "<caption>"
echo "<h1>$title</h1>"
echo "</caption>"
fi
echo "<tr>"
echo "<td BGCOLOR=\"$color\">"
echo "<PRE>"
}
_html_code_end() {
echo "</PRE>"
echo "</td></tr></table>"
}
_filter_inc() {
typeset dn=`_docname "$1"`
_html_begin "$1"
_html_code_begin "Gadget Sourcecode: $1" "#FFCCFF"
sed -f source.seds \
-e "s|<a href=\"$dn\">\([^<]*\)</a>|\1|g"
_html_code_end
_html_end
}
_filter_asm() {
typeset dn=`_docname "$1"`
_html_begin "$1"
_html_code_begin "Gadget Sourcecode: $1" "#FFCCFF"
sed -f source.seds \
-e "s|<a href=\"$dn\">\([^<]*\)</a>|\1|g"
_html_code_end
_html_end
}
_filter_c() {
typeset dn=`_docname "$1"`
_html_begin "$1"
_html_code_begin "Gadget Sourcecode: $1" "#COCOCO"
sed -f source.seds \
-e "s|<a href=\"$dn\">\([^<]*\)</a>|\1|g"
_html_code_end
_html_end
}
_filter_txt() {
typeset dn=`_docname "$1"`
_html_begin "$1"
_html_code_begin "File: $1" "#33CCFF"
cat
_html_code_end
_html_end
}
# sed -f source.seds \
# -e "s|<a href=\"$dn\">\([^<]*\)</a>|\1|g"
_filter_str() {
typeset dn=`_docname "$1"`
_html_begin "$1"
_html_code_begin "File: $1" "#66FF99"
sed -f source.seds \
-e "s|<a href=\"$dn\">\([^<]*\)</a>|\1|g"
_html_code_end
_html_end
}
_filter_script() {
typeset dn=`_docname "$1"`
_html_begin "$1"
_html_code_begin "File: $1" "#C0C0C0"
sed -f source.seds \
-e "s|<a href=\"$dn\">\([^<]*\)</a>|\1|g"
_html_code_end
_html_end
}
#_filter_secret() {
# typeset dn=`_docname "$1"`
# _html_begin "$1"
# _html_code_begin "File: $1" "#FFFFFF"
# echo "<h2>This file is confidential</h2>"
# _html_code_end
# _html_end
#}
#
# build sed script
#
if (( do_code )) ; then
\rm -f source.seds
echo 's|<|\<|g' >> source.seds
echo 's|>|\>|g' >> source.seds
echo 's|\<\([a-zA-Z0-9_]\+\)\.inc\>|<a href="\1_inc.html">&</a>|g' >> source.seds
echo 's|\<\([a-zA-Z0-9_]\+\)\.asm\>|<a href="\1_asm.html">&</a>|g' >> source.seds
echo 's|\<\([a-zA-Z0-9_]\+\)\.txt\>|<a href="\1_txt.html">&</a>|g' >> source.seds
echo 's|\<\([a-zA-Z0-9_]\+\)\.str\>|<a href="\1_str.html">&</a>|g' >> source.seds
echo 's|\<\([a-zA-Z0-9_]\+\)\.stxt\>|<a href="\1_stxt.html">&</a>|g' >> source.seds
echo 's|\<\([a-zA-Z0-9_]\+\)\.sstr\>|<a href="\1_sstr.html">&</a>|g' >> source.seds
echo 's|\<\([a-zA-Z0-9_]\+\)\.c\>|<a href="\1_c.html">&</a>|g' >> source.seds
get_def='^[ ]*#*[ ]*define[ ]\+\([a-zA-Z_][a-zA-Z0-9_]*\)[ ].*'
get_sdf='^define[ ]\+\([a-zA-Z_][a-zA-Z0-9_]*\)[ ].*'
get_equ='^\([a-zA-Z_][a-zA-Z0-9_]*\)[ ]*[Ee][Qq][Uu].*'
get_lab='^\([a-zA-Z_][a-zA-Z0-9_]*\):.*'
get_str='^\(str_[a-zA-Z0-9_]\+\)[ ].*'
get_menu='^MENU[ ]\+\(mode_[a-zA-Z0-9_]\+\)[ ].*'
get_text='^TEXT[ ]\+\(mode_[a-zA-Z0-9_]\+\)[ ].*'
get_entry='^ENTRY[ ]\+\(mode_[a-zA-Z0-9_]\+\)[ ].*'
get_func='^FPTR[ ]\+\([a-zA-Z_][a-zA-Z0-9_]*\)[ ].*'
to_link1='s:\\<\1\\>:<a href="'
to_link2='doctarget_\1">\&</a>:g'
to_link1func='s:\\<func_\1\\>:<a href="'
_filter_tosed() {
typeset fn="$1"
typeset dfn=`_docname "$1"`
if [[ $fn != gstrings.inc && $fn != gfuncs.inc ]] ; then
sed -n \
-e "s|$get_def|$to_link1$dfn#d$to_link2|p" \
$fn >> source.seds
fi
sed -n \
-e "s|$get_equ|$to_link1$dfn#e$to_link2|p" \
$fn >> source.seds
sed -n \
-e "s|$get_lab|$to_link1$dfn#l$to_link2|p" \
$fn >> source.seds
}
_filter_tosed_str() {
typeset fn="$1"
typeset dfn=`_docname "$1"`
sed -n \
-e "s|$get_sdf|$to_link1$dfn#sd$to_link2|p" \
$fn >> source.seds
sed -n \
-e "s|$get_str|$to_link1$dfn#ss$to_link2|p" \
$fn >> source.seds
sed -n \
-e "s|$get_menu|$to_link1$dfn#sm$to_link2|p" \
$fn >> source.seds
sed -n \
-e "s|$get_text|$to_link1$dfn#st$to_link2|p" \
$fn >> source.seds
sed -n \
-e "s|$get_entry|$to_link1$dfn#se$to_link2|p" \
$fn >> source.seds
sed -n \
-e "s|$get_func|$to_link1func$dfn#l$to_link2|p" \
$fn >> source.seds
}
echo "s|$get_def|<a name=\"ddoctarget_\\1\"></a>&|" >> source.seds
echo "s|$get_equ|<a name=\"edoctarget_\\1\"></a>&|" >> source.seds
echo "s|$get_lab|<a name=\"ldoctarget_\\1\"></a>&|" >> source.seds
echo "s|$get_sdf|<a name=\"sddoctarget_\\1\"></a>&|" >> source.seds
echo "s|$get_str|<a name=\"ssdoctarget_\\1\"></a>&|" >> source.seds
echo "s|$get_menu|<a name=\"smdoctarget_\\1\"></a>&|" >> source.seds
echo "s|$get_text|<a name=\"stdoctarget_\\1\"></a>&|" >> source.seds
echo "s|$get_entry|<a name=\"sedoctarget_\\1\"></a>&|" >> source.seds
for i in *.asm
do
_verb "Checking for symbols in '$i'"
_filter_tosed $i
done
for i in *.inc
do
if [[ $i != gstrings.inc ]] ; then
_verb "Checking for symbols in '$i'"
_filter_tosed $i
fi
done
for i in *.str *.sstr
do
_verb "Checking for symbols in '$i'"
_filter_tosed_str $i
done
#
# turn off links to self (3x in case there are nested instances)
# 1 1 2 2 3 3 4 4
dbl_link='^\(<a name="\)\([lde]doctarget_[^"]\+\)\("></a>.*\)<a href="[^"]*#\2">\([^<]*\)</a>'
to_unlink='\1\2\3\4'
echo "s|$dbl_link|$to_unlink|g" >> source.seds
echo "s|$dbl_link|$to_unlink|g" >> source.seds
echo "s|$dbl_link|$to_unlink|g" >> source.seds
opcodes="addwf addwfc andwf clrf comf cpfseq cpfsgt cpfslt decf decfsz dcfsnz incf"
opcodes="$opcodes incfsz infsnz iorwf movf movff movwf mulwf negf rlcf rlncf rrcf rrncf setf"
opcodes="$opcodes subfwb subwf subwfb swapf tstfsz xorwf bcf bsf btfsc btfss btg bc bn bnc"
opcodes="$opcodes bnn bnov bnz bov bra bz call clrwdt daw goto nop pop push rcall reset retfie"
opcodes="$opcodes retlw return sleep addlw andlw iorlw lfsr movlb movlw mullw retlw sublw xorlw"
opcodes="$opcodes tblrd tblwt"
opcodes="$opcodes equ org radix end __config include define if else endif ifdef ifndef"
opcodes="$opcodes ADDWF ADDWFC ANDWF CLRF COMF CPFSEQ CPFSGT CPFSLT DECF DECFSZ DCFSNZ INCF"
opcodes="$opcodes INCFSZ INFSNZ IORWF MOVF MOVFF MOVWF MULWF NEGF RLCF RLNCF RRCF RRNCF SETF"
opcodes="$opcodes SUBFWB SUBWF SUBWFB SWAPF TSTFSZ XORWF BCF BSF BTFSC BTFSS BTG BC BN BNC"
opcodes="$opcodes BNN BNOV BNZ BOV BRA BZ CALL CLRWDT DAW GOTO NOP POP PUSH RCALL RESET RETFIE"
opcodes="$opcodes RETLW RETURN SLEEP ADDLW ANDLW IORLW LFSR MOVLB MOVLW MULLW RETLW SUBLW XORLW"
opcodes="$opcodes TBLRD TBLWT"
opcodes="$opcodes EQU ORG RADIX END __CONFIG"
for i in $opcodes
do
echo "s|^\\([ a-zA-Z0-9_:]*\\)\\(\\<$i\\>\\)|\1<B>\2</B>|g" >> source.seds
done
#
# convert files to html
#
for i in *.asm
do
_verb "Converting '$i'"
cat "$i" | detab -t4 | _filter_asm $i > $ddir/`_docname $i`
done
for i in *.inc
do
_verb "Converting '$i'"
cat "$i" | detab -t4 | _filter_inc $i > $ddir/`_docname $i`
done
for i in *.c
do
_verb "Converting '$i'"
cat "$i" | detab -t4 | _filter_c $i > $ddir/`_docname $i`
done
for i in *.txt
do
_verb "Converting '$i'"
cat "$i" | detab -t4 | _filter_txt $i > $ddir/`_docname $i`
done
for i in *.str *.sstr
do
_verb "Converting '$i'"
cat "$i" | detab -t4 | _filter_str $i > $ddir/`_docname $i`
done
#for i in *.sstr
#do
# _verb "Converting '$i' (secret)"
# echo "xxx" | _filter_secret $i > $ddir/`_docname $i`
#done
for i in do_* Makef* gg
do
_verb "Converting '$i'"
cat "$i" | detab -t4 | _filter_script $i > $ddir/`_docname $i`
done
fi
#
# create index file
#
_add_file() {
typeset pfx="$1"
typeset fn="$2"
typeset title="$3"
if [[ -z $title ]] ; then
title=`grep "$docstr" "$fn" | sed "s|.*$docstr||"`
fi
if [[ -z $title ]] ; then
title="$fn"
else
title="$fn : $title"
fi
typeset dfn=`_docname "$fn"`
echo "<li><a href=\"$pfx$dfn\">$title</a><br></li>"
}
_add_file_check() {
typeset sofar="$1"
typeset pfx="$2"
typeset fn="$3"
typeset title="$4"
typeset already=0
typeset dfn=`_docname "$fn"`
grep "href=\"$pfx$dfn" "$sofar" > /dev/null && already=1
if (( ! already )) ; then
_add_file "$2" "$3" "$4"
fi
}
_add_link() {
typeset targ="$1"
typeset title="$2"
if [[ -z $title ]] ; then
title="$targ"
fi
echo "<li><a href=\"$targ\">$title</a><br></li>"
}
_add_image() {
typeset targ="$1"
typeset title="$2"
if [[ -z $title ]] ; then
title="$targ"
fi
echo "<p><table>"
echo "<tr><td align=CENTER>$title</td></tr>"
echo "<tr><td align=CENTER><img src=\"$targ\"></td></tr>"
echo "</table><br></p>"
}
_make_pics() {
idx="$1"
pfx="$2"
_html_begin
#
# GADGET PICS
#
echo "<h2>Pictures of gadget</h2>"
_add_image "gadgetv3.jpg" "Version 3 of gadget with ZIF socket"
_add_image "gadget_vac1a.jpg" "First completed vacuum molded case (vacform attempt 2) (front)"
_add_image "gadget_vac2a.jpg" "First completed vacuum molded case (vacform attempt 2) (end)"
_add_image "gadget_vac3a.jpg" "First completed vacuum molded case (vacform attempt 2) (closeup)"
#
# VACUUM FORMING PICS
#
echo "<h2>Pictures of vacuum forming</h2>"
_add_image "vacform1.jpg" "First attempt at vacuum forming"
_add_image "vacform2.jpg" "Second attempt at vacuum forming"
_add_image "vacform2_back.jpg" "Back of second attempt"
_add_image "vacform_table.jpg" "Vacuum forming table built by Jeff and Acorn"
_add_image "vacform_table3.jpg" "Second attempt still on table"
_add_image "vacform_table2.jpg" "Top view of second attempt on table"
_html_end
}
_make_index() {
idx="$1"
pfx="$2"
_html_begin
doc_files=""
#
# PRIMARY TEXT FILES
#
echo "<h2>Gadget Goals and Design</h2>"
echo "<ul>"
for i in goals.txt todo.txt
do
_add_file_check "$idx" "$pfx" "$i"
done
_add_link "pictures.html" "Pictures"
echo "</ul>"
#
# CONTACT INFO
#
echo "<h2>contact info</h2>"
echo "<p>"
echo "Please send ANY ideas, comments, suggestions, questions, etc to Acorn."
echo "The more ideas we get, the better the gadget will be!!"
echo "Contact Acorn at:"
echo "<ul>"
echo "<li><a href=\"http://www.rawbw.com/~acorn/contact_me.html\">http://www.rawbw.com/~acorn/contact_me.html</a></li>"
echo "<li>408-739-2269</li>"
echo "</ul>"
echo "</p>"
#
# STRINGS FILES
#
echo "<h2>Files Defining all Menus, Screens, and Strings</h2>"
echo "<ul>"
for i in *.str *.sstr
do
_add_file "$pfx" "$i"
done
echo "</ul>"
#
# SOURCE
#
echo "<h2>Sourcecode for the Gadget</h2>"
echo "<ul>"
for i in *.asm
do
_add_file "$pfx" "$i"
done
for i in *.inc
do
_add_file "$pfx" "$i"
done
echo "</ul>"
#
# OTHER SOURCE
#
echo "<h2>Other files used to create the gadget</h2>"
echo "<ul>"
_add_file "$pfx" "Makefile"
_add_file "$pfx" "ju_convert.c" "Program for converting gadget_strings.str into sourcecode"
for i in Makef* do_* *.c gg
do
_add_file_check "$idx" "$pfx" "$i"
done
echo "</ul>"
#
# TEXT FILES
#
echo "<h2>Other Text Files</h2>"
echo "<ul>"
for i in *.txt
do
_add_file_check "$idx" "$pfx" "$i"
done
echo "</ul>"
#
# TAR
#
echo "<h2>Get Sourcecode</h2>"
echo "<p>"
echo "Download all files needed to build the gadget (except for confidential files)"
echo "<ul>"
echo "<li><a href="ju_gadget.tgz">ju_gadget.tgz</a></li>"
echo "</ul>"
echo "</p>"
#
# PARTS LINKS
#
echo "<h2>Parts Links</h2>"
echo "<ul>"
_add_link "http://ww1.microchip.com/downloads/en/DeviceDoc/39564b.pdf" \
"Pic 18F252 microcontroller datasheet"
_add_link "http://embrace.grayhill.com/embrace/IMAGES/PDF/I-19-20.pdf" \
"Encoder datasheet"
echo "<li>LCD Display<ul>"
_add_link "http://www.hantronix.com/down/ks0066u.pdf" \
"LCD Controller chip description"
_add_link "http://www.ampire.com/AmpireCatalogue/P090-AC164A.pdf" \
"LCD Module pinout and dimensions"
echo "</ul></li>"
_add_link "http://rocky.digikey.com/WebLib/Panasonic/Web%20data/AN80xx,AN80xxM%20Series.pdf" \
"Voltage regulator 'AN8005'"
_add_link "http://rocky.digikey.com/WebLib/Fairchild/Web%20Data/2N3906_MMBT3906_PZT3906.pdf" \
"2N 3906 - general purpose PNP transistor"
echo "</ul>"
#
# PARTS COMPANY LINKS
#
echo "<h2>Parts Company Links</h2>"
echo "<ul>"
_add_link "http://www.digikey.com" \
"Digikey - mail order parts store"
echo "</ul>"
_html_end
}
_verb "Creating druid_devel.html"
_make_index "$ddir/druid_devel.html" "" > "$ddir/druid_devel.html"
_verb "Creating docs.html"
_make_index "docs.html" "$ddir/" > "docs.html"
_verb "Creating pictures.html"
_make_pics "$ddir/pictures.html" "" > "$ddir/pictures.html"
#
# empty confidential files
#
#for i in *.sstr gstrings.inc
#do
# _verb "Hiding '$i' (secret)"
# echo "xxx" | _filter_secret $i > $ddir/`_docname $i`
#done
#
# build tar of all non-secret files
#
if [[ -L ju_gadget2 ]] ; then
\rm ju_gadget2
fi
if [[ -a ju_gadget ]] ; then
echo "there is already a file called 'ju_gadget'"
echo "Cannot create tar file"
else
mkdir ju_gadget
( cd ju_gadget ; ln -s .. sw )
\rm -f file_list
for i in ju_gadget/sw/*.txt \
ju_gadget/sw/*.asm \
ju_gadget/sw/*.inc \
ju_gadget/sw/*.str \
ju_gadget/sw/Makef* \
ju_gadget/sw/do_* \
ju_gadget/sw/gg \
ju_gadget/sw/*.c \
ju_gadget/sw/*.Fsti \
ju_gadget/sw/*.Psti \
ju_gadget/sw/*.mcp \
ju_gadget/sw/*.mcw
do
if [[ -a $i && $i != gstrings.inc ]] ; then
echo "$i" >> file_list
fi
done
tar cz -f $ddir/ju_gadget.tgz --files-from=file_list
\rm ju_gadget/sw
rmdir ju_gadget
fi
|
This file Copyright (C) 2004 by Nathan (Acorn) Pooley
Go to DRUID Development page
Go to DRUID page
Go to JU Gadgets page
Go to Justice Unlimited homepage
Go to Acorn's personal webpage
Contact Acorn
See comments from others
Post your own comments
File created by do_doc at Wed Aug 4 18:14:42 2004