cmlenz@3: #!/usr/bin/env python cmlenz@3: # -*- coding: utf-8 -*- cmlenz@3: # cmlenz@3: # Copyright (C) 2007 Edgewall Software cmlenz@3: # All rights reserved. cmlenz@3: # cmlenz@3: # This software is licensed as described in the file COPYING, which cmlenz@3: # you should have received as part of this distribution. The terms cmlenz@3: # are also available at http://babel.edgewall.org/wiki/License. cmlenz@3: # cmlenz@3: # This software consists of voluntary contributions made by many cmlenz@3: # individuals. For the exact contribution history, see the revision cmlenz@3: # history and logs, available at http://babel.edgewall.org/log/. cmlenz@3: cmlenz@14: from distutils.cmd import Command cmlenz@3: import doctest cmlenz@3: from glob import glob cmlenz@3: import os cmlenz@14: try: cmlenz@14: from setuptools import setup cmlenz@14: except ImportError: cmlenz@14: from distutils.core import setup cmlenz@3: import sys cmlenz@3: cmlenz@3: cmlenz@3: class build_doc(Command): cmlenz@3: description = 'Builds the documentation' cmlenz@100: user_options = [ cmlenz@118: ('force', None, cmlenz@118: "force regeneration even if no reStructuredText files have changed"), cmlenz@100: ('without-apidocs', None, cmlenz@100: "whether to skip the generation of API documentaton"), cmlenz@100: ] cmlenz@118: boolean_options = ['force', 'without-apidocs'] cmlenz@3: cmlenz@3: def initialize_options(self): cmlenz@118: self.force = False cmlenz@100: self.without_apidocs = False cmlenz@3: cmlenz@3: def finalize_options(self): cmlenz@3: pass cmlenz@3: cmlenz@3: def run(self): cmlenz@3: from docutils.core import publish_cmdline cmlenz@42: from docutils.nodes import raw cmlenz@42: from docutils.parsers import rst cmlenz@42: cmlenz@118: docutils_conf = os.path.join('doc', 'conf', 'docutils.ini') cmlenz@118: epydoc_conf = os.path.join('doc', 'conf', 'epydoc.ini') cmlenz@3: cmlenz@42: try: cmlenz@42: from pygments import highlight cmlenz@42: from pygments.lexers import get_lexer_by_name cmlenz@42: from pygments.formatters import HtmlFormatter cmlenz@42: cmlenz@42: def code_block(name, arguments, options, content, lineno, cmlenz@42: content_offset, block_text, state, state_machine): cmlenz@42: lexer = get_lexer_by_name(arguments[0]) cmlenz@42: html = highlight('\n'.join(content), lexer, HtmlFormatter()) cmlenz@42: return [raw('', html, format='html')] cmlenz@42: code_block.arguments = (1, 0, 0) cmlenz@42: code_block.options = {'language' : rst.directives.unchanged} cmlenz@42: code_block.content = 1 cmlenz@42: rst.directives.register_directive('code-block', code_block) cmlenz@42: except ImportError: cmlenz@42: print 'Pygments not installed, syntax highlighting disabled' cmlenz@42: cmlenz@3: for source in glob('doc/*.txt'): cmlenz@3: dest = os.path.splitext(source)[0] + '.html' cmlenz@118: if self.force or not os.path.exists(dest) or \ cmlenz@118: os.path.getmtime(dest) < os.path.getmtime(source): cmlenz@3: print 'building documentation file %s' % dest cmlenz@3: publish_cmdline(writer_name='html', cmlenz@3: argv=['--config=%s' % docutils_conf, source, cmlenz@3: dest]) cmlenz@3: cmlenz@100: if not self.without_apidocs: cmlenz@100: try: cmlenz@100: from epydoc import cli cmlenz@100: old_argv = sys.argv[1:] cmlenz@100: sys.argv[1:] = [ cmlenz@100: '--config=%s' % epydoc_conf, cmlenz@100: '--no-private', # epydoc bug, not read from config cmlenz@100: '--simple-term', cmlenz@100: '--verbose' cmlenz@100: ] cmlenz@100: cli.cli() cmlenz@100: sys.argv[1:] = old_argv cmlenz@3: cmlenz@100: except ImportError: cmlenz@100: print 'epydoc not installed, skipping API documentation.' cmlenz@3: cmlenz@3: cmlenz@3: class test_doc(Command): cmlenz@3: description = 'Tests the code examples in the documentation' cmlenz@3: user_options = [] cmlenz@3: cmlenz@3: def initialize_options(self): cmlenz@3: pass cmlenz@3: cmlenz@3: def finalize_options(self): cmlenz@3: pass cmlenz@3: cmlenz@3: def run(self): cmlenz@3: for filename in glob('doc/*.txt'): cmlenz@3: print 'testing documentation file %s' % filename cmlenz@3: doctest.testfile(filename, False, optionflags=doctest.ELLIPSIS) cmlenz@3: cmlenz@3: cmlenz@3: setup( cmlenz@3: name = 'Babel', cmlenz@143: version = '0.9', cmlenz@3: description = 'Internationalization utilities', cmlenz@3: long_description = \ cmlenz@3: """A collection of tools for internationalizing Python applications.""", cmlenz@3: author = 'Edgewall Software', cmlenz@3: author_email = 'info@edgewall.org', cmlenz@3: license = 'BSD', cmlenz@3: url = 'http://babel.edgewall.org/', cmlenz@3: download_url = 'http://babel.edgewall.org/wiki/Download', cmlenz@3: zip_safe = False, cmlenz@3: cmlenz@3: classifiers = [ cmlenz@3: 'Development Status :: 4 - Beta', cmlenz@3: 'Environment :: Web Environment', cmlenz@3: 'Intended Audience :: Developers', cmlenz@3: 'License :: OSI Approved :: BSD License', cmlenz@3: 'Operating System :: OS Independent', cmlenz@3: 'Programming Language :: Python', cmlenz@3: 'Topic :: Software Development :: Libraries :: Python Modules', cmlenz@3: ], cmlenz@56: packages = ['babel', 'babel.messages'], cmlenz@3: package_data = {'babel': ['localedata/*.dat']}, cmlenz@3: test_suite = 'babel.tests.suite', cmlenz@3: cmlenz@3: entry_points = """ cmlenz@3: [console_scripts] cmlenz@191: pybabel = babel.messages.frontend:main cmlenz@3: cmlenz@3: [distutils.commands] cmlenz@162: compile_catalog = babel.messages.frontend:compile_catalog cmlenz@56: extract_messages = babel.messages.frontend:extract_messages cmlenz@183: init_catalog = babel.messages.frontend:init_catalog cmlenz@183: update_catalog = babel.messages.frontend:update_catalog cmlenz@3: cmlenz@51: [distutils.setup_keywords] cmlenz@56: message_extractors = babel.messages.frontend:check_message_extractors cmlenz@51: cmlenz@3: [babel.extractors] cmlenz@140: ignore = babel.messages.extract:extract_nothing cmlenz@56: python = babel.messages.extract:extract_python cmlenz@3: """, cmlenz@3: cmlenz@3: cmdclass = {'build_doc': build_doc, 'test_doc': test_doc} cmlenz@3: )