summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Krupcale <mkrupcale@matthewkrupcale.com>2019-03-12 23:40:19 -0400
committerMatthew Krupcale <mkrupcale@matthewkrupcale.com>2019-03-14 16:40:18 -0400
commit2e755f89cfeec7303ded1c8d1634230c6c871234 (patch)
tree2182ba6a3cc15ad3114ecc0d3a86280c9bc8a194
parente20a351013745e8d6c3a0a99bd40c172ed0ae8be (diff)
downloadbuild2-2e755f89cfeec7303ded1c8d1634230c6c871234.tar.gz
build2-2e755f89cfeec7303ded1c8d1634230c6c871234.tar.xz
build2-2e755f89cfeec7303ded1c8d1634230c6c871234.zip
Add support for LaTeX documentation.generate-latex
* doc/.gitignore: Ignore .tex output * doc/cli.sh: Generate LaTeX man pages and documentation and run through pdflatex * doc/{doc,man}-{prologue,epilogue}.tex: Symlink to prologues and epilogues * doc/manual.cli: Escape closing curly brackets inside code spans
-rw-r--r--doc/.gitignore2
-rwxr-xr-xdoc/cli.sh80
l---------doc/doc-epilogue.tex1
l---------doc/doc-prologue.tex1
l---------doc/man-epilogue.tex1
l---------doc/man-prologue.tex1
-rw-r--r--doc/manual.cli8
7 files changed, 81 insertions, 13 deletions
diff --git a/doc/.gitignore b/doc/.gitignore
index 9d45a89e..1a231f2a 100644
--- a/doc/.gitignore
+++ b/doc/.gitignore
@@ -1,5 +1,7 @@
+b.tex
b.xhtml
b.1
+build2-*-manual.tex
build2-*-manual.xhtml
*.ps
*.pdf
diff --git a/doc/cli.sh b/doc/cli.sh
index 4cd6863a..732ac07c 100755
--- a/doc/cli.sh
+++ b/doc/cli.sh
@@ -12,9 +12,11 @@ function error () { info "$*"; exit 1; }
while [ $# -gt 0 ]; do
case $1 in
--clean)
- rm -f b*.xhtml b*.1
+ rm -f b*.xhtml b*.tex b*.1
rm -f build2-build-system-manual.xhtml
+ rm -f build2-build-system-manual.tex
rm -f build2-testscript-manual.xhtml
+ rm -f build2-testscript-manual.tex
rm -f *.ps *.pdf
exit 0
;;
@@ -42,11 +44,36 @@ man-prologue.xhtml --html-epilogue-file man-epilogue.xhtml --html-suffix \
.xhtml ../build2/$n.cli
cli -I .. -v project="build2" -v version="$version" -v date="$date" \
+--include-base-last "${o[@]}" --generate-latex --latex-prologue-file \
+man-prologue.tex --latex-epilogue-file man-epilogue.tex \
+--latex-section-map "0=chapter*" --latex-section-map "1=chapter*" \
+--latex-section-map "H=part*" --latex-section-map "h=section*" \
+--latex-section-map "2=subsection*" ../build2/$n.cli
+
+ run_pdflatex "$n" "a4"
+ run_pdflatex "$n" "letter"
+
+ cli -I .. -v project="build2" -v version="$version" -v date="$date" \
--include-base-last "${o[@]}" --generate-man --man-prologue-file \
man-prologue.1 --man-epilogue-file man-epilogue.1 --man-suffix .1 \
../build2/$n.cli
}
+function run_pdflatex () # <name> <paper>
+{
+ local n="$1"
+ local paper="$2"
+
+ if [ "$paper" == "letter" ]; then
+ sed -i 's/a4paper/letterpaper/' "$n.tex"
+ fi
+
+ pdflatex -output-format dvi -jobname="$n-$paper" "$n"
+ dvips "$n-$paper.dvi"
+ pdflatex -output-format pdf -jobname="$n-$paper" "$n"
+ rm -f "$n-$paper".{aux,dvi,log,out,toc}
+}
+
o="--output-prefix b-"
# A few special cases.
@@ -64,6 +91,21 @@ done
function compile_doc () # <file> <prefix> <suffix>
{
+ local f="$1"
+ local prefix="$2"
+ local suffix="$3"
+
+ compile_html_doc "$f" "$prefix" "$suffix"
+ compile_latex_doc "$f" "$prefix" "$suffix" "a4"
+ compile_latex_doc "$f" "$prefix" "$suffix" "letter"
+}
+
+function compile_html_doc () # <file> <prefix> <suffix>
+{
+ local f="$1"
+ local prefix="$2"
+ local suffix="$3"
+
cli -I .. \
-v version="$(echo "$version" | sed -e 's/^\([^.]*\.[^.]*\).*/\1/')" \
-v date="$date" \
@@ -75,17 +117,37 @@ function compile_doc () # <file> <prefix> <suffix>
--link-regex '%bpkg(#.+)?%../../bpkg/doc/build2-package-manager-manual.xhtml$1%' \
--link-regex '%bdep([-.].+)%../../bdep/doc/bdep$1%' \
--link-regex '%testscript(#.+)?%build2-testscript-manual.xhtml$1%' \
---output-prefix "$2" \
---output-suffix "$3" \
-"$1"
+--output-prefix "$prefix" \
+--output-suffix "$suffix" \
+"$f"
+}
- local n="$2$(basename -s .cli $1)$3"
+function compile_latex_doc () # <file> <prefix> <suffix> <paper>
+{
+ local f="$1"
+ local prefix="$2"
+ local suffix="$3"
+ local paper="$4"
- html2ps -f doc.html2ps:a4.html2ps -o "$n-a4.ps" "$n.xhtml"
- ps2pdf14 -sPAPERSIZE=a4 -dOptimize=true -dEmbedAllFonts=true "$n-a4.ps" "$n-a4.pdf"
+ cli -I .. \
+-v version="$(echo "$version" | sed -e 's/^\([^.]*\.[^.]*\).*/\1/')" \
+-v date="$date" \
+--generate-latex \
+--latex-prologue-file doc-prologue.tex \
+--latex-epilogue-file doc-epilogue.tex \
+--link-regex '%intro(#.+)?%../../build2-toolchain/doc/build2-toolchain-intro-'"$paper"'.pdf$1%' \
+--link-regex '%bpkg([-.].+)?\.pdf%../../bpkg/doc/bpkg$1-'"$paper"'.pdf%' \
+--link-regex '%bpkg(#.+)?%../../bpkg/doc/build2-package-manager-manual-'"$paper"'.pdf$1%' \
+--link-regex '%bdep([-.].+)?\.pdf%../../bdep/doc/bdep$1-'"$paper"'.pdf%' \
+--link-regex '%testscript(#.+)?%build2-testscript-manual-'"$paper"'.pdf$1%' \
+--link-regex '%b([-.].+)%b-'"$paper"'$1%' \
+--output-prefix "$prefix" \
+--output-suffix "$suffix" \
+"$f"
+
+ local n="$2$(basename -s .cli $1)$3"
- html2ps -f doc.html2ps:letter.html2ps -o "$n-letter.ps" "$n.xhtml"
- ps2pdf14 -sPAPERSIZE=letter -dOptimize=true -dEmbedAllFonts=true "$n-letter.ps" "$n-letter.pdf"
+ run_pdflatex "$n" "$paper"
}
compile_doc manual.cli 'build2-build-system-'
diff --git a/doc/doc-epilogue.tex b/doc/doc-epilogue.tex
new file mode 120000
index 00000000..b17b5d1e
--- /dev/null
+++ b/doc/doc-epilogue.tex
@@ -0,0 +1 @@
+style/doc-epilogue.tex \ No newline at end of file
diff --git a/doc/doc-prologue.tex b/doc/doc-prologue.tex
new file mode 120000
index 00000000..b5d4e006
--- /dev/null
+++ b/doc/doc-prologue.tex
@@ -0,0 +1 @@
+style/doc-prologue.tex \ No newline at end of file
diff --git a/doc/man-epilogue.tex b/doc/man-epilogue.tex
new file mode 120000
index 00000000..47936113
--- /dev/null
+++ b/doc/man-epilogue.tex
@@ -0,0 +1 @@
+style/man-epilogue.tex \ No newline at end of file
diff --git a/doc/man-prologue.tex b/doc/man-prologue.tex
new file mode 120000
index 00000000..258684a1
--- /dev/null
+++ b/doc/man-prologue.tex
@@ -0,0 +1 @@
+style/man-prologue.tex \ No newline at end of file
diff --git a/doc/manual.cli b/doc/manual.cli
index 15d7c310..cffdcf0b 100644
--- a/doc/manual.cli
+++ b/doc/manual.cli
@@ -658,7 +658,7 @@ directory\" semantics.
Note also that \c{dir{\}} is purely an alias and doesn't have anything to do
with the filesystem. In particular, it does not create any directories. If you
do want explicit directory creation (which should be rarely needed), use the
-\c{fsdir{}} target type instead.|
+\c{fsdir{\}} target type instead.|
The \c{./} target is a special \i{default target}. If we run the build system
without specifying the target explicitly, then this target is built by
@@ -1049,7 +1049,7 @@ trees, src and out, with the in source build being just a special case where
they are the same. Targets in a project can be either in the src or out
directory though most of the time targets we mention in our \c{buildfiles}
will be in out, which is the default. Prerequsites are relative to targets
-they are prerequisites of and \c{file{}}-based prerequisites are first
+they are prerequisites of and \c{file{\}}-based prerequisites are first
searched for as declared targets in out and then as existing files in src.
Note also that we can have as many out of source builds as we want and we can
@@ -1751,7 +1751,7 @@ ld ../hello-gcc/hello/exe{hello}
ln ../hello-gcc/hello/exe{hello} -> hello/
\
-Notice the last line in the above listing: it indicates that \c{exe{hello}}
+Notice the last line in the above listing: it indicates that \c{exe{hello\}}
from the out directory was backlinked in our project's source subdirectory:
\
@@ -4665,7 +4665,7 @@ installing the manifest file as well as automatically generating version
headers (or other similar version-based files).
By default the project's \c{manifest} file is installed as documentation, just
-like other \c{doc{}} targets (thus replacing the \c{version} file customarily
+like other \c{doc{\}} targets (thus replacing the \c{version} file customarily
shipped in the project root directory). The manifest installation rule in the
\c{version} module in addition patches the installed manifest file with the
actual snapshot number and id, just like during the preparation of