Commit c1fdc167 authored by Fred Drake's avatar Fred Drake

Integrate updates to the GNU info conversion.

This includes SF patch #590352 and additional support for more of the custom
markup.
parent 02255153
...@@ -34,34 +34,34 @@ check-emacs-version: ...@@ -34,34 +34,34 @@ check-emacs-version:
fi fi
python$(VERSION)-api.info: ../api/api.tex $(SCRIPTS) python$(VERSION)-api.info: ../api/api.tex $(SCRIPTS)
EMACS=$(EMACS) $(MKINFO) $< $@ EMACS=$(EMACS) $(MKINFO) $< $*.texi $@
python$(VERSION)-ext.info: ../ext/ext.tex $(SCRIPTS) python$(VERSION)-ext.info: ../ext/ext.tex $(SCRIPTS)
EMACS=$(EMACS) $(MKINFO) $< $@ EMACS=$(EMACS) $(MKINFO) $< $*.texi $@
python$(VERSION)-lib.info: ../lib/lib.tex $(SCRIPTS) python$(VERSION)-lib.info: ../lib/lib.tex $(SCRIPTS)
EMACS=$(EMACS) $(MKINFO) $< $@ EMACS=$(EMACS) $(MKINFO) $< $*.texi $@
# Not built by default; the conversion doesn't really handle it well. # Not built by default; the conversion doesn't really handle it well.
python$(VERSION)-mac.info: ../mac/mac.tex $(SCRIPTS) python$(VERSION)-mac.info: ../mac/mac.tex $(SCRIPTS)
EMACS=$(EMACS) $(MKINFO) $< $@ EMACS=$(EMACS) $(MKINFO) $< $*.texi $@
python$(VERSION)-ref.info: ../ref/ref.tex $(SCRIPTS) python$(VERSION)-ref.info: ../ref/ref.tex $(SCRIPTS)
EMACS=$(EMACS) $(MKINFO) $< $@ EMACS=$(EMACS) $(MKINFO) $< $*.texi $@
python$(VERSION)-tut.info: ../tut/tut.tex $(SCRIPTS) python$(VERSION)-tut.info: ../tut/tut.tex $(SCRIPTS)
EMACS=$(EMACS) $(MKINFO) $< $@ EMACS=$(EMACS) $(MKINFO) $< $*.texi $@
# Not built by default; the conversion doesn't handle it at all. # Not built by default; the conversion doesn't handle it at all.
python$(VERSION)-doc.info: ../doc/doc.tex $(SCRIPTS) python$(VERSION)-doc.info: ../doc/doc.tex $(SCRIPTS)
EMACS=$(EMACS) $(MKINFO) $< $@ EMACS=$(EMACS) $(MKINFO) $< $*.texi $@
python$(VERSION)-dist.info: ../dist/dist.tex $(SCRIPTS) python$(VERSION)-dist.info: ../dist/dist.tex $(SCRIPTS)
EMACS=$(EMACS) $(MKINFO) $< $@ EMACS=$(EMACS) $(MKINFO) $< $*.texi $@
# Not built by default; the conversion chokes on two @end multitable's # Not built by default; the conversion chokes on two @end multitable's
python$(VERSION)-inst.info: ../inst/inst.tex $(SCRIPTS) python$(VERSION)-inst.info: ../inst/inst.tex $(SCRIPTS)
EMACS=$(EMACS) $(MKINFO) $< $@ EMACS=$(EMACS) $(MKINFO) $< $*.texi $@
clean: clean:
rm -f *.texi~ *.texi rm -f *.texi~ *.texi
......
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
# -*- Ksh -*- # -*- Ksh -*-
# Script to drive the HTML-info conversion process. # Script to drive the HTML-info conversion process.
# Pass in a single parameter: the name of the top-level HTML file # Pass in upto three parameters:
# generated by LaTeX2HTML. # - the name of the main tex file
# - the name of the output file in texi format (optional)
# - the name of the output file in info format (optional)
# #
# Written by Fred L. Drake, Jr. <fdrake@acm.org> # Written by Fred L. Drake, Jr. <fdrake@acm.org>
...@@ -18,7 +20,12 @@ DOCDIR=`dirname "$FILENAME"` ...@@ -18,7 +20,12 @@ DOCDIR=`dirname "$FILENAME"`
DOCFILE=`basename "$FILENAME"` DOCFILE=`basename "$FILENAME"`
DOCNAME=`basename "$FILENAME" .tex` DOCNAME=`basename "$FILENAME" .tex`
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then
INFONAME="$2" TEXINAME="$2"
else
TEXINAME="python-$DOCNAME.texi"
fi
if [ $# -gt 2 ]; then
INFONAME="$3"
else else
INFONAME="python-$DOCNAME.info" INFONAME="python-$DOCNAME.info"
fi fi
...@@ -43,6 +50,8 @@ run() { ...@@ -43,6 +50,8 @@ run() {
run $EMACS -batch -q --no-site-file -l $TOOLSDIR/py2texi.el \ run $EMACS -batch -q --no-site-file -l $TOOLSDIR/py2texi.el \
--eval "(setq py2texi-dirs '(\"./\" \"../texinputs/\" \"$DOCDIR\"))" \ --eval "(setq py2texi-dirs '(\"./\" \"../texinputs/\" \"$DOCDIR\"))" \
--eval "(setq py2texi-texi-file-name \"$TEXINAME\")" \
--eval "(setq py2texi-info-file-name \"$INFONAME\")" \
--eval "(py2texi \"$DOCDIR/$DOCFILE\")" \ --eval "(py2texi \"$DOCDIR/$DOCFILE\")" \
-f kill-emacs -f kill-emacs
echo Done echo Done
...@@ -51,4 +60,4 @@ echo Done ...@@ -51,4 +60,4 @@ echo Done
# generate the .info files: # generate the .info files:
run $MAKEINFO --footnote-style end --fill-column 72 \ run $MAKEINFO --footnote-style end --fill-column 72 \
--paragraph-indent 0 --output=$INFONAME $DOCNAME.texi --paragraph-indent 0 --output=$INFONAME $TEXINAME
...@@ -56,6 +56,14 @@ ...@@ -56,6 +56,14 @@
(match-string 0 py2texi-python-version)) (match-string 0 py2texi-python-version))
"Short version number, usually set by the LaTeX commands.") "Short version number, usually set by the LaTeX commands.")
(defvar py2texi-texi-file-name nil
"If non-nil, that string is used as the name of the Texinfo file.
Otherwise a generated Texinfo file name is used.")
(defvar py2texi-info-file-name nil
"If non-nil, that string is used as the name of the Info file.
Otherwise a generated Info file name is used.")
(defvar py2texi-stop-on-problems nil (defvar py2texi-stop-on-problems nil
"*If non-nil, stop when you encouter soft problem.") "*If non-nil, stop when you encouter soft problem.")
...@@ -65,36 +73,35 @@ ...@@ -65,36 +73,35 @@
("cfuncdesc" 3 ("cfuncdesc" 3
(progn (setq findex t) (progn (setq findex t)
"\n@table @code\n@item \\1 \\2(\\3)\n@findex \\2\n") "\n@table @code\n@item \\1 \\2(\\3)\n@findex \\2\n")
"@end table") "@end table\n")
("cmemberdesc" 3
"\n@table @code\n@item \\2 \\3\n"
"@end table\n")
("classdesc" 2 ("classdesc" 2
(progn (setq obindex t) (progn (setq obindex t)
"\n@table @code\n@item \\1(\\2)\n@obindex \\1\n") "\n@table @code\n@item \\1(\\2)\n@obindex \\1\n")
"@end table") "@end table\n")
("classdesc*" 1 ("classdesc*" 1
(progn (setq obindex t) (progn (setq obindex t)
"\n@table @code\n@item \\1\n@obindex \\1\n") "\n@table @code\n@item \\1\n@obindex \\1\n")
"@end table") "@end table\n")
("cmemberdesc" 3
(progn (setq findex t)
"\n@table @code\n@item \\1 \\2 \\3\n@findex \\3\n")
"@end table")
("csimplemacrodesc" 1 ("csimplemacrodesc" 1
(progn (setq cindex t) (progn (setq cindex t)
"\n@table @code\n@item \\1\n@cindex \\1\n") "\n@table @code\n@item \\1\n@cindex \\1\n")
"@end table") "@end table\n")
("ctypedesc" 1 ("ctypedesc" 1
(progn (setq cindex t) (progn (setq cindex t)
"\n@table @code\n@item \\1\n@cindex \\1\n") "\n@table @code\n@item \\1\n@cindex \\1\n")
"@end table") "@end table\n")
("cvardesc" 2 ("cvardesc" 2
(progn (setq findex t) (progn (setq findex t)
"\n@table @code\n@item \\1 \\2\n@findex \\2\n") "\n@table @code\n@item \\1 \\2\n@findex \\2\n")
"@end table") "@end table\n")
("datadesc" 1 ("datadesc" 1
(progn (setq findex t) (progn (setq findex t)
"\n@table @code\n@item \\1\n@findex \\1\n") "\n@table @code\n@item \\1\n@findex \\1\n")
"@end table") "@end table\n")
("datadescni" 1 "\n@table @code\n@item \\1\n" "@end table") ("datadescni" 1 "\n@table @code\n@item \\1\n" "@end table\n")
("definitions" 0 "@table @dfn" "@end table\n") ("definitions" 0 "@table @dfn" "@end table\n")
("description" 0 "@table @samp" "@end table\n") ("description" 0 "@table @samp" "@end table\n")
("displaymath" 0 "" "") ("displaymath" 0 "" "")
...@@ -115,20 +122,20 @@ ...@@ -115,20 +122,20 @@
("excdesc" 1 ("excdesc" 1
(progn (setq obindex t) (progn (setq obindex t)
"\n@table @code\n@item \\1\n@obindex \\1\n") "\n@table @code\n@item \\1\n@obindex \\1\n")
"@end table") "@end table\n")
("excclassdesc" 2 ("excclassdesc" 2
(progn (setq obindex t) (progn (setq obindex t)
"\n@table @code\n@item \\1(\\2)\n@obindex \\1\n") "\n@table @code\n@item \\1(\\2)\n@obindex \\1\n")
"@end table") "@end table\n")
("flushleft" 0 "" "") ("flushleft" 0 "" "")
("fulllineitems" 0 "\n@table @code\n" "@end table") ("fulllineitems" 0 "\n@table @code\n" "@end table\n")
("funcdesc" 2 ("funcdesc" 2
(progn (setq findex t) (progn (setq findex t)
"\n@table @code\n@item \\1(\\2)\n@findex \\1\n") "\n@table @code\n@item \\1(\\2)\n@findex \\1\n")
"@end table") "@end table\n")
("funcdescni" 2 "\n@table @code\n@item \\1(\\2)\n" "@end table") ("funcdescni" 2 "\n@table @code\n@item \\1(\\2)\n" "@end table\n")
("itemize" 0 "@itemize @bullet" "@end itemize\n") ("itemize" 0 "@itemize @bullet" "@end itemize\n")
("list" 2 "\n@table @code\n" "@end table") ("list" 2 "\n@table @code\n" "@end table\n")
("longtableii" 4 (concat "@multitable @columnfractions .5 .5\n" ("longtableii" 4 (concat "@multitable @columnfractions .5 .5\n"
"@item \\3 @tab \\4\n" "@item \\3 @tab \\4\n"
"@item ------- @tab ------ \n") "@item ------- @tab ------ \n")
...@@ -140,22 +147,22 @@ ...@@ -140,22 +147,22 @@
("memberdesc" 1 ("memberdesc" 1
(progn (setq findex t) (progn (setq findex t)
"\n@table @code\n@item \\1\n@findex \\1\n") "\n@table @code\n@item \\1\n@findex \\1\n")
"@end table") "@end table\n")
("memberdescni" 1 "\n@table @code\n@item \\1\n" "@end table") ("memberdescni" 1 "\n@table @code\n@item \\1\n" "@end table\n")
("methoddesc" 2 ("methoddesc" 2
(progn (setq findex t) (progn (setq findex t)
"\n@table @code\n@item \\1(\\2)\n@findex \\1\n") "\n@table @code\n@item \\1(\\2)\n@findex \\1\n")
"@end table") "@end table\n")
("methoddescni" 2 "\n@table @code\n@item \\1(\\2)\n" "@end table") ("methoddescni" 2 "\n@table @code\n@item \\1(\\2)\n" "@end table\n")
("notice" 0 "@emph{Notice:} " "") ("notice" 0 "@emph{Notice:} " "")
("opcodedesc" 2 ("opcodedesc" 2
(progn (setq findex t) (progn (setq findex t)
"\n@table @code\n@item \\1 \\2\n@findex \\1\n") "\n@table @code\n@item \\1 \\2\n@findex \\1\n")
"@end table") "@end table\n")
("productionlist" 0 "\n@table @code\n" "@end table") ("productionlist" 0 "\n@table @code\n" "@end table\n")
("quotation" 0 "@quotation" "@end quotation") ("quotation" 0 "@quotation" "@end quotation")
("seealso" 0 "See also:\n@table @emph\n" "@end table") ("seealso" 0 "See also:\n@table @emph\n" "@end table\n")
("seealso*" 0 "@table @emph\n" "@end table") ("seealso*" 0 "@table @emph\n" "@end table\n")
("sloppypar" 0 "" "") ("sloppypar" 0 "" "")
("small" 0 "" "") ("small" 0 "" "")
("tableii" 4 (concat "@multitable @columnfractions .5 .5\n" ("tableii" 4 (concat "@multitable @columnfractions .5 .5\n"
...@@ -200,9 +207,7 @@ Both BEGIN and END are evaled. Moreover, you can reference arguments through ...@@ -200,9 +207,7 @@ Both BEGIN and END are evaled. Moreover, you can reference arguments through
("catcode" 0 "") ("catcode" 0 "")
("cdata" 1 "@code{\\1}") ("cdata" 1 "@code{\\1}")
("centerline" 1 "@center \\1") ("centerline" 1 "@center \\1")
("cfuncline" 3 ("cfuncline" 3 "@itemx \\1 \\2(\\3)\n@findex \\2")
(progn (setq findex t)
"\n@item \\1 \\2(\\3)\n@findex \\2\n"))
("cfunction" 1 "@code{\\1}") ("cfunction" 1 "@code{\\1}")
("chapter" 1 (format "@node \\1\n@%s \\1\n" ("chapter" 1 (format "@node \\1\n@%s \\1\n"
(if appendix "appendix" "chapter"))) (if appendix "appendix" "chapter")))
...@@ -210,9 +215,7 @@ Both BEGIN and END are evaled. Moreover, you can reference arguments through ...@@ -210,9 +215,7 @@ Both BEGIN and END are evaled. Moreover, you can reference arguments through
("character" 1 "@samp{\\1}") ("character" 1 "@samp{\\1}")
("citetitle" 1 "@ref{Top,,,\\1}") ("citetitle" 1 "@ref{Top,,,\\1}")
("class" 1 "@code{\\1}") ("class" 1 "@code{\\1}")
("cmemberline" 3 ("cmemberline" 3 "@itemx \\2 \\3\n")
(progn (setq findex t)
"\n@item \\1 \\2 \\3\n@findex \\3\n"))
("code" 1 "@code{\\1}") ("code" 1 "@code{\\1}")
("command" 1 "@command{\\1}") ("command" 1 "@command{\\1}")
("constant" 1 "@code{\\1}") ("constant" 1 "@code{\\1}")
...@@ -282,7 +285,7 @@ Both BEGIN and END are evaled. Moreover, you can reference arguments through ...@@ -282,7 +285,7 @@ Both BEGIN and END are evaled. Moreover, you can reference arguments through
("methodlineni" 2 "@item \\1(\\2)\n") ("methodlineni" 2 "@item \\1(\\2)\n")
("mimetype" 1 "@samp{\\1}") ("mimetype" 1 "@samp{\\1}")
("module" 1 "@samp{\\1}") ("module" 1 "@samp{\\1}")
("moduleauthor" 2 "This module was written by \\1 @email{\\2}.@*") ("moduleauthor" 2 "")
("modulesynopsis" 1 "\\1") ("modulesynopsis" 1 "\\1")
("moreargs" 0 "@dots{}") ("moreargs" 0 "@dots{}")
("n" 0 "@backslash{}n") ("n" 0 "@backslash{}n")
...@@ -308,7 +311,7 @@ Both BEGIN and END are evaled. Moreover, you can reference arguments through ...@@ -308,7 +311,7 @@ Both BEGIN and END are evaled. Moreover, you can reference arguments through
("plusminus" 0 "+-") ("plusminus" 0 "+-")
("POSIX" 0 "POSIX") ("POSIX" 0 "POSIX")
("production" 2 "@item \\1 \\2") ("production" 2 "@item \\1 \\2")
("productioncont" 1 "@item \\1") ("productioncont" 1 "@item @w{} \\1")
("program" 1 "@command{\\1}") ("program" 1 "@command{\\1}")
("programopt" 1 "@option{\\1}") ("programopt" 1 "@option{\\1}")
("protect" 0 "") ("protect" 0 "")
...@@ -334,8 +337,7 @@ Both BEGIN and END are evaled. Moreover, you can reference arguments through ...@@ -334,8 +337,7 @@ Both BEGIN and END are evaled. Moreover, you can reference arguments through
(py2texi-backslash-quote (match-string 1 str)) (py2texi-backslash-quote (match-string 1 str))
(py2texi-backslash-quote (match-string 2 str))) (py2texi-backslash-quote (match-string 2 str)))
"@node \\1\n@section \\1\n")))) "@node \\1\n@section \\1\n"))))
("sectionauthor" 2 ("sectionauthor" 2 "")
"\nThis manual section was written by \\1 @email{\\2}.@*")
("seemodule" 2 "@ref{\\1} \\2") ("seemodule" 2 "@ref{\\1} \\2")
("seepep" 3 "\n@table @strong\n@item PEP\\1 \\2\n\\3\n@end table\n") ("seepep" 3 "\n@table @strong\n@item PEP\\1 \\2\n\\3\n@end table\n")
("seerfc" 3 "\n@table @strong\n@item RFC\\1 \\2\n\\3\n@end table\n") ("seerfc" 3 "\n@table @strong\n@item RFC\\1 \\2\n\\3\n@end table\n")
...@@ -468,20 +470,26 @@ Each list item is of the form (COMMAND ARGNUM SUBSTITUTION) where: ...@@ -468,20 +470,26 @@ Each list item is of the form (COMMAND ARGNUM SUBSTITUTION) where:
(py2texi-destroy-empties) (py2texi-destroy-empties)
(py2texi-fix-newlines) (py2texi-fix-newlines)
(py2texi-adjust-level)) (py2texi-adjust-level))
(let* ((filename (concat "./" (let* ((texi-file-name (or py2texi-texi-file-name
(file-name-nondirectory file) (py2texi-texi-file-name file)))
(if (string-match "\\.tex$" file) "i" ".texi"))) (info-file-name (or py2texi-info-file-name
(infofilename (py2texi-info-file-name filename))) (py2texi-info-file-name texi-file-name))))
(goto-char (point-min)) (goto-char (point-min))
(when (looking-at py2texi-magic) (when (looking-at py2texi-magic)
(delete-region (point) (progn (beginning-of-line 2) (point))) (delete-region (point) (progn (beginning-of-line 2) (point)))
(insert "\\input texinfo @c -*-texinfo-*-\n") (insert "\\input texinfo @c -*-texinfo-*-\n")
(insert "@setfilename " (file-name-nondirectory infofilename))) (insert "@setfilename " info-file-name))
(when (re-search-forward "@chapter" nil t) (when (re-search-forward "@chapter" nil t)
(texinfo-all-menus-update t)) (texinfo-all-menus-update t))
(goto-char (point-min)) (goto-char (point-min))
(write-file filename) (write-file texi-file-name)
(message (format "You can apply `makeinfo %s' now." filename)))) (message (format "You can apply `makeinfo %s' now." texi-file-name))))
(defun py2texi-texi-file-name (filename)
"Generate name of Texinfo file from original file name FILENAME."
(concat filename
(if (string-match "\\.tex$" filename) "i" ".texi")))
(defun py2texi-info-file-name (filename) (defun py2texi-info-file-name (filename)
...@@ -719,19 +727,25 @@ Do not include .ind files." ...@@ -719,19 +727,25 @@ Do not include .ind files."
id id
counter counter
string string
label) label
index)
(py2texi-search "^@node +\\(.*\\)$" (py2texi-search "^@node +\\(.*\\)$"
(setq string (match-string 1)) (setq string (match-string 1))
(if py2texi-xemacs (if py2texi-xemacs
(replace-match "@node " t) (replace-match "@node " t)
(replace-match "" t nil nil 1)) (replace-match "" t nil nil 1))
(when (string-match "@label{[^}]*}" string) (while (string-match "@label{[^}]*}" string)
(setq label (match-string 0 string)) (setq label (match-string 0 string))
(setq string (replace-match "" t nil string))) (setq string (replace-match "" t nil string)))
(while (string-match "@..?index{[^}]*}" string)
(setq index (match-string 0 string))
(setq string (replace-match "" t nil string)))
(while (string-match "@[a-zA-Z]+\\|[{}():]\\|``\\|''" string) (while (string-match "@[a-zA-Z]+\\|[{}():]\\|``\\|''" string)
(setq string (replace-match "" t nil string))) (setq string (replace-match "" t nil string)))
(while (string-match " -- " string) (while (string-match " -- " string)
(setq string (replace-match " - " t nil string))) (setq string (replace-match " - " t nil string)))
(while (string-match "\\." string)
(setq string (replace-match "" t nil string)))
(when (string-match " +$" string) (when (string-match " +$" string)
(setq string (replace-match "" t nil string))) (setq string (replace-match "" t nil string)))
(when (string-match "^\\(Built-in\\|Standard\\) Module \\|The " string) (when (string-match "^\\(Built-in\\|Standard\\) Module \\|The " string)
...@@ -747,9 +761,11 @@ Do not include .ind files." ...@@ -747,9 +761,11 @@ Do not include .ind files."
(setq counter 1)) (setq counter 1))
(setf (gethash id nodes) counter) (setf (gethash id nodes) counter)
(insert string) (insert string)
(beginning-of-line 3)
(when label (when label
(beginning-of-line 3) (insert label "\n"))
(insert label "\n"))))) (when index
(insert index "\n")))))
(defun py2texi-fix-references () (defun py2texi-fix-references ()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment