Mercurial > babel > mirror
annotate setup.py @ 107:fadbba1d89c8 trunk
Minor doc improvements.
author | cmlenz |
---|---|
date | Thu, 14 Jun 2007 10:05:47 +0000 |
parents | f5cfd37ec37e |
children | 1984cdac1ddb |
rev | line source |
---|---|
1 | 1 #!/usr/bin/env python |
2 # -*- coding: utf-8 -*- | |
3 # | |
4 # Copyright (C) 2007 Edgewall Software | |
5 # All rights reserved. | |
6 # | |
7 # This software is licensed as described in the file COPYING, which | |
8 # you should have received as part of this distribution. The terms | |
9 # are also available at http://babel.edgewall.org/wiki/License. | |
10 # | |
11 # This software consists of voluntary contributions made by many | |
12 # individuals. For the exact contribution history, see the revision | |
13 # history and logs, available at http://babel.edgewall.org/log/. | |
14 | |
12
e6ba3e878b10
* Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
1
diff
changeset
|
15 from distutils.cmd import Command |
1 | 16 import doctest |
17 from glob import glob | |
18 import os | |
12
e6ba3e878b10
* Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
1
diff
changeset
|
19 try: |
e6ba3e878b10
* Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
1
diff
changeset
|
20 from setuptools import setup |
e6ba3e878b10
* Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
1
diff
changeset
|
21 except ImportError: |
e6ba3e878b10
* Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
1
diff
changeset
|
22 from distutils.core import setup |
1 | 23 import sys |
24 | |
25 | |
26 class build_doc(Command): | |
27 description = 'Builds the documentation' | |
98
f5cfd37ec37e
Add `--without-apidocs` switch to `build_doc` command for quicker doc-edit/review cycles.
cmlenz
parents:
57
diff
changeset
|
28 user_options = [ |
f5cfd37ec37e
Add `--without-apidocs` switch to `build_doc` command for quicker doc-edit/review cycles.
cmlenz
parents:
57
diff
changeset
|
29 ('without-apidocs', None, |
f5cfd37ec37e
Add `--without-apidocs` switch to `build_doc` command for quicker doc-edit/review cycles.
cmlenz
parents:
57
diff
changeset
|
30 "whether to skip the generation of API documentaton"), |
f5cfd37ec37e
Add `--without-apidocs` switch to `build_doc` command for quicker doc-edit/review cycles.
cmlenz
parents:
57
diff
changeset
|
31 ] |
f5cfd37ec37e
Add `--without-apidocs` switch to `build_doc` command for quicker doc-edit/review cycles.
cmlenz
parents:
57
diff
changeset
|
32 boolean_options = ['without-apidocs'] |
1 | 33 |
34 def initialize_options(self): | |
98
f5cfd37ec37e
Add `--without-apidocs` switch to `build_doc` command for quicker doc-edit/review cycles.
cmlenz
parents:
57
diff
changeset
|
35 self.without_apidocs = False |
1 | 36 |
37 def finalize_options(self): | |
38 pass | |
39 | |
40 def run(self): | |
41 from docutils.core import publish_cmdline | |
40 | 42 from docutils.nodes import raw |
43 from docutils.parsers import rst | |
44 | |
1 | 45 docutils_conf = os.path.join('doc', 'docutils.conf') |
46 epydoc_conf = os.path.join('doc', 'epydoc.conf') | |
47 | |
40 | 48 try: |
49 from pygments import highlight | |
50 from pygments.lexers import get_lexer_by_name | |
51 from pygments.formatters import HtmlFormatter | |
52 | |
53 def code_block(name, arguments, options, content, lineno, | |
54 content_offset, block_text, state, state_machine): | |
55 lexer = get_lexer_by_name(arguments[0]) | |
56 html = highlight('\n'.join(content), lexer, HtmlFormatter()) | |
57 return [raw('', html, format='html')] | |
58 code_block.arguments = (1, 0, 0) | |
59 code_block.options = {'language' : rst.directives.unchanged} | |
60 code_block.content = 1 | |
61 rst.directives.register_directive('code-block', code_block) | |
62 except ImportError: | |
63 print 'Pygments not installed, syntax highlighting disabled' | |
64 | |
1 | 65 for source in glob('doc/*.txt'): |
66 dest = os.path.splitext(source)[0] + '.html' | |
67 if not os.path.exists(dest) or \ | |
68 os.path.getmtime(dest) < os.path.getmtime(source): | |
69 print 'building documentation file %s' % dest | |
70 publish_cmdline(writer_name='html', | |
71 argv=['--config=%s' % docutils_conf, source, | |
72 dest]) | |
73 | |
98
f5cfd37ec37e
Add `--without-apidocs` switch to `build_doc` command for quicker doc-edit/review cycles.
cmlenz
parents:
57
diff
changeset
|
74 if not self.without_apidocs: |
f5cfd37ec37e
Add `--without-apidocs` switch to `build_doc` command for quicker doc-edit/review cycles.
cmlenz
parents:
57
diff
changeset
|
75 try: |
f5cfd37ec37e
Add `--without-apidocs` switch to `build_doc` command for quicker doc-edit/review cycles.
cmlenz
parents:
57
diff
changeset
|
76 from epydoc import cli |
f5cfd37ec37e
Add `--without-apidocs` switch to `build_doc` command for quicker doc-edit/review cycles.
cmlenz
parents:
57
diff
changeset
|
77 old_argv = sys.argv[1:] |
f5cfd37ec37e
Add `--without-apidocs` switch to `build_doc` command for quicker doc-edit/review cycles.
cmlenz
parents:
57
diff
changeset
|
78 sys.argv[1:] = [ |
f5cfd37ec37e
Add `--without-apidocs` switch to `build_doc` command for quicker doc-edit/review cycles.
cmlenz
parents:
57
diff
changeset
|
79 '--config=%s' % epydoc_conf, |
f5cfd37ec37e
Add `--without-apidocs` switch to `build_doc` command for quicker doc-edit/review cycles.
cmlenz
parents:
57
diff
changeset
|
80 '--no-private', # epydoc bug, not read from config |
f5cfd37ec37e
Add `--without-apidocs` switch to `build_doc` command for quicker doc-edit/review cycles.
cmlenz
parents:
57
diff
changeset
|
81 '--simple-term', |
f5cfd37ec37e
Add `--without-apidocs` switch to `build_doc` command for quicker doc-edit/review cycles.
cmlenz
parents:
57
diff
changeset
|
82 '--verbose' |
f5cfd37ec37e
Add `--without-apidocs` switch to `build_doc` command for quicker doc-edit/review cycles.
cmlenz
parents:
57
diff
changeset
|
83 ] |
f5cfd37ec37e
Add `--without-apidocs` switch to `build_doc` command for quicker doc-edit/review cycles.
cmlenz
parents:
57
diff
changeset
|
84 cli.cli() |
f5cfd37ec37e
Add `--without-apidocs` switch to `build_doc` command for quicker doc-edit/review cycles.
cmlenz
parents:
57
diff
changeset
|
85 sys.argv[1:] = old_argv |
1 | 86 |
98
f5cfd37ec37e
Add `--without-apidocs` switch to `build_doc` command for quicker doc-edit/review cycles.
cmlenz
parents:
57
diff
changeset
|
87 except ImportError: |
f5cfd37ec37e
Add `--without-apidocs` switch to `build_doc` command for quicker doc-edit/review cycles.
cmlenz
parents:
57
diff
changeset
|
88 print 'epydoc not installed, skipping API documentation.' |
1 | 89 |
90 | |
91 class test_doc(Command): | |
92 description = 'Tests the code examples in the documentation' | |
93 user_options = [] | |
94 | |
95 def initialize_options(self): | |
96 pass | |
97 | |
98 def finalize_options(self): | |
99 pass | |
100 | |
101 def run(self): | |
102 for filename in glob('doc/*.txt'): | |
103 print 'testing documentation file %s' % filename | |
104 doctest.testfile(filename, False, optionflags=doctest.ELLIPSIS) | |
105 | |
106 | |
107 setup( | |
108 name = 'Babel', | |
109 version = '0.1', | |
110 description = 'Internationalization utilities', | |
111 long_description = \ | |
112 """A collection of tools for internationalizing Python applications.""", | |
113 author = 'Edgewall Software', | |
114 author_email = 'info@edgewall.org', | |
115 license = 'BSD', | |
116 url = 'http://babel.edgewall.org/', | |
117 download_url = 'http://babel.edgewall.org/wiki/Download', | |
118 zip_safe = False, | |
119 | |
120 classifiers = [ | |
121 'Development Status :: 4 - Beta', | |
122 'Environment :: Web Environment', | |
123 'Intended Audience :: Developers', | |
124 'License :: OSI Approved :: BSD License', | |
125 'Operating System :: OS Independent', | |
126 'Programming Language :: Python', | |
127 'Topic :: Software Development :: Libraries :: Python Modules', | |
128 ], | |
54
7dbcbc3f07e0
Rename the `babel.catalog` package to `babel.messages` for consistency with the other package names.
cmlenz
parents:
52
diff
changeset
|
129 packages = ['babel', 'babel.messages'], |
1 | 130 package_data = {'babel': ['localedata/*.dat']}, |
131 test_suite = 'babel.tests.suite', | |
132 | |
133 entry_points = """ | |
134 [console_scripts] | |
54
7dbcbc3f07e0
Rename the `babel.catalog` package to `babel.messages` for consistency with the other package names.
cmlenz
parents:
52
diff
changeset
|
135 babel = babel.messages.frontend:main |
1 | 136 |
137 [distutils.commands] | |
54
7dbcbc3f07e0
Rename the `babel.catalog` package to `babel.messages` for consistency with the other package names.
cmlenz
parents:
52
diff
changeset
|
138 extract_messages = babel.messages.frontend:extract_messages |
7dbcbc3f07e0
Rename the `babel.catalog` package to `babel.messages` for consistency with the other package names.
cmlenz
parents:
52
diff
changeset
|
139 new_catalog = babel.messages.frontend:new_catalog |
1 | 140 |
49
37bd476dafe4
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
141 [distutils.setup_keywords] |
54
7dbcbc3f07e0
Rename the `babel.catalog` package to `babel.messages` for consistency with the other package names.
cmlenz
parents:
52
diff
changeset
|
142 message_extractors = babel.messages.frontend:check_message_extractors |
49
37bd476dafe4
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
143 |
1 | 144 [babel.extractors] |
54
7dbcbc3f07e0
Rename the `babel.catalog` package to `babel.messages` for consistency with the other package names.
cmlenz
parents:
52
diff
changeset
|
145 genshi = babel.messages.extract:extract_genshi |
7dbcbc3f07e0
Rename the `babel.catalog` package to `babel.messages` for consistency with the other package names.
cmlenz
parents:
52
diff
changeset
|
146 python = babel.messages.extract:extract_python |
57
d930a3dfbf3d
* The `extract_messages` distutils command now operators on configurable input directories again, instead of the complete current directory. The `input_dirs` default to the package directories.
cmlenz
parents:
54
diff
changeset
|
147 ignore = babel.messages.extract:extract_nothing |
1 | 148 """, |
149 | |
150 cmdclass = {'build_doc': build_doc, 'test_doc': test_doc} | |
151 ) |