hgbook
changeset 18:e6f4088ebe52
Generate a PDF file with a feedback link on each paragraph.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Tue Jul 04 16:41:31 2006 -0700 (2006-07-04) |
parents | 2668e15c76e9 |
children | 187702df428b ce3339dbeb6f |
files | .hgignore en/00book.tex en/Makefile en/fblinks en/mq.tex |
line diff
1.1 --- a/.hgignore Tue Jul 04 15:00:18 2006 -0700 1.2 +++ b/.hgignore Tue Jul 04 16:41:31 2006 -0700 1.3 @@ -3,6 +3,7 @@ 1.4 1.5 syntax: glob 1.6 1.7 +beta/*.tex 1.8 build_id.tex 1.9 *.aux 1.10 *.bbl
2.1 --- a/en/00book.tex Tue Jul 04 15:00:18 2006 -0700 2.2 +++ b/en/00book.tex Tue Jul 04 16:41:31 2006 -0700 2.3 @@ -4,7 +4,7 @@ 2.4 \usepackage{makeidx} 2.5 \usepackage{ifpdf} 2.6 \usepackage{graphicx} 2.7 -\usepackage{newcent} 2.8 +\usepackage{pslatex} 2.9 \usepackage{fancyvrb} 2.10 % leave hyperref until last 2.11 \usepackage{hyperref} 2.12 @@ -28,7 +28,7 @@ 2.13 \pagenumbering{roman} 2.14 \tableofcontents 2.15 \listoffigures 2.16 -\listoftables 2.17 +%\listoftables 2.18 2.19 \pagenumbering{arabic} 2.20
3.1 --- a/en/Makefile Tue Jul 04 15:00:18 2006 -0700 3.2 +++ b/en/Makefile Tue Jul 04 16:41:31 2006 -0700 3.3 @@ -1,3 +1,7 @@ 3.4 +# This makefile requires GNU make. 3.5 + 3.6 +hg_id := $(shell hg id 2>/dev/null | sed -e 's/ tip\>//' -e 's/ /,/g' || echo external) 3.7 + 3.8 sources := \ 3.9 00book.tex \ 3.10 99book.bib \ 3.11 @@ -23,7 +27,7 @@ 3.12 3.13 pdf: pdf/hgbook.pdf 3.14 3.15 -pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%_pdf.png) examples 3.16 +define pdf 3.17 mkdir -p $(dir $@) 3.18 pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1) 3.19 cp 99book.bib $(dir $@) 3.20 @@ -31,9 +35,18 @@ 3.21 cd $(dir $@) && makeindex $(basename $(notdir $@)) 3.22 pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1) 3.23 pdflatex $(call latex-options,$@) $< || (rm -f $@; exit 1) 3.24 +endef 3.25 + 3.26 +pdf/hgbook.pdf: $(sources) $(image-sources:%.svg=%_pdf.png) examples 3.27 + $(call pdf) 3.28 3.29 html: html/onepage/hgbook.html html/split/hgbook.html 3.30 3.31 +# This is a horrible hack to work around the fact that the htlatex 3.32 +# command in tex4ht is itself a horrible hack. I really don't want to 3.33 +# include verbatim the big wad of TeX that is repeated in that script, 3.34 +# so instead I mangle the script itself. 3.35 + 3.36 define htlatex 3.37 mkdir -p $(dir $(1)) 3.38 head -2 $(shell which htlatex) > $(dir $(1))/htlatex.book 3.39 @@ -57,25 +70,40 @@ 3.40 $(call htlatex,$@,$<,2) 3.41 cp $(image-sources:%.svg=%.png) $(dir $@) 3.42 3.43 +beta: beta/pdf/hgbook.pdf beta/html/onepage/hgbook.html beta/html/split/hgbook.html 3.44 + 3.45 +beta/%.tex: %.tex 3.46 + ./fblinks $(hg_id) $(dir $@) $< 3.47 + 3.48 +beta/pdf/hgbook.pdf: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%_pdf.png) examples fblinks 3.49 + $(call pdf) 3.50 + 3.51 +beta/html/onepage/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples 3.52 + $(call htlatex,$@,$<) 3.53 + cp $(image-sources:%.svg=%.png) $(dir $@) 3.54 + 3.55 +beta/html/split/hgbook.html: $(sources:%.tex=beta/%.tex) $(image-sources:%.svg=%.png) examples 3.56 + $(call htlatex,$@,$<,2) 3.57 + cp $(image-sources:%.svg=%.png) $(dir $@) 3.58 + 3.59 +# Produce 90dpi PNGs for the web. 3.60 + 3.61 %.png: %.svg 3.62 inkscape -D -e $@ $< 3.63 3.64 +# Produce 300dpi PNGs for PDF. 3.65 + 3.66 %_pdf.png: %.svg 3.67 inkscape -D -d 300 -e $@ $< 3.68 3.69 -%.eps: %.svg 3.70 - inkscape -E $@ $< 3.71 - 3.72 examples: examples/.run 3.73 3.74 examples/.run: $(example-sources) 3.75 cd examples && ./run-example 3.76 3.77 -build_id.tex: 3.78 - echo 'in-place build' > $@ 3.79 - 3.80 -build_id: 3.81 - hg id | sed -e 's/ tip\>//' > build_id.tex 3.82 +build_id.tex: $(wildcard ../.hg/00changelog.[id]) 3.83 + echo $(hg_id) > build_id.tex 3.84 3.85 clean: 3.86 - rm -rf html pdf *.eps *.png *.aux *.dvi *.log *.out examples/*.out examples/.run buildrev.tex 3.87 + rm -rf beta html pdf *.eps *.png *.aux *.dvi *.log *.out \ 3.88 + examples/*.out examples/.run build_id.tex
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/en/fblinks Tue Jul 04 16:41:31 2006 -0700 4.3 @@ -0,0 +1,41 @@ 4.4 +#!/usr/bin/python 4.5 + 4.6 +import errno 4.7 +import os 4.8 +import re 4.9 +import sys 4.10 + 4.11 +hg_id = sys.argv[1][:12] 4.12 + 4.13 +dest_dir = sys.argv[2] 4.14 + 4.15 +empty_re = re.compile('^\s*$') 4.16 +line_re = re.compile('^(\w+)(.*)') 4.17 + 4.18 +try: 4.19 + os.makedirs(dest_dir) 4.20 +except OSError, err: 4.21 + if err.errno != errno.EEXIST: 4.22 + raise 4.23 + 4.24 +def feedback(name, text, line): 4.25 + return r'\marginpar{\scriptsize \href{http://www.sourcecontrol.org/book/feedback.cgi?id=%s&file=%s&line=%d}{Feedback?}}' % (hg_id, name, line) 4.26 + 4.27 +for name in sys.argv[3:]: 4.28 + if not name.endswith('.tex'): 4.29 + continue 4.30 + dest_name = os.path.join(dest_dir, name) 4.31 + ifp = open(name) 4.32 + ofp = open(dest_name, 'w') 4.33 + new_par = True 4.34 + line_num = 0 4.35 + for line in ifp: 4.36 + line_num += 1 4.37 + if new_par: 4.38 + m = line_re.match(line) 4.39 + if m: 4.40 + line = m.group(1) + feedback(name, line, line_num) + m.group(2) 4.41 + new_par = False 4.42 + elif not line.strip(): 4.43 + new_par = True 4.44 + ofp.write(line)
5.1 --- a/en/mq.tex Tue Jul 04 15:00:18 2006 -0700 5.2 +++ b/en/mq.tex Tue Jul 04 16:41:31 2006 -0700 5.3 @@ -310,8 +310,8 @@ 5.4 5.5 Here's an example that illustrates how you can use this ability. 5.6 Let's say you're developing a new feature as two patches. The first 5.7 -is a change to the core of your software, and the second--layered on 5.8 -top of the first--changes the user interface to use the code you just 5.9 +is a change to the core of your software, and the second---layered on 5.10 +top of the first---changes the user interface to use the code you just 5.11 added to the core. If you notice a bug in the core while you're 5.12 working on the UI patch, it's easy to fix the core. Simply 5.13 \hgcmd{qrefresh} the UI patch to save your in-progress changes, and 5.14 @@ -439,8 +439,8 @@ 5.15 \begin{itemize} 5.16 \item The context in the middle of a hunk has changed. 5.17 \item A hunk is missing some context at the beginning or end. 5.18 -\item A large hunk might apply better--either entirely or in part--if 5.19 - it was broken up into smaller hunks. 5.20 +\item A large hunk might apply better---either entirely or in 5.21 + part---if it was broken up into smaller hunks. 5.22 \item A hunk removes lines with slightly different content than those 5.23 currently present in the file. 5.24 \end{itemize} 5.25 @@ -629,7 +629,7 @@ 5.26 5.27 The \command{diffstat} command~\cite{web:diffstat} generates a 5.28 histogram of the modifications made to each file in a patch. It 5.29 -provides a good way to ``get a sense of'' a patch--which files it 5.30 +provides a good way to ``get a sense of'' a patch---which files it 5.31 affects, and how much change it introduces to each file and as a 5.32 whole. (I find that it's a good idea to use \command{diffstat}'s 5.33 \texttt{-p} option as a matter of course, as otherwise it will try to