summaryrefslogtreecommitdiffstats
path: root/Doc/howto
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/howto')
-rw-r--r--Doc/howto/Makefile120
-rw-r--r--Doc/howto/doanddont.tex5
-rw-r--r--Doc/howto/sockets.tex61
3 files changed, 94 insertions, 92 deletions
diff --git a/Doc/howto/Makefile b/Doc/howto/Makefile
index 19701c6..18110a2 100644
--- a/Doc/howto/Makefile
+++ b/Doc/howto/Makefile
@@ -1,88 +1,84 @@
+# Makefile for the HOWTO directory
+# LaTeX HOWTOs can be turned into HTML, PDF, PS, DVI or plain text output.
+# reST HOWTOs can only be turned into HTML.
-MKHOWTO=../tools/mkhowto
-WEBDIR=.
+# Variables to change
+
+# Paper size for non-HTML formats (letter or a4)
+PAPER=letter
+
+# Arguments to rst2html.py, and location of the script
RSTARGS = --input-encoding=utf-8
-VPATH=.:dvi:pdf:ps:txt
+RST2HTML = rst2html.py
-# List of HOWTOs that aren't to be processed
+# List of HOWTOs that aren't to be processed. This should contain the
+# base name of the HOWTO without any extension (e.g. 'advocacy',
+# 'unicode').
+REMOVE_HOWTOS =
-REMOVE_HOWTO =
+MKHOWTO=../tools/mkhowto
+WEBDIR=.
+PAPERDIR=../paper-$(PAPER)
+HTMLDIR=../html
# Determine list of files to be built
+TEX_SOURCES = $(wildcard *.tex)
+RST_SOURCES = $(wildcard *.rst)
+TEX_NAMES = $(filter-out $(REMOVE_HOWTOS),$(patsubst %.tex,%,$(TEX_SOURCES)))
+
+PAPER_PATHS=$(addprefix $(PAPERDIR)/,$(TEX_NAMES))
+DVI =$(addsuffix .dvi,$(PAPER_PATHS))
+PDF =$(addsuffix .pdf,$(PAPER_PATHS))
+PS =$(addsuffix .ps,$(PAPER_PATHS))
-HOWTO=$(filter-out $(REMOVE_HOWTO),$(wildcard *.tex))
-RST_SOURCES = $(shell echo *.rst)
-DVI =$(patsubst %.tex,%.dvi,$(HOWTO))
-PDF =$(patsubst %.tex,%.pdf,$(HOWTO))
-PS =$(patsubst %.tex,%.ps,$(HOWTO))
-TXT =$(patsubst %.tex,%.txt,$(HOWTO))
-HTML =$(patsubst %.tex,%,$(HOWTO))
+ALL_HOWTO_NAMES = $(TEX_NAMES) $(patsubst %.rst,%,$(RST_SOURCES))
+HOWTO_NAMES = $(filter-out $(REMOVE_HOWTOS),$(ALL_HOWTO_NAMES))
+HTML = $(addprefix $(HTMLDIR)/,$(HOWTO_NAMES))
# Rules for building various formats
-%.dvi : %.tex
+
+# reST to HTML
+$(HTMLDIR)/%: %.rst
+ if [ ! -d $@ ] ; then mkdir $@ ; fi
+ $(RST2HTML) $(RSTARGS) $< >$@/index.html
+
+# LaTeX to various output formats
+$(PAPERDIR)/%.dvi : %.tex
$(MKHOWTO) --dvi $<
- mv $@ dvi
+ mv $*.dvi $@
-%.pdf : %.tex
+$(PAPERDIR)/%.pdf : %.tex
$(MKHOWTO) --pdf $<
- mv $@ pdf
+ mv $*.pdf $@
-%.ps : %.tex
+$(PAPERDIR)/%.ps : %.tex
$(MKHOWTO) --ps $<
- mv $@ ps
+ mv $*.ps $@
+
+$(HTMLDIR)/% : %.tex
+ $(MKHOWTO) --html --iconserver="." --dir $@ $<
-%.txt : %.tex
+# Rule that isn't actually used -- we no longer support the 'txt' target.
+$(PAPERDIR)/%.txt : %.tex
$(MKHOWTO) --text $<
mv $@ txt
-% : %.tex
- $(MKHOWTO) --html --iconserver="." $<
- tar -zcvf html/$*.tgz $*
- #zip -r html/$*.zip $*
-
default:
@echo "'all' -- build all files"
- @echo "'dvi', 'pdf', 'ps', 'txt', 'html' -- build one format"
-
-all: $(HTML)
-
-.PHONY : dvi pdf ps txt html rst
-dvi: $(DVI)
-
-pdf: $(PDF)
-ps: $(PS)
-txt: $(TXT)
-html:$(HTML)
-
-# Rule to build collected tar files
-dist: #all
- for i in dvi pdf ps txt ; do \
- cd $$i ; \
- tar -zcf All.tgz *.$$i ;\
- cd .. ;\
- done
+ @echo "'dvi', 'pdf', 'ps', 'html' -- build one format"
-# Rule to copy files to the Web tree on AMK's machine
-web: dist
- cp dvi/* $(WEBDIR)/dvi
- cp ps/* $(WEBDIR)/ps
- cp pdf/* $(WEBDIR)/pdf
- cp txt/* $(WEBDIR)/txt
- for dir in $(HTML) ; do cp -rp $$dir $(WEBDIR) ; done
- for ltx in $(HOWTO) ; do cp -p $$ltx $(WEBDIR)/latex ; done
+all: dvi pdf ps html
-rst: unicode.html
-
-%.html: %.rst
- rst2html $(RSTARGS) $< >$@
+.PHONY : dvi pdf ps html
+dvi: $(DVI)
+pdf: $(PDF)
+ps: $(PS)
+html: $(HTML)
clean:
- rm -f *~ *.log *.ind *.l2h *.aux *.toc *.how
- rm -f *.dvi *.ps *.pdf *.bkm
- rm -f unicode.html
+ rm -f *~ *.log *.ind *.l2h *.aux *.toc *.how *.bkm
+ rm -f *.dvi *.pdf *.ps
clobber:
- rm dvi/* ps/* pdf/* txt/* html/*
-
-
-
+ rm -rf $(HTML)
+ rm -rf $(DVI) $(PDF) $(PS)
diff --git a/Doc/howto/doanddont.tex b/Doc/howto/doanddont.tex
index adbde66..a105ca1 100644
--- a/Doc/howto/doanddont.tex
+++ b/Doc/howto/doanddont.tex
@@ -288,8 +288,9 @@ More useful functions in \module{os.path}: \function{basename},
There are also many useful builtin functions people seem not to be
aware of for some reason: \function{min()} and \function{max()} can
find the minimum/maximum of any sequence with comparable semantics,
-for example, yet many people write they own max/min. Another highly
-useful function is \function{reduce()}. Classical use of \function{reduce()}
+for example, yet many people write their own
+\function{max()}/\function{min()}. Another highly useful function is
+\function{reduce()}. A classical use of \function{reduce()}
is something like
\begin{verbatim}
diff --git a/Doc/howto/sockets.tex b/Doc/howto/sockets.tex
index 4da92a8..0cecbb9 100644
--- a/Doc/howto/sockets.tex
+++ b/Doc/howto/sockets.tex
@@ -213,34 +213,39 @@ Assuming you don't want to end the connection, the simplest solution
is a fixed length message:
\begin{verbatim}
- class mysocket:
- '''demonstration class only
- - coded for clarity, not efficiency'''
- def __init__(self, sock=None):
- if sock is None:
- self.sock = socket.socket(
- socket.AF_INET, socket.SOCK_STREAM)
- else:
- self.sock = sock
- def connect(host, port):
- self.sock.connect((host, port))
- def mysend(msg):
- totalsent = 0
- while totalsent < MSGLEN:
- sent = self.sock.send(msg[totalsent:])
- if sent == 0:
- raise RuntimeError, \\
- "socket connection broken"
- totalsent = totalsent + sent
- def myreceive():
- msg = ''
- while len(msg) < MSGLEN:
- chunk = self.sock.recv(MSGLEN-len(msg))
- if chunk == '':
- raise RuntimeError, \\
- "socket connection broken"
- msg = msg + chunk
- return msg
+class mysocket:
+ '''demonstration class only
+ - coded for clarity, not efficiency
+ '''
+
+ def __init__(self, sock=None):
+ if sock is None:
+ self.sock = socket.socket(
+ socket.AF_INET, socket.SOCK_STREAM)
+ else:
+ self.sock = sock
+
+ def connect(self, host, port):
+ self.sock.connect((host, port))
+
+ def mysend(self, msg):
+ totalsent = 0
+ while totalsent < MSGLEN:
+ sent = self.sock.send(msg[totalsent:])
+ if sent == 0:
+ raise RuntimeError, \\
+ "socket connection broken"
+ totalsent = totalsent + sent
+
+ def myreceive(self):
+ msg = ''
+ while len(msg) < MSGLEN:
+ chunk = self.sock.recv(MSGLEN-len(msg))
+ if chunk == '':
+ raise RuntimeError, \\
+ "socket connection broken"
+ msg = msg + chunk
+ return msg
\end{verbatim}
The sending code here is usable for almost any messaging scheme - in