diff options
Diffstat (limited to 'Doc/tools')
-rwxr-xr-x | Doc/tools/mkinfo | 17 | ||||
-rw-r--r-- | Doc/tools/py2texi.el | 110 |
2 files changed, 76 insertions, 51 deletions
diff --git a/Doc/tools/mkinfo b/Doc/tools/mkinfo index 65add7c..d952730 100755 --- a/Doc/tools/mkinfo +++ b/Doc/tools/mkinfo @@ -2,8 +2,10 @@ # -*- Ksh -*- # Script to drive the HTML-info conversion process. -# Pass in a single parameter: the name of the top-level HTML file -# generated by LaTeX2HTML. +# Pass in upto three parameters: +# - 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> @@ -18,7 +20,12 @@ DOCDIR=`dirname "$FILENAME"` DOCFILE=`basename "$FILENAME"` DOCNAME=`basename "$FILENAME" .tex` if [ $# -gt 1 ]; then - INFONAME="$2" + TEXINAME="$2" +else + TEXINAME="python-$DOCNAME.texi" +fi +if [ $# -gt 2 ]; then + INFONAME="$3" else INFONAME="python-$DOCNAME.info" fi @@ -43,6 +50,8 @@ run() { run $EMACS -batch -q --no-site-file -l $TOOLSDIR/py2texi.el \ --eval "(setq py2texi-dirs '(\"./\" \"../texinputs/\" \"$DOCDIR\"))" \ + --eval "(setq py2texi-texi-file-name \"$TEXINAME\")" \ + --eval "(setq py2texi-info-file-name \"$INFONAME\")" \ --eval "(py2texi \"$DOCDIR/$DOCFILE\")" \ -f kill-emacs echo Done @@ -51,4 +60,4 @@ echo Done # generate the .info files: run $MAKEINFO --footnote-style end --fill-column 72 \ - --paragraph-indent 0 --output=$INFONAME $DOCNAME.texi + --paragraph-indent 0 --output=$INFONAME $TEXINAME diff --git a/Doc/tools/py2texi.el b/Doc/tools/py2texi.el index b29a913..eb7e00b 100644 --- a/Doc/tools/py2texi.el +++ b/Doc/tools/py2texi.el @@ -56,6 +56,14 @@ (match-string 0 py2texi-python-version)) "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 "*If non-nil, stop when you encouter soft problem.") @@ -65,36 +73,35 @@ ("cfuncdesc" 3 (progn (setq findex t) "\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 (progn (setq obindex t) "\n@table @code\n@item \\1(\\2)\n@obindex \\1\n") - "@end table") + "@end table\n") ("classdesc*" 1 (progn (setq obindex t) "\n@table @code\n@item \\1\n@obindex \\1\n") - "@end table") - ("cmemberdesc" 3 - (progn (setq findex t) - "\n@table @code\n@item \\1 \\2 \\3\n@findex \\3\n") - "@end table") + "@end table\n") ("csimplemacrodesc" 1 (progn (setq cindex t) "\n@table @code\n@item \\1\n@cindex \\1\n") - "@end table") + "@end table\n") ("ctypedesc" 1 (progn (setq cindex t) "\n@table @code\n@item \\1\n@cindex \\1\n") - "@end table") + "@end table\n") ("cvardesc" 2 (progn (setq findex t) "\n@table @code\n@item \\1 \\2\n@findex \\2\n") - "@end table") + "@end table\n") ("datadesc" 1 (progn (setq findex t) "\n@table @code\n@item \\1\n@findex \\1\n") - "@end table") - ("datadescni" 1 "\n@table @code\n@item \\1\n" "@end table") + "@end table\n") + ("datadescni" 1 "\n@table @code\n@item \\1\n" "@end table\n") ("definitions" 0 "@table @dfn" "@end table\n") ("description" 0 "@table @samp" "@end table\n") ("displaymath" 0 "" "") @@ -115,20 +122,20 @@ ("excdesc" 1 (progn (setq obindex t) "\n@table @code\n@item \\1\n@obindex \\1\n") - "@end table") + "@end table\n") ("excclassdesc" 2 (progn (setq obindex t) "\n@table @code\n@item \\1(\\2)\n@obindex \\1\n") - "@end table") + "@end table\n") ("flushleft" 0 "" "") - ("fulllineitems" 0 "\n@table @code\n" "@end table") + ("fulllineitems" 0 "\n@table @code\n" "@end table\n") ("funcdesc" 2 (progn (setq findex t) "\n@table @code\n@item \\1(\\2)\n@findex \\1\n") - "@end table") - ("funcdescni" 2 "\n@table @code\n@item \\1(\\2)\n" "@end table") + "@end table\n") + ("funcdescni" 2 "\n@table @code\n@item \\1(\\2)\n" "@end table\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" "@item \\3 @tab \\4\n" "@item ------- @tab ------ \n") @@ -140,22 +147,22 @@ ("memberdesc" 1 (progn (setq findex t) "\n@table @code\n@item \\1\n@findex \\1\n") - "@end table") - ("memberdescni" 1 "\n@table @code\n@item \\1\n" "@end table") + "@end table\n") + ("memberdescni" 1 "\n@table @code\n@item \\1\n" "@end table\n") ("methoddesc" 2 (progn (setq findex t) "\n@table @code\n@item \\1(\\2)\n@findex \\1\n") - "@end table") - ("methoddescni" 2 "\n@table @code\n@item \\1(\\2)\n" "@end table") + "@end table\n") + ("methoddescni" 2 "\n@table @code\n@item \\1(\\2)\n" "@end table\n") ("notice" 0 "@emph{Notice:} " "") ("opcodedesc" 2 (progn (setq findex t) "\n@table @code\n@item \\1 \\2\n@findex \\1\n") - "@end table") - ("productionlist" 0 "\n@table @code\n" "@end table") + "@end table\n") + ("productionlist" 0 "\n@table @code\n" "@end table\n") ("quotation" 0 "@quotation" "@end quotation") - ("seealso" 0 "See also:\n@table @emph\n" "@end table") - ("seealso*" 0 "@table @emph\n" "@end table") + ("seealso" 0 "See also:\n@table @emph\n" "@end table\n") + ("seealso*" 0 "@table @emph\n" "@end table\n") ("sloppypar" 0 "" "") ("small" 0 "" "") ("tableii" 4 (concat "@multitable @columnfractions .5 .5\n" @@ -200,9 +207,7 @@ Both BEGIN and END are evaled. Moreover, you can reference arguments through ("catcode" 0 "") ("cdata" 1 "@code{\\1}") ("centerline" 1 "@center \\1") - ("cfuncline" 3 - (progn (setq findex t) - "\n@item \\1 \\2(\\3)\n@findex \\2\n")) + ("cfuncline" 3 "@itemx \\1 \\2(\\3)\n@findex \\2") ("cfunction" 1 "@code{\\1}") ("chapter" 1 (format "@node \\1\n@%s \\1\n" (if appendix "appendix" "chapter"))) @@ -210,9 +215,7 @@ Both BEGIN and END are evaled. Moreover, you can reference arguments through ("character" 1 "@samp{\\1}") ("citetitle" 1 "@ref{Top,,,\\1}") ("class" 1 "@code{\\1}") - ("cmemberline" 3 - (progn (setq findex t) - "\n@item \\1 \\2 \\3\n@findex \\3\n")) + ("cmemberline" 3 "@itemx \\2 \\3\n") ("code" 1 "@code{\\1}") ("command" 1 "@command{\\1}") ("constant" 1 "@code{\\1}") @@ -282,7 +285,7 @@ Both BEGIN and END are evaled. Moreover, you can reference arguments through ("methodlineni" 2 "@item \\1(\\2)\n") ("mimetype" 1 "@samp{\\1}") ("module" 1 "@samp{\\1}") - ("moduleauthor" 2 "This module was written by \\1 @email{\\2}.@*") + ("moduleauthor" 2 "") ("modulesynopsis" 1 "\\1") ("moreargs" 0 "@dots{}") ("n" 0 "@backslash{}n") @@ -308,7 +311,7 @@ Both BEGIN and END are evaled. Moreover, you can reference arguments through ("plusminus" 0 "+-") ("POSIX" 0 "POSIX") ("production" 2 "@item \\1 \\2") - ("productioncont" 1 "@item \\1") + ("productioncont" 1 "@item @w{} \\1") ("program" 1 "@command{\\1}") ("programopt" 1 "@option{\\1}") ("protect" 0 "") @@ -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 2 str))) "@node \\1\n@section \\1\n")))) - ("sectionauthor" 2 - "\nThis manual section was written by \\1 @email{\\2}.@*") + ("sectionauthor" 2 "") ("seemodule" 2 "@ref{\\1} \\2") ("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") @@ -468,20 +470,26 @@ Each list item is of the form (COMMAND ARGNUM SUBSTITUTION) where: (py2texi-destroy-empties) (py2texi-fix-newlines) (py2texi-adjust-level)) - (let* ((filename (concat "./" - (file-name-nondirectory file) - (if (string-match "\\.tex$" file) "i" ".texi"))) - (infofilename (py2texi-info-file-name filename))) + (let* ((texi-file-name (or py2texi-texi-file-name + (py2texi-texi-file-name file))) + (info-file-name (or py2texi-info-file-name + (py2texi-info-file-name texi-file-name)))) (goto-char (point-min)) (when (looking-at py2texi-magic) (delete-region (point) (progn (beginning-of-line 2) (point))) (insert "\\input texinfo @c -*-texinfo-*-\n") - (insert "@setfilename " (file-name-nondirectory infofilename))) + (insert "@setfilename " info-file-name)) (when (re-search-forward "@chapter" nil t) (texinfo-all-menus-update t)) (goto-char (point-min)) - (write-file filename) - (message (format "You can apply `makeinfo %s' now." filename)))) + (write-file texi-file-name) + (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) @@ -719,19 +727,25 @@ Do not include .ind files." id counter string - label) + label + index) (py2texi-search "^@node +\\(.*\\)$" (setq string (match-string 1)) (if py2texi-xemacs (replace-match "@node " t) (replace-match "" t nil nil 1)) - (when (string-match "@label{[^}]*}" string) + (while (string-match "@label{[^}]*}" string) (setq label (match-string 0 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) (setq string (replace-match "" t nil string))) (while (string-match " -- " string) (setq string (replace-match " - " t nil string))) + (while (string-match "\\." string) + (setq string (replace-match "" t nil string))) (when (string-match " +$" string) (setq string (replace-match "" t nil string))) (when (string-match "^\\(Built-in\\|Standard\\) Module \\|The " string) @@ -747,9 +761,11 @@ Do not include .ind files." (setq counter 1)) (setf (gethash id nodes) counter) (insert string) + (beginning-of-line 3) (when label - (beginning-of-line 3) - (insert label "\n"))))) + (insert label "\n")) + (when index + (insert index "\n"))))) (defun py2texi-fix-references () |