changeset 18:e6f4088ebe52

Generate a PDF file with a feedback link on each paragraph.
author Bryan O'Sullivan <bos@serpentine.com>
date Tue, 04 Jul 2006 16:41:31 -0700
parents 2668e15c76e9
children 187702df428b ce3339dbeb6f
files .hgignore en/00book.tex en/Makefile en/fblinks en/mq.tex
diffstat 5 files changed, 87 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Tue Jul 04 15:00:18 2006 -0700
+++ b/.hgignore	Tue Jul 04 16:41:31 2006 -0700
@@ -3,6 +3,7 @@
 
 syntax: glob
 
+beta/*.tex
 build_id.tex
 *.aux
 *.bbl
--- a/en/00book.tex	Tue Jul 04 15:00:18 2006 -0700
+++ b/en/00book.tex	Tue Jul 04 16:41:31 2006 -0700
@@ -4,7 +4,7 @@
 \usepackage{makeidx}
 \usepackage{ifpdf}
 \usepackage{graphicx}
-\usepackage{newcent}
+\usepackage{pslatex}
 \usepackage{fancyvrb}
 % leave hyperref until last
 \usepackage{hyperref}
@@ -28,7 +28,7 @@
 \pagenumbering{roman}
 \tableofcontents
 \listoffigures
-\listoftables
+%\listoftables
 
 \pagenumbering{arabic}
 
--- a/en/Makefile	Tue Jul 04 15:00:18 2006 -0700
+++ b/en/Makefile	Tue Jul 04 16:41:31 2006 -0700
@@ -1,3 +1,7 @@
+# This makefile requires GNU make.
+
+hg_id := $(shell hg id 2>/dev/null | sed -e 's/ tip\>//' -e 's/ /,/g' || echo external)
+
 sources := \
 	00book.tex \
 	99book.bib \
@@ -23,7 +27,7 @@
 
 pdf: pdf/hgbook.pdf
 
-pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%_pdf.png) examples
+define pdf
 	mkdir -p $(dir $@)
 	pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
 	cp 99book.bib $(dir $@)
@@ -31,9 +35,18 @@
 	cd $(dir $@) && makeindex $(basename $(notdir $@))
 	pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
 	pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1)
+endef
+
+pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%_pdf.png) examples
+	$(call pdf)
 
 html: html/onepage/hgbook.html html/split/hgbook.html
 
+# This is a horrible hack to work around the fact that the htlatex
+# command in tex4ht is itself a horrible hack.  I really don't want to
+# include verbatim the big wad of TeX that is repeated in that script,
+# so instead I mangle the script itself.
+
 define htlatex
 	mkdir -p $(dir $(1))
 	head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book
@@ -57,25 +70,40 @@
 	$(call htlatex,$@,$<,2)
 	cp $(image-sources:%.svg=%.png) $(dir $@)
 
+beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html
+
+beta/%.tex: %.tex
+	./fblinks $(hg_id) $(dir $@) $<
+
+beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%_pdf.png) examples fblinks
+	$(call pdf)
+
+beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
+	$(call htlatex,$@,$<)
+	cp $(image-sources:%.svg=%.png) $(dir $@)
+
+beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples
+	$(call htlatex,$@,$<,2)
+	cp $(image-sources:%.svg=%.png) $(dir $@)
+
+# Produce 90dpi PNGs for the web.
+
 %.png: %.svg
 	inkscape -D -e $@ $<
 
+# Produce 300dpi PNGs for PDF.
+
 %_pdf.png: %.svg
 	inkscape -D -d 300 -e $@ $<
 
-%.eps: %.svg
-	inkscape -E $@ $<
-
 examples: examples/.run
 
 examples/.run: $(example-sources)
 	cd examples && ./run-example
 
-build_id.tex:
-	echo 'in-place build' > $@
-
-build_id:
-	hg id | sed -e 's/ tip\>//' > build_id.tex
+build_id.tex: $(wildcard ../.hg/00changelog.[id])
+	echo $(hg_id) > build_id.tex
 
 clean:
-	rm -rf html pdf *.eps *.png *.aux *.dvi *.log *.out examples/*.out examples/.run buildrev.tex
+	rm -rf beta html pdf *.eps *.png *.aux *.dvi *.log *.out \
+		examples/*.out examples/.run build_id.tex
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/en/fblinks	Tue Jul 04 16:41:31 2006 -0700
@@ -0,0 +1,41 @@
+#!/usr/bin/python
+
+import errno
+import os
+import re
+import sys
+
+hg_id = sys.argv[1][:12]
+
+dest_dir = sys.argv[2]
+
+empty_re = re.compile('^\s*$')
+line_re = re.compile('^(\w+)(.*)')
+
+try:
+    os.makedirs(dest_dir)
+except OSError, err:
+    if err.errno != errno.EEXIST:
+        raise
+
+def feedback(name, text, line):
+    return r'\marginpar{\scriptsize \href{http://www.sourcecontrol.org/book/feedback.cgi?id=%s&file=%s&line=%d}{Feedback?}}' % (hg_id, name, line)
+
+for name in sys.argv[3:]:
+    if not name.endswith('.tex'):
+        continue
+    dest_name = os.path.join(dest_dir, name)
+    ifp = open(name)
+    ofp = open(dest_name, 'w')
+    new_par = True
+    line_num = 0
+    for line in ifp:
+        line_num += 1
+        if new_par:
+            m = line_re.match(line)
+            if m:
+                line = m.group(1) + feedback(name, line, line_num) + m.group(2)
+                new_par = False
+        elif not line.strip():
+            new_par = True
+        ofp.write(line)
--- a/en/mq.tex	Tue Jul 04 15:00:18 2006 -0700
+++ b/en/mq.tex	Tue Jul 04 16:41:31 2006 -0700
@@ -310,8 +310,8 @@
 
 Here's an example that illustrates how you can use this ability.
 Let's say you're developing a new feature as two patches.  The first
-is a change to the core of your software, and the second--layered on
-top of the first--changes the user interface to use the code you just
+is a change to the core of your software, and the second---layered on
+top of the first---changes the user interface to use the code you just
 added to the core.  If you notice a bug in the core while you're
 working on the UI patch, it's easy to fix the core.  Simply
 \hgcmd{qrefresh} the UI patch to save your in-progress changes, and
@@ -439,8 +439,8 @@
 \begin{itemize}
 \item The context in the middle of a hunk has changed.
 \item A hunk is missing some context at the beginning or end.
-\item A large hunk might apply better--either entirely or in part--if
-  it was broken up into smaller hunks.
+\item A large hunk might apply better---either entirely or in
+  part---if it was broken up into smaller hunks.
 \item A hunk removes lines with slightly different content than those
   currently present in the file.
 \end{itemize}
@@ -629,7 +629,7 @@
 
 The \command{diffstat} command~\cite{web:diffstat} generates a
 histogram of the modifications made to each file in a patch.  It
-provides a good way to ``get a sense of'' a patch--which files it
+provides a good way to ``get a sense of'' a patch---which files it
 affects, and how much change it introduces to each file and as a
 whole.  (I find that it's a good idea to use \command{diffstat}'s
 \texttt{-p} option as a matter of course, as otherwise it will try to