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