##// END OF EJS Templates
doc: add generic frontend to rst2man and rst2html...
Martin Geisler -
r10971:cbe400a8 default
parent child Browse files
Show More
@@ -0,0 +1,26
1 #!/usr/bin/env python
2 #
3 # runrst - register custom roles and run correct writer
4 #
5 # Copyright 2010 Matt Mackall <mpm@selenic.com> and others
6 #
7 # This software may be used and distributed according to the terms of the
8 # GNU General Public License version 2 or any later version.
9
10 """usage: %s WRITER args...
11
12 where WRITER is the name of a Docutils writer such as 'html' or 'manpage'
13 """
14
15 import sys
16 from docutils.core import publish_cmdline
17
18 if __name__ == "__main__":
19 if len(sys.argv) < 2:
20 sys.stderr.write(__doc__ % sys.argv[0])
21 sys.exit(1)
22
23 writer = sys.argv[1]
24 del sys.argv[1]
25
26 publish_cmdline(writer_name=writer)
@@ -6,7 +6,6 PREFIX=/usr/local
6 MANDIR=$(PREFIX)/share/man
6 MANDIR=$(PREFIX)/share/man
7 INSTALL=install -c -m 644
7 INSTALL=install -c -m 644
8 PYTHON=python
8 PYTHON=python
9 RST2HTML=$(shell which rst2html 2> /dev/null || echo rst2html.py)
10
9
11 export LANGUAGE=C
10 export LANGUAGE=C
12 export LC_ALL=C
11 export LC_ALL=C
@@ -25,11 +24,11 hg.1.gendoc.txt: $(GENDOC)
25 mv $@.tmp $@
24 mv $@.tmp $@
26
25
27 %: %.txt common.txt
26 %: %.txt common.txt
28 $(PYTHON) rst2man.py --halt warning \
27 $(PYTHON) runrst manpage --halt warning \
29 --strip-elements-with-class htmlonly $*.txt $*
28 --strip-elements-with-class htmlonly $*.txt $*
30
29
31 %.html: %.txt common.txt
30 %.html: %.txt common.txt
32 $(RST2HTML) --halt warning \
31 $(PYTHON) runrst html --halt warning \
33 --link-stylesheet --stylesheet-path style.css $*.txt $*.html
32 --link-stylesheet --stylesheet-path style.css $*.txt $*.html
34
33
35 MANIFEST: man html
34 MANIFEST: man html
@@ -1099,11 +1099,4 class Translator(nodes.NodeVisitor):
1099 raise NotImplementedError('visiting unimplemented node type: %s'
1099 raise NotImplementedError('visiting unimplemented node type: %s'
1100 % node.__class__.__name__)
1100 % node.__class__.__name__)
1101
1101
1102 # The following part is taken from the Docutils rst2man.py script:
1103 if __name__ == "__main__":
1104 from docutils.core import publish_cmdline, default_description
1105 description = ("Generates plain unix manual documents. " +
1106 default_description)
1107 publish_cmdline(writer=Writer(), description=description)
1108
1109 # vim: set fileencoding=utf-8 et ts=4 ai :
1102 # vim: set fileencoding=utf-8 et ts=4 ai :
@@ -120,11 +120,11 def has_lsprof():
120 def has_git():
120 def has_git():
121 return matchoutput('git --version 2>&1', r'^git version')
121 return matchoutput('git --version 2>&1', r'^git version')
122
122
123 def has_rst2html():
123 def has_docutils():
124 for name in ('rst2html', 'rst2html.py'):
124 try:
125 name = name + ' --version 2>&1'
125 from docutils.core import publish_cmdline
126 if matchoutput(name, r'^rst2html(?:\.py)? \(Docutils'):
127 return True
126 return True
127 except ImportError:
128 return False
128 return False
129
129
130 def has_svn():
130 def has_svn():
@@ -198,7 +198,7 checks = {
198 "outer-repo": (has_outer_repo, "outer repo"),
198 "outer-repo": (has_outer_repo, "outer repo"),
199 "p4": (has_p4, "Perforce server and client"),
199 "p4": (has_p4, "Perforce server and client"),
200 "pygments": (has_pygments, "Pygments source highlighting library"),
200 "pygments": (has_pygments, "Pygments source highlighting library"),
201 "rst2html": (has_rst2html, "Docutils rst2html tool"),
201 "docutils": (has_docutils, "Docutils text processing library"),
202 "svn": (has_svn, "subversion client and admin tools"),
202 "svn": (has_svn, "subversion client and admin tools"),
203 "svn-bindings": (has_svn_bindings, "subversion python bindings"),
203 "svn-bindings": (has_svn_bindings, "subversion python bindings"),
204 "symlink": (has_symlink, "symbolic links"),
204 "symlink": (has_symlink, "symbolic links"),
@@ -1,7 +1,6
1 #!/bin/sh
1 #!/bin/sh
2
2
3 "$TESTDIR/hghave" rst2html || exit 80
3 "$TESTDIR/hghave" docutils || exit 80
4 RST2HTML=`which rst2html 2> /dev/null || which rst2html.py`
5
4
6 HGENCODING=UTF-8
5 HGENCODING=UTF-8
7 export HGENCODING
6 export HGENCODING
@@ -14,8 +13,8 for PO in C $TESTDIR/../i18n/*.po; do
14 echo "" >> gendoc-$LOCALE.txt
13 echo "" >> gendoc-$LOCALE.txt
15 LC_ALL=$LOCALE python $TESTDIR/../doc/gendoc.py >> gendoc-$LOCALE.txt || exit
14 LC_ALL=$LOCALE python $TESTDIR/../doc/gendoc.py >> gendoc-$LOCALE.txt || exit
16
15
17 # We run rst2html over the file without adding "--halt warning" to
16 # We call runrst without adding "--halt warning" to make it report
18 # make it report all errors instead of stopping on the first one.
17 # all errors instead of stopping on the first one.
19 echo "checking for parse errors with rst2html"
18 echo "checking for parse errors"
20 $RST2HTML gendoc-$LOCALE.txt /dev/null
19 python $TESTDIR/../doc/runrst html gendoc-$LOCALE.txt /dev/null
21 done
20 done
@@ -1,33 +1,33
1
1
2 % extracting documentation from C
2 % extracting documentation from C
3 checking for parse errors with rst2html
3 checking for parse errors
4
4
5 % extracting documentation from da
5 % extracting documentation from da
6 checking for parse errors with rst2html
6 checking for parse errors
7
7
8 % extracting documentation from de
8 % extracting documentation from de
9 checking for parse errors with rst2html
9 checking for parse errors
10
10
11 % extracting documentation from el
11 % extracting documentation from el
12 checking for parse errors with rst2html
12 checking for parse errors
13
13
14 % extracting documentation from fr
14 % extracting documentation from fr
15 checking for parse errors with rst2html
15 checking for parse errors
16
16
17 % extracting documentation from it
17 % extracting documentation from it
18 checking for parse errors with rst2html
18 checking for parse errors
19
19
20 % extracting documentation from ja
20 % extracting documentation from ja
21 checking for parse errors with rst2html
21 checking for parse errors
22
22
23 % extracting documentation from pt_BR
23 % extracting documentation from pt_BR
24 checking for parse errors with rst2html
24 checking for parse errors
25
25
26 % extracting documentation from sv
26 % extracting documentation from sv
27 checking for parse errors with rst2html
27 checking for parse errors
28
28
29 % extracting documentation from zh_CN
29 % extracting documentation from zh_CN
30 checking for parse errors with rst2html
30 checking for parse errors
31
31
32 % extracting documentation from zh_TW
32 % extracting documentation from zh_TW
33 checking for parse errors with rst2html
33 checking for parse errors
General Comments 0
You need to be logged in to leave comments. Login now