11#! /bin/bash
2- # Generic make.sh
3- # Usage: make.sh name [sphinx publish src]
4- #
5- # if publish: -DNOTREAD preprocess option is added so that all
6- # sections are included. Use #ifdef NOTREAD to mark sections
7- # that should not yet be published because they are not sufficiently
8- # proof read.
2+ # Generic make.sh for building PDF chapters
3+ # Usage: make.sh name
94
105set -x
116
@@ -21,20 +16,11 @@ function system {
2116 fi
2217}
2318
24-
2519if [ $# -eq 0 ]; then
26- print ' name of document missing!'
20+ echo ' name of document missing!'
2721 exit 1
2822fi
2923
30- function oliver_art {
31- if [ -f fig-${nickname} /oliver_sin.jpg ]; then
32- doconce subst " <h2>Table of contents</h2>" " <h2>Table of contents</h2>\n\n<a href=\" https://www.facebook.com/oliversinofficial\" ><img src=\" fig-$name /oliver_sin.jpg\" width=300 align=\" right\" ></a>" ${mainname} .html
33- cp fig-${nickname} /oliver_sin.jpg sphinx-rootdir/_build/html/_images
34- doconce subst ' <div class="toctree-wrapper compound">' ' <div class="toctree-wrapper compound">\n\n<a href="https://www.facebook.com/oliversinofficial"><img src="_images/oliver_sin.jpg" width=300 align="right"></a>\n' sphinx-rootdir/_build/html/index.html
35- fi
36- }
37-
3824rm -f tmp_*
3925
4026doconce spellcheck -d .dict4spell.txt * .do.txt
@@ -48,33 +34,18 @@ egrep "[^\\]thinspace" *.do.txt
4834if [ $? -eq 0 ]; then echo " wrong thinspace commands - abort" ; exit ; fi
4935
5036comments=" --skip_inline_comments"
51- # comments=""
5237doc=document
5338appendix=document
5439
55- preprocessor_opt=" DOCUMENT=$doc APPENDIX=$appendix BOOK=standalone FEM_BOOK=False"
40+ preprocessor_opt=" DOCUMENT=$doc APPENDIX=$appendix BOOK=standalone FEM_BOOK=False -DNOTREAD "
5641no_solutions=' --without_solutions --without_answers'
57- sphinx=0
58- publish=0
59-
60- if [ $# -ge 2 ]; then
61- sphinx=1
62- fi
63- if [ $# -ge 3 ]; then
64- publish=1
65- else
66- publish=0
67- # allow everything to be compiled...
68- preprocessor_opt=" ${preprocessor_opt} -DNOTREAD"
69- fi
7042
7143rm -f * .aux
7244preprocess -DFORMAT=pdflatex ../newcommands_keep.p.tex > newcommands_keep.tex
7345
7446function edit_solution_admons {
7547 # We use question admon for typesetting solution, but let's edit to
7648 # somewhat less eye catching than the std admon
77- # (also note we use --latex_admon_envir_map= in compile)
7849 doconce replace ' notice_mdfboxadmon}[Solution.]' ' question_mdfboxadmon}[Solution.]' ${mainname} .tex
7950 doconce replace ' end{notice_mdfboxadmon} % title: Solution.' ' end{question_mdfboxadmon} % title: Solution.' ${mainname} .tex
8051 doconce subst -s ' % "question" admon.+?question_mdfboxmdframed\}' ' % "question" admon
@@ -100,175 +71,38 @@ function edit_solution_admons {
10071
10172function compile {
10273 options=" $@ "
103- system doconce format pdflatex ${mainname} $preprocessor_opt $comments --latex_table_format=center " --latex_code_style=default:lst[style=blue1_bluegreen]@pypro:lst[style=blue1bar_bluegreen]@pypro2:lst[style=greenblue]@pycod2:lst[style=greenblue]@dat:lst[style=gray]@sys:vrb[frame=lines,label=\\ fbox{{\tiny Terminal}},framesep=2.5mm,framerule=0.7pt,fontsize=\fontsize{9pt}{9pt}]" --allow_refs_to_external_docs --exercise_solution=admon --movie_prefix=https://raw.githubusercontent.com/hplgit/fdm-book/master/doc/.src/chapters/${nickname} / --latex_admon_envir_map=2 --latex_list_of_exercises=toc $options
104- edit_solution_admons
105- system doconce latex_exercise_toc ${mainname}
106- doconce subst ' frametitlebackgroundcolor=.*?,' ' frametitlebackgroundcolor=blue!5,' ${mainname} .tex
107- system pdflatex ${mainname}
108- system makeindex ${mainname}
109- system bibtex ${mainname}
110- pdflatex ${mainname}
111- pdflatex ${mainname}
74+ system doconce format pdflatex ${mainname} $preprocessor_opt $comments \
75+ --latex_table_format=center \
76+ " --latex_code_style=default:lst[style=blue1_bluegreen]@pypro:lst[style=blue1bar_bluegreen]@pypro2:lst[style=greenblue]@pycod2:lst[style=greenblue]@dat:lst[style=gray]@sys:vrb[frame=lines,label=\\ fbox{{\tiny Terminal}},framesep=2.5mm,framerule=0.7pt,fontsize=\fontsize{9pt}{9pt}]" \
77+ --allow_refs_to_external_docs \
78+ --exercise_solution=admon \
79+ --movie_prefix=https://raw.githubusercontent.com/devitocodes/devito_book/master/doc/.src/chapters/${nickname} / \
80+ --latex_admon_envir_map=2 \
81+ --latex_list_of_exercises=toc \
82+ $options
83+ edit_solution_admons
84+ system doconce latex_exercise_toc ${mainname}
85+ doconce subst ' frametitlebackgroundcolor=.*?,' ' frametitlebackgroundcolor=blue!5,' ${mainname} .tex
86+ system pdflatex ${mainname}
87+ system makeindex ${mainname}
88+ system bibtex ${mainname}
89+ pdflatex ${mainname}
90+ pdflatex ${mainname}
11291}
11392
114- # PDF with solutions (start with this and let .aux be the most
115- # relevant version for xr references (the "book" version)
93+ # PDF with solutions
11694compile --device=screen
11795cp ${mainname} .pdf ${nickname} -sol.pdf
11896rm -f ${mainname} .pdf
11997
120- # See http://www2.warwick.ac.uk/fac/sci/statistics/staff/academic-research/firth/software/pdfjam for examples on pdfnup and pdfjam
121-
122- # PDF for printing, standard paper size
98+ # PDF for printing
12399compile --device=paper $no_solutions
124100cp ${mainname} .pdf ${nickname} -4print.pdf
125101
126- # 2 pages per sheet to save trees
127- # pdfnup --frame true --outfile ${nickname}-4print-2up.pdf ${nickname}-4print.pdf
128-
129- # PDF for electronic viewing
130- compile --device=paper $no_solutions
102+ # PDF for screen viewing
103+ compile --device=screen $no_solutions
131104cp ${mainname} .pdf ${nickname} -4screen.pdf
132105rm -f ${mainname} .pdf
133106
134- # HTML
135- system preprocess -DFORMAT=html ../newcommands_keep.p.tex > newcommands_keep.tex
136-
137- style=solarized
138- # Note that we use perldoc and not native solarized3 code
139- system doconce format html ${mainname} $preprocessor_opt $no_solutions --html_style=solarized3 --html_output=${nickname} -$style --pygments_html_style=perldoc $comments --allow_refs_to_external_docs
140- doconce replace ' P$d$' ' Pd' ${nickname} -${style} .html
141- system doconce split_html ${nickname} -${style} .html --nav_button=text
142-
143- # default nickname.html is bootswatch journal style
144- system doconce format html ${mainname} $preprocessor_opt $no_solutions $comments --html_style=bootswatch_journal --html_code_style=inherit --html_output=${nickname} --allow_refs_to_external_docs
145- doconce replace ' P$d$' ' Pd' ${nickname} .html
146- system doconce split_html ${nickname} .html
147-
148- # nickname-sol.html is bootswatch journal with solutions
149- system doconce format html ${mainname} $preprocessor_opt $comments --html_style=bootswatch_journal --html_code_style=inherit --html_output=${nickname} -sol --allow_refs_to_external_docs
150- doconce replace ' P$d$' ' Pd' ${nickname} -sol.html
151- system doconce split_html ${nickname} -sol.html
152-
153- if [ $sphinx -eq 1 ]; then
154- system doconce format sphinx ${mainname} $preprocessor_opt $no_solutions $comments --sphinx_keep_splits --allow_refs_to_external_docs
155- doconce replace ' P$d$' ' Pd' ${mainname} .rst
156- system doconce split_rst ${mainname}
157- system doconce sphinx_dir theme=cbc ${mainname}
158- system python automake_sphinx.py
159- fi
160-
161- # Add Oliver Sin's image for this chapter (if it exists), html and sphinx
162- oliver_art
163-
164-
165- # Note: this script is run from a subdirectory
166- if [ -f slides_${nickname} .do.txt ]; then
167- bash -x ../make_slides.sh slides_${nickname} .do.txt $nickname
168- if [ $? -ne 0 ]; then echo " doconce could not compile slides - abort" ; exit ; fi
169- fi
170- rsync=" rsync -rtDvz -u -e ssh -b --exclude-from=$HOME /1/.rsyncexclude --delete --force "
171-
172- doc=../../..
173- if [ $publish -eq 1 ]; then
174- # Copy compiled documents to destination repo
175- dest=$doc /pub
176- dest_sol=$doc /Trash
177- if [ ! -d $dest /${nickname} ]; then
178- echo " making directory ${dest} /${nickname} "
179- mkdir $dest /${nickname}
180- mkdir $dest /${nickname} /pdf
181- mkdir $dest /${nickname} /html
182- fi
183- if [ ! -d $dest_sol ]; then
184- mkdir $dest_sol
185- fi
186- if [ ! -d $dest_sol /${nickname} ]; then
187- echo " making directory ${dest_sol} /${nickname} "
188- mkdir $dest_sol /${nickname}
189- mkdir $dest_sol /${nickname} /pdf
190- mkdir $dest_sol /${nickname} /html
191- fi
192-
193- echo " copying compiled documents to $dest "
194- # Should not copy chapters since that requires ref[][][] and
195- # publishing of separate chapters...or should chapters exist in html?
196- cp ${nickame} * .pdf slides* .pdf ${dest} /${nickname} /pdf
197- cp ${nickname} * .html .${nickname} * ._${nickname} * .html slides* .html ._slides* ${dest} /${nickname} /html
198- # Remove documents with solutions
199- rm -f ${dest} /${nickname} /html/* -sol.html ${nickname} /html/._* -sol.html
200- rm -f ${dest} /${nickname} /pdf/* -sol.pdf
201-
202- # Replace the sphinx doc entirely
203- rm -rf ${dest} /${nickname} /sphinx
204- cp -r sphinx-rootdir/_build/html ${dest} /${nickname} /sphinx
205-
206- rm -f fig-${nickname} /* ~ fig-${nickname} /tmp*
207- # drop copying deck.js
208- dirs=" fig-${nickname} mov-${nickname} reveal.js"
209- for dir in $dirs ; do
210- if [ -d $dir ]; then
211- $rsync $dir ${dest} /${nickname} /html
212- fi
213- done
214-
215- echo " copying compiled documents to $dest_sol "
216-
217- cp ${nickname} -sol.pdf ${dest_sol} /${nickname} /pdf
218- cp ${nickname} -sol.html ._${nickname} -sol* .html ${dest_sol} /${nickname} /html
219- dirs=" fig-${nickname} mov-${nickname} "
220- for dir in $dirs ; do
221- if [ -d $dir ]; then
222- $rsync $dir ${dest_sol} /${nickname} /html
223- fi
224- done
225-
226- # Copy slides source
227- # dest=$doc/doc/slides/src/$name
228- # if [ ! -d $dest ]; then
229- # mkdir $dest
230- # fi
231- # $rsync lecture_${nickname}.do.txt slides-$nickname mov-$name fig-$namename src-$nickname $dest
232- # cp ../newcommands_keep.p.tex ../make_lectures.sh ../mako_code.txt ../papers.pub ../venues.list $dest/..
233-
234- cd ..
235- cp index_files.do.txt index.do.txt
236- system doconce format html index --html_style=bootstrap --html_links_in_new_window --html_bootstrap_navbar=off -DCHAPTERS
237- cd -
238- cp ../index.html $dest
239- rm -f ../index.*
240-
241- # Copy src
242- if [ $# -ge 3 ]; then
243- dest=../../../../src
244- if [ ! -d $dest ]; then
245- mkdir $dest
246- fi
247- if [ ! -d $dest /$nickname ]; then
248- mkdir $dest /$nickname
249- fi
250- if [ -d src-$nickname ]; then
251- cd src-$nickname
252- if [ -f clean.sh ]; then
253- sh clean.sh
254- fi
255- cd ..
256- files=` find -L src-$nickname \( -name ' *.py' -o -name ' *.pyx' -o -name ' *.f' -o -name ' *.c' -o -name ' *.cpp' -o -name ' make*.sh' \) -print`
257- if [ -f src-${nickname} /README ]; then
258- files=" $files src-$name /README"
259- fi
260- tar cfz tmp.tar.gz $files
261- mv -f tmp.tar.gz $dest
262- cd $dest
263- rm -rf src-$nickname
264- tar xfz tmp.tar.gz
265- rm -f tmp.tar.gz
266- python ~ /1/programs/rsync_git.py src-$nickname $nickname
267- rm -rf src-$nickname
268- cd -
269- fi
270- fi
271- fi
272-
273- cd $dest
274- git add .
107+ echo " Generated PDFs:"
108+ ls -la ${nickname} * .pdf
0 commit comments