comparison setup.py @ 238:d75cfd01f218

Documentation stuff moved to a shared repository.
author cmlenz
date Tue, 07 Aug 2007 13:07:37 +0000
parents d0cd235ede46
children 758556f6edb4
comparison
equal deleted inserted replaced
237:1e2f17433085 238:d75cfd01f218
20 from setuptools import setup 20 from setuptools import setup
21 except ImportError: 21 except ImportError:
22 from distutils.core import setup 22 from distutils.core import setup
23 import sys 23 import sys
24 24
25 25 sys.path.append(os.path.join('doc', 'common'))
26 class build_doc(Command): 26 try:
27 description = 'Builds the documentation' 27 from doctools import build_doc, test_doc
28 user_options = [ 28 except ImportError:
29 ('force', None, 29 build_doc = test_doc = None
30 "force regeneration even if no reStructuredText files have changed"),
31 ('without-apidocs', None,
32 "whether to skip the generation of API documentaton"),
33 ]
34 boolean_options = ['force', 'without-apidocs']
35
36 def initialize_options(self):
37 self.force = False
38 self.without_apidocs = False
39
40 def finalize_options(self):
41 pass
42
43 def run(self):
44 from docutils.core import publish_cmdline
45 from docutils.nodes import raw
46 from docutils.parsers import rst
47
48 docutils_conf = os.path.join('doc', 'conf', 'docutils.ini')
49 epydoc_conf = os.path.join('doc', 'conf', 'epydoc.ini')
50
51 try:
52 from pygments import highlight
53 from pygments.lexers import get_lexer_by_name
54 from pygments.formatters import HtmlFormatter
55
56 def code_block(name, arguments, options, content, lineno,
57 content_offset, block_text, state, state_machine):
58 lexer = get_lexer_by_name(arguments[0])
59 html = highlight('\n'.join(content), lexer, HtmlFormatter())
60 return [raw('', html, format='html')]
61 code_block.arguments = (1, 0, 0)
62 code_block.options = {'language' : rst.directives.unchanged}
63 code_block.content = 1
64 rst.directives.register_directive('code-block', code_block)
65 except ImportError:
66 print 'Pygments not installed, syntax highlighting disabled'
67
68 for source in glob('doc/*.txt'):
69 dest = os.path.splitext(source)[0] + '.html'
70 if self.force or not os.path.exists(dest) or \
71 os.path.getmtime(dest) < os.path.getmtime(source):
72 print 'building documentation file %s' % dest
73 publish_cmdline(writer_name='html',
74 argv=['--config=%s' % docutils_conf, source,
75 dest])
76
77 if not self.without_apidocs:
78 try:
79 from epydoc import cli
80 old_argv = sys.argv[1:]
81 sys.argv[1:] = [
82 '--config=%s' % epydoc_conf,
83 '--no-private', # epydoc bug, not read from config
84 '--simple-term',
85 '--verbose'
86 ]
87 cli.cli()
88 sys.argv[1:] = old_argv
89
90 except ImportError:
91 print 'epydoc not installed, skipping API documentation.'
92
93
94 class test_doc(Command):
95 description = 'Tests the code examples in the documentation'
96 user_options = []
97
98 def initialize_options(self):
99 pass
100
101 def finalize_options(self):
102 pass
103
104 def run(self):
105 for filename in glob('doc/*.txt'):
106 print 'testing documentation file %s' % filename
107 doctest.testfile(filename, False, optionflags=doctest.ELLIPSIS)
108 30
109 31
110 setup( 32 setup(
111 name = 'Babel', 33 name = 'Babel',
112 version = '0.9', 34 version = '0.9',
Copyright (C) 2012-2017 Edgewall Software