Matt Williams avatar Matt Williams committed c6403ab Merge

Merge changes

Comments (0)

Files changed (56)

 
 syntax: glob
 */distribute-*.tar.gz
+.tox/
 08054161d9948b0699728ed666615eab55737db7 ansi-0.4.1
 97e5a39971671dd8c89e64c4f3b08a67b88d9d0b issuetracker-0.5
 fb4622a05ec346617e1b2a48081f7a04308c0f73 doxylink-0.1
+64706e5cf5b21c3161cf74fbaa8128811d582d5e issuetracker-0.5.1
+9be29ec83802014e5fab72730c493ddf54dee26c programoutput-0.4
+a4498fcaf56502fbdfef12a41f7bb93cefbbdeb3 ansi-0.5
+9ccb32d8f5ea45d3366c43a176fde120da1031e9 ansi-0.5.1
 
 ansi:
    Sebastian Wiesner <lunaryorn@googlemail.com>
+
+programoutput:
+   Sebastian Wiesner <lunaryorn@googlemail.com>
+
+cheeseshop:
+   Richard Jones <r1chardj0n3s@gmail.com>
+   Georg Brandl <georg@python.org>
 - pyqt4: markup for PyQt4 signals
 - doxylink: Link to external Doxygen-generated HTML documentation
 - ansi: parse ANSI color sequences inside documents
+- cheeseshop: easily link to PyPI packages
+- programoutput: include output of programs into documentation
 
 .. _aafigure: http://docutils.sourceforge.net/sandbox/aafigure/
 

Empty file added.

_template/setup.py

 requires = ['Sphinx>=0.6']
 
 setup(
-    name='${name}',
+    name='sphinxcontrib-${name}',
     version='0.1',
     url='http://bitbucket.org/birkenfeld/sphinx-contrib',
-    download_url='http://pypi.python.org/pypi/${name}',
+    download_url='http://pypi.python.org/pypi/sphinxcontrib-${name}',
     license='BSD',
     author='${author}',
     author_email='${author_email}',
-    description='Sphinx extension ${name}',
+    description='Sphinx "${name}" extension',
     long_description=long_desc,
     zip_safe=False,
     classifiers=[

_template/tox.ini

+## configuration for tox <http://codespeak.net/tox/>
+
+## tox automates running certain tasks within virtualenvs.  The following
+## tox configuration outlines a basic setup for running unit tests and
+## building sphinx docs in separate virtual environments.  Give it a try!
+
+[tox]
+envlist=python,doc
+
+# test running
+[testenv:python]
+deps=
+    ## if you use nose for test running
+    # nose
+    ## if you use py.test for test running
+    # py
+commands=
+    ## run tests with py.test
+    # py.test []
+    ## run tests with nose
+    # nose
+
+[testenv:doc]
+deps=
+    sphinx
+    # add all Sphinx extensions and other dependencies required to build your docs
+commands=
+    ## test links
+    # sphinx-build -W -b linkcheck -d {envtmpdir}/doctrees doc {envtmpdir}/linkcheck
+    ## test html output
+    # sphinx-build -W -b html -d {envtmpdir}/doctrees doc {envtmpdir}/html
+
+0.5.1 (Jul 26, 2010)
+====================
+
+- Fixed wrong ordering with nested colors
+
+
+0.5 (Jul 25, 2010)
+==================
+
+- Ignore colors in non-html output
+
+
 0.4.1 (Jul 21, 2010)
 ====================
 
 include README
 include LICENSE
 include CHANGES.*
+include test_ansi.py
 recursive-include sphinxcontrib *.css
 recursive-include doc *.rst *.py Makefile
 prune doc/_build
 # -*- coding: utf-8 -*-
-#
-# sphinxcontrib-ansi documentation build configuration file, created by
-# sphinx-quickstart on Sun Jul 18 18:20:39 2010.
-#
-# This file is execfile()d with the current directory set to its containing dir.
-#
-# Note that not all possible configuration values are present in this
-# autogenerated file.
-#
-# All configuration values have a default; values that are commented out
-# serve to show the default.
 
 import sys, os
 
-# If extensions (or modules to document with autodoc) are in another directory,
-# add these directories to sys.path here. If the directory is relative to the
-# documentation root, use os.path.abspath to make it absolute, like shown here.
-#sys.path.insert(0, os.path.abspath('.'))
+needs_sphinx = '1.0'
 
-# -- General configuration -----------------------------------------------------
-
-# If your documentation needs a minimal Sphinx version, state it here.
-#needs_sphinx = '1.0'
-
-# Add any Sphinx extension module names here, as strings. They can be extensions
-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.intersphinx', 'sphinxcontrib.issuetracker']
 
-# Add any paths that contain templates here, relative to this directory.
-templates_path = ['_templates']
-
-# The suffix of source filenames.
 source_suffix = '.rst'
-
-# The encoding of source files.
-#source_encoding = 'utf-8-sig'
-
-# The master toctree document.
 master_doc = 'index'
 
-# General information about the project.
 project = u'sphinxcontrib-ansi'
 copyright = u'2010, Sebastian Wiesner'
+version = '0.5'
+release = '0.5.1'
 
-# The version info for the project you're documenting, acts as replacement for
-# |version| and |release|, also used in various other places throughout the
-# built documents.
-#
-# The short X.Y version.
-version = '0.4'
-# The full version, including alpha/beta/rc tags.
-release = '0.4.1'
-
-# The language for content autogenerated by Sphinx. Refer to documentation
-# for a list of supported languages.
-#language = None
-
-# There are two options for replacing |today|: either, you set today to some
-# non-false value, then it is used:
-#today = ''
-# Else, today_fmt is used as the format for a strftime call.
-#today_fmt = '%B %d, %Y'
-
-# List of patterns, relative to source directory, that match files and
-# directories to ignore when looking for source files.
 exclude_patterns = ['_build']
 
-# The reST default role (used for this markup: `text`) to use for all documents.
-#default_role = None
+html_theme = 'default'
+html_static_path = []
 
-# If true, '()' will be appended to :func: etc. cross-reference text.
-#add_function_parentheses = True
+intersphinx_mapping = {'python': ('http://docs.python.org/', None),
+                       'sphinx': ('http://sphinx.pocoo.org/', None)}
 
-# If true, the current module name will be prepended to all description
-# unit titles (such as .. function::).
-#add_module_names = True
-
-# If true, sectionauthor and moduleauthor directives will be shown in the
-# output. They are ignored by default.
-#show_authors = False
-
-# The name of the Pygments (syntax highlighting) style to use.
-pygments_style = 'sphinx'
-
-# A list of ignored prefixes for module index sorting.
-#modindex_common_prefix = []
-
-
-# -- Options for HTML output ---------------------------------------------------
-
-# The theme to use for HTML and HTML Help pages.  See the documentation for
-# a list of builtin themes.
-html_theme = 'default'
-
-# Theme options are theme-specific and customize the look and feel of a theme
-# further.  For a list of options available for each theme, see the
-# documentation.
-#html_theme_options = {}
-
-# Add any paths that contain custom themes here, relative to this directory.
-#html_theme_path = []
-
-# The name for this set of Sphinx documents.  If None, it defaults to
-# "<project> v<release> documentation".
-#html_title = None
-
-# A shorter title for the navigation bar.  Default is the same as html_title.
-#html_short_title = None
-
-# The name of an image file (relative to this directory) to place at the top
-# of the sidebar.
-#html_logo = None
-
-# The name of an image file (within the static path) to use as favicon of the
-# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
-# pixels large.
-#html_favicon = None
-
-# Add any paths that contain custom static files (such as style sheets) here,
-# relative to this directory. They are copied after the builtin static files,
-# so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = ['_static']
-
-# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
-# using the given strftime format.
-#html_last_updated_fmt = '%b %d, %Y'
-
-# If true, SmartyPants will be used to convert quotes and dashes to
-# typographically correct entities.
-#html_use_smartypants = True
-
-# Custom sidebar templates, maps document names to template names.
-#html_sidebars = {}
-
-# Additional templates that should be rendered to pages, maps page names to
-# template names.
-#html_additional_pages = {}
-
-# If false, no module index is generated.
-#html_domain_indices = True
-
-# If false, no index is generated.
-#html_use_index = True
-
-# If true, the index is split into individual pages for each letter.
-#html_split_index = False
-
-# If true, links to the reST sources are added to the pages.
-#html_show_sourcelink = True
-
-# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
-#html_show_sphinx = True
-
-# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
-#html_show_copyright = True
-
-# If true, an OpenSearch description file will be output, and all pages will
-# contain a <link> tag referring to it.  The value of this option must be the
-# base URL from which the finished HTML is served.
-#html_use_opensearch = ''
-
-# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
-#html_file_suffix = ''
-
-# Output file base name for HTML help builder.
-htmlhelp_basename = 'sphinxcontrib-ansidoc'
-
-
-# -- Options for LaTeX output --------------------------------------------------
-
-# The paper size ('letter' or 'a4').
-#latex_paper_size = 'letter'
-
-# The font size ('10pt', '11pt' or '12pt').
-#latex_font_size = '10pt'
-
-# Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title, author, documentclass [howto/manual]).
-latex_documents = [
-  ('index', 'sphinxcontrib-ansi.tex', u'sphinxcontrib-ansi Documentation',
-   u'Sebastian Wiesner', 'manual'),
-]
-
-# The name of an image file (relative to this directory) to place at the top of
-# the title page.
-#latex_logo = None
-
-# For "manual" documents, if this is true, then toplevel headings are parts,
-# not chapters.
-#latex_use_parts = False
-
-# If true, show page references after internal links.
-#latex_show_pagerefs = False
-
-# If true, show URL addresses after external links.
-#latex_show_urls = False
-
-# Additional stuff for the LaTeX preamble.
-#latex_preamble = ''
-
-# Documents to append as an appendix to all manuals.
-#latex_appendices = []
-
-# If false, no module index is generated.
-#latex_domain_indices = True
-
-
-# -- Options for manual page output --------------------------------------------
-
-# One entry per manual page. List of tuples
-# (source start file, name, description, authors, manual section).
-man_pages = [
-    ('index', 'sphinxcontrib-ansi', u'sphinxcontrib-ansi Documentation',
-     [u'Sebastian Wiesner'], 1)
-]
-
-
-# Example configuration for intersphinx: refer to the Python standard library.
-intersphinx_mapping = {'http://docs.python.org/': None,
-                       'http://sphinx.pocoo.org/latest/': None,}
-
-# issue tracker settings
 issuetracker = 'bitbucket'
 issuetracker_user = 'birkenfeld'
 issuetracker_project = 'sphinx-contrib'

ansi/doc/index.rst

 .. highlight:: rest
 .. default-domain:: rst
 
-:py:mod:`lunar.sphinx.ext.ansi` -- Parse ANSI control sequences
-===============================================================
+:py:mod:`sphinxcontrib.ansi` -- Parse ANSI control sequences
+============================================================
 
-.. py:module:: lunar.sphinx.ext.ansi
+.. py:module:: sphinxcontrib.ansi
    :synopsis:  Parse and interpret ANSI control sequences
 
 This extension for Sphinx_ 1.0 converts ANSI colour sequences to colored
 .. directive:: ansi-block
 
    This directive interprets its content as literal block containing ANSI
-   control sequences for coloured output.
+   control sequences for coloured output for HTML output.  If the document
+   is build with any other builder than ``html``, color sequences are
+   stripped from output.
 
    If the option ``string_escape`` is specified, the content of the
    directive is decoded using the ``string_escape`` codec.  Thus you can
 Contribution
 ------------
 
-Please contact the author or create an issue in the issue tracker of the
+Please contact the author or create an issue in the `issue tracker`_ of the
 sphinx-contrib_ repository, if you have found any bugs or miss some
 functionality (e.g. integration of some other issue tracker).  Patches are
 welcome!
    changes.rst
 
 
-.. _`Sphinx`: http://sphinx.pocoo.org/latest
+.. _`Sphinx`: http://sphinx.pocoo.org/
 .. _`sphinx-contrib`: http://bitbucket.org/birkenfeld/sphinx-contrib
 .. _`issue tracker`: http://bitbucket.org/birkenfeld/sphinx-contrib/issues
 .. _`black-on-white.css`: http://bitbucket.org/birkenfeld/sphinx-contrib/src/tip/ansi/sphinxcontrib/black-on-white.css
 
 setup(
     name='sphinxcontrib-ansi',
-    version='0.4.1',
+    version='0.5.1',
     url='http://bitbucket.org/birkenfeld/sphinx-contrib',
     download_url='http://pypi.python.org/pypi/ansi',
     license='BSD',

ansi/sphinxcontrib/ansi.py

 
         Pending nodes will be append to the new nodes.
         """
-        while self.pending_nodes:
-            self.new_nodes.append(self.pending_nodes.pop())
+        self.new_nodes.extend(self.pending_nodes)
+        self.pending_nodes = []
 
     def _add_text(self, text):
         """
             else:
                 self.new_nodes.append(nodes.Text(text))
 
+    def _colorize_block_contents(self, block):
+        raw = block.rawsource
+        # create the "super" node, which contains to while block and all it
+        # sub nodes, and replace the old block with it
+        literal_node = nodes.literal_block()
+        literal_node['classes'].append('ansi-block')
+        block.replace_self(literal_node)
+
+        # this contains "pending" nodes.  A node representing an ANSI
+        # color is "pending", if it has not yet seen a reset
+        self.pending_nodes = []
+        # these are the nodes, that will finally be added to the
+        # literal_node
+        self.new_nodes = []
+        # this holds the end of the last regex match
+        last_end = 0
+        # iterate over all color codes
+        for match in COLOR_PATTERN.finditer(raw):
+            # add any text preceeding this match
+            head = raw[last_end:match.start()]
+            self._add_text(head)
+            # update the match end
+            last_end = match.end()
+            # get the single format codes
+            codes = [int(c) for c in match.group(1).split(';')]
+            if codes[-1] == 0:
+                # the last code is a reset, so finalize all pending
+                # nodes.
+                self._finalize_pending_nodes()
+            else:
+                # create a new color node
+                code_node = nodes.inline()
+                self.pending_nodes.append(code_node)
+                # and set the classes for its colors
+                for code in codes:
+                    code_node['classes'].append(
+                        'ansi-%s' % CODE_CLASS_MAP[code])
+        # add any trailing text
+        tail = raw[last_end:]
+        self._add_text(tail)
+        # move all pending nodes to new_nodes
+        self._finalize_pending_nodes()
+        # and add the new nodes to the block
+        literal_node.extend(self.new_nodes)
+
+    def _strip_color_from_block_content(self, block):
+        content = COLOR_PATTERN.sub('', block.rawsource)
+        literal_node = nodes.literal_block(content, content)
+        block.replace_self(literal_node)
+
     def __call__(self, app, doctree, docname):
         """
         Extract and parse all ansi escapes in ansi_literal_block nodes.
         """
+        handler = self._colorize_block_contents
+        if app.builder.name != 'html':
+            # strip all color codes in non-html output
+            handler = self._strip_color_from_block_content
         for ansi_block in doctree.traverse(ansi_literal_block):
-            raw = ansi_block.rawsource
-            # create the "super" node, which contains to while block and all
-            # it sub nodes, and replace the old block with it
-            literal_node = nodes.literal_block()
-            literal_node['classes'].append('ansi-block')
-            ansi_block.replace_self(literal_node)
-
-            # this contains "pending" nodes.  A node representing an ANSI
-            # color is "pending", if it has not yet seen a reset
-            self.pending_nodes = []
-            # these are the nodes, that will finally be added to the
-            # literal_node
-            self.new_nodes = []
-            # this holds the end of the last regex match
-            last_end = 0
-            # iterate over all color codes
-            for match in COLOR_PATTERN.finditer(raw):
-                # add any text preceeding this match
-                head = raw[last_end:match.start()]
-                self._add_text(head)
-                # update the match end
-                last_end = match.end()
-                # get the single format codes
-                codes = [int(c) for c in match.group(1).split(';')]
-                if codes[-1] == 0:
-                    # the last code is a reset, so finalize all pending
-                    # nodes.
-                    self._finalize_pending_nodes()
-                else:
-                    # create a new color node
-                    code_node = nodes.inline()
-                    self.pending_nodes.append(code_node)
-                    # and set the classes for its colors
-                    for code in codes:
-                        code_node['classes'].append(
-                            'ansi-%s' % CODE_CLASS_MAP[code])
-            # add any trailing text
-            tail = raw[last_end:]
-            self._add_text(tail)
-            # move all pending nodes to new_nodes
-            self._finalize_pending_nodes()
-            # and add the new nodes to the block
-            literal_node.extend(self.new_nodes)
+            handler(ansi_block)
 
 
 def add_stylesheet(app):

ansi/test_ansi.py

+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from docutils import nodes
+from mock import Mock
+
+from sphinxcontrib import ansi
+
+
+RAWSOURCE = '''\
+\x1b[1mfoo\x1b[33;1mbar\x1b[1;34mhello\x1b[0mworld\x1b[1m'''
+
+
+def pytest_funcarg__paragraph(request):
+    paragraph = nodes.paragraph()
+    paragraph.append(ansi.ansi_literal_block(RAWSOURCE, RAWSOURCE))
+    return paragraph
+
+
+def pytest_funcarg__app(request):
+    return Mock()
+
+
+def pytest_funcarg__parser(request):
+    return ansi.ANSIColorParser()
+
+
+def _assert_colors(node, *colors):
+    assert isinstance(node, nodes.inline)
+    for color in colors:
+        assert ('ansi-%s' % color) in node['classes']
+
+
+def _assert_text(node, text):
+    assert isinstance(node, nodes.Text)
+    assert node.astext() == text
+
+
+def test_parser_strip_colors(app, parser, paragraph):
+    app.builder.name = 'foo'
+    parser(app, paragraph, 'foo')
+    assert isinstance(paragraph[0], nodes.literal_block)
+    _assert_text(paragraph[0][0], 'foobarhelloworld')
+    assert not paragraph[0][0].children
+    assert paragraph.astext() == 'foobarhelloworld'
+
+
+def test_parser_colors_parsed(app, parser, paragraph):
+    app.builder.name = 'html'
+    parser(app, paragraph, 'foo')
+    block = paragraph[0]
+    assert isinstance(block, nodes.literal_block)
+    _assert_colors(block[0], 'bold')
+    _assert_text(block[0][0], 'foo')
+    _assert_colors(block[1], 'bold', 'yellow')
+    _assert_text(block[1][0], 'bar')
+    _assert_colors(block[2], 'bold', 'blue')
+    _assert_text(block[2][0], 'hello')
+    _assert_text(block[3], 'world')
+    _assert_colors(block[4], 'bold')
+    assert not block[4].children
+    assert paragraph.astext() == 'foobarhelloworld'
+
+
+def test_setup(app):
+    ansi.setup(app)
+    app.require_sphinx.assert_called_with('1.0')
+    app.add_config_value.assert_called_with(
+        'html_ansi_stylesheet', None, 'env')
+    app.add_directive.assert_called_with(
+        'ansi-block', ansi.ANSIBlockDirective)
+    assert app.connect.call_args_list[:2] == [
+        (('builder-inited', ansi.add_stylesheet),),
+        (('build-finished', ansi.copy_stylesheet),)]
+    assert app.connect.call_args_list[2][0][0] == 'doctree-resolved'
+    assert isinstance(app.connect.call_args_list[2][0][1],
+                      ansi.ANSIColorParser)
+
+
+def main():
+    import py
+    py.cmdline.pytest()
+
+
+if __name__ == '__main__':
+    main()
+[tox]
+envlist=du06,du05,doc
+
+[testenv:du05]
+deps=
+    docutils==0.5
+    mock
+    py
+commands=
+    py.test --junitxml={envlogdir}/tests.xml []
+
+[testenv:du06]
+deps=
+    docutils==0.6
+    mock
+    py
+commands=
+    py.test --junitxml={envlogdir}/tests.xml []
+
+[testenv:doc]
+deps=
+    sphinx
+    lxml
+    sphinxcontrib-issuetracker
+commands=
+    sphinx-build -W -b linkcheck -d {envtmpdir}/doctrees doc {envtmpdir}/linkcheck
+    sphinx-build -W -b html -d {envtmpdir}/doctrees doc {envtmpdir}/html

cheeseshop/CHANGES

+Release 0.2
+===========
+
+* Allow giving a CSS class for the ``pypi-release`` directive.
+* Allow giving versions and explicit titles for the ``pypi`` role.
+* Add some documentation.
+
+
+Release 0.1
+===========
+
+* Initial release.

cheeseshop/MANIFEST.in

+include README
+include LICENSE
+include CHANGES.*

cheeseshop/README

+================================
+The Cheese Shop Sphinx extension
+================================
+
+   Ah! We do have some Camembert, sir...
+
+This extension adds directives for easy linking to Cheese Shop (Python Package
+Index) packages.  It requires Sphinx 1.0.
+
+   It's a bit runny, sir...
+
+It supports a directive and a role, as well as a new config value.
+
+   Well, as a matter of fact it's very runny, sir...
+
+The ``pypi-release`` directive adds an HTML-only output block that automatically
+fetches the download links for the latest release of the given package and
+displays them as a list.  For example, ::
+
+   .. pypi-release:: Sphinx
+      :prefix: Download
+      :class: sidebar
+
+will display "Download:" and a list of download links (eggs and the source
+distribution) for the latest Sphinx release.  The "sidebar" class makes the
+resulting ``<div>`` appear like a reStructuredText sidebar.  Using "prefix", you
+can select what text precedes the list.
+
+   I think it's runnier than you like it, sir...
+
+The ``pypi`` role links to a package.  Use it in one of these forms::
+
+   :pypi:`Sphinx`  -- link to latest release
+   :pypi:`the Sphinx package <Sphinx>`  -- dito, but explicit title given
+   :pypi:`Sphinx (0.6)`  -- link to specific release
+   :pypi:`the Sphinx package <Sphinx (0.6)>`  -- dito, with explicit title
+
+This extension also adds a ``cheeseshop_url`` config value, which defaults to
+``'http://pypi.python.org/pypi'`` and is used to build URLs to the Cheese Shop.
+
+Have fun!
+
+   Oh... The cat's eaten it.

cheeseshop/setup.cfg

+[egg_info]
+tag_build = dev
+tag_date = true
+
+[aliases]
+release = egg_info -RDb ''

cheeseshop/setup.py

+# -*- coding: utf-8 -*-
+
+from setuptools import setup, find_packages
+
+long_desc = file('README', 'r').read()
+
+requires = ['Sphinx>=1.0']
+
+setup(
+    name='sphinxcontrib-cheeseshop',
+    version='0.2',
+    url='http://bitbucket.org/birkenfeld/sphinx-contrib',
+    download_url='http://pypi.python.org/pypi/sphinxcontrib-cheeseshop',
+    license='BSD',
+    author='Richard Jones, Georg Brandl',
+    author_email='georg@python.org',
+    description='Sphinx extension cheeseshop',
+    long_description=long_desc,
+    zip_safe=False,
+    classifiers=[
+        'Development Status :: 4 - Beta',
+        'Environment :: Console',
+        'Environment :: Web Environment',
+        'Intended Audience :: Developers',
+        'License :: OSI Approved :: BSD License',
+        'Operating System :: OS Independent',
+        'Programming Language :: Python',
+        'Topic :: Documentation',
+        'Topic :: Utilities',
+    ],
+    platforms='any',
+    packages=find_packages(),
+    include_package_data=True,
+    install_requires=requires,
+    namespace_packages=['sphinxcontrib'],
+)

cheeseshop/sphinxcontrib/__init__.py

+# -*- coding: utf-8 -*-
+"""
+    sphinxcontrib
+    ~~~~~~~~~~~~~
+
+    This package is a namespace package that contains all extensions
+    distributed in the ``sphinx-contrib`` distribution.
+
+    :copyright: Copyright 2007-2009 by the Sphinx team, see AUTHORS.
+    :license: BSD, see LICENSE for details.
+"""
+
+__import__('pkg_resources').declare_namespace(__name__)
+

cheeseshop/sphinxcontrib/cheeseshop.py

+# -*- coding: utf-8 -*-
+"""
+    sphinxcontrib.cheeseshop
+    ~~~~~~~~~~~~~~~~~~~~~~~~
+
+    :copyright: Copyright 2010 by Richard Jones, Georg Brandl.
+    :license: BSD, see LICENSE for details.
+"""
+
+import re
+
+from docutils import nodes, utils
+from docutils.parsers.rst import directives
+
+from sphinx.util.nodes import split_explicit_title
+from sphinx.util.compat import Directive
+
+
+RELEASE_INFO = '''\
+<div class="release_info %(class)s">%(prefix)s:
+  <a href="http://pypi.python.org/pypi/%(dist)s">latest</a></div>
+'''
+
+RELEASE_SCRIPT = '''\
+<script type="text/javascript">
+  $(function() {
+    $('.release_info').each(function() {
+      var self = this, anchor = $('a', this);
+      $.getJSON(anchor.attr('href') + '/json?callback=?', function(data) {
+        anchor.remove();
+        var ul = $('<ul>').appendTo(self);
+        $u.each(data.urls, function(url) {
+          $('<li>').append($('<a>').attr('href', url.url).text(url.filename))
+                   .appendTo(ul);
+        });
+      });
+    });
+  });
+</script>
+'''
+
+class CheeseShop(Directive):
+    """Directive for embedding "latest release" info in the form of a list of
+    release file links.
+    """
+
+    has_content = False
+    required_arguments = 1
+    optional_arguments = 0
+    final_argument_whitespace = True
+    option_spec = {
+        'prefix': directives.unchanged,
+        'class': directives.unchanged,
+    }
+
+    def run(self):
+        env = self.state.document.settings.env
+        ret = []
+        if not env.temp_data.get('cheeseshop_script_written'):
+            env.temp_data['cheeseshop_script_written'] = True
+            ret.append(nodes.raw(RELEASE_SCRIPT, RELEASE_SCRIPT, format='html'))
+        dist = self.arguments[0]
+        prefix = self.options.get('prefix') or 'Download'
+        class_ = self.options.get('class') or ''
+        html = RELEASE_INFO % {'dist': dist, 'prefix': prefix, 'class': class_}
+        ret.append(nodes.raw(html, html, format='html'))
+        return ret
+
+
+def pypi_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
+    """Role for linking to PyPI packages."""
+    env = inliner.document.settings.env
+    text = utils.unescape(text)
+    has_explicit, title, target = split_explicit_title(text)
+    m = re.match(r'(.*)\s+\((.*?)\)', target)
+    if m:
+        dist, version = m.groups()
+        url = env.config.cheeseshop_url + '/' + dist + '/' + version
+        if not has_explicit:
+            title = '%s %s' % (dist, version)
+    else:
+        url = env.config.cheeseshop_url + '/' + target
+    ref = nodes.reference(rawtext, title, refuri=url)
+    return [ref], []
+
+
+def setup(app):
+    app.require_sphinx('1.0')
+    app.add_directive('pypi-release', CheeseShop)
+    app.add_role('pypi', pypi_role)
+    app.add_config_value('cheeseshop_url',
+                         'http://pypi.python.org/pypi', 'html')

epydoc/MANIFEST.in

 include README
 include LICENSE
 include CHANGES.*
+include test_epydoc.py
 recursive-include doc *.rst *.py Makefile
 prune doc/_build

epydoc/doc/conf.py

 # -*- coding: utf-8 -*-
-#
-# sphinxcontrib-epydoc documentation build configuration file, created by
-# sphinx-quickstart on Sun Jul 11 16:34:14 2010.
-#
-# This file is execfile()d with the current directory set to its containing dir.
-#
-# Note that not all possible configuration values are present in this
-# autogenerated file.
-#
-# All configuration values have a default; values that are commented out
-# serve to show the default.
 
 import sys, os
 
-# If extensions (or modules to document with autodoc) are in another directory,
-# add these directories to sys.path here. If the directory is relative to the
-# documentation root, use os.path.abspath to make it absolute, like shown here.
-#sys.path.insert(0, os.path.abspath('.'))
+needs_sphinx = '1.0'
 
-# -- General configuration -----------------------------------------------------
-
-# If your documentation needs a minimal Sphinx version, state it here.
-#needs_sphinx = '1.0'
-
-# Add any Sphinx extension module names here, as strings. They can be extensions
-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.intersphinx']
 
-# Add any paths that contain templates here, relative to this directory.
-templates_path = ['_templates']
-
-# The suffix of source filenames.
 source_suffix = '.rst'
-
-# The encoding of source files.
-#source_encoding = 'utf-8-sig'
-
-# The master toctree document.
 master_doc = 'index'
 
-# General information about the project.
 project = u'sphinxcontrib-epydoc'
 copyright = u'2010, Sebastian Wiesner'
-
-# The version info for the project you're documenting, acts as replacement for
-# |version| and |release|, also used in various other places throughout the
-# built documents.
-#
-# The short X.Y version.
 version = '0.4'
-# The full version, including alpha/beta/rc tags.
 release = '0.4'
 
-# The language for content autogenerated by Sphinx. Refer to documentation
-# for a list of supported languages.
-#language = None
-
-# There are two options for replacing |today|: either, you set today to some
-# non-false value, then it is used:
-#today = ''
-# Else, today_fmt is used as the format for a strftime call.
-#today_fmt = '%B %d, %Y'
-
-# List of patterns, relative to source directory, that match files and
-# directories to ignore when looking for source files.
 exclude_patterns = ['_build']
 
-# The reST default role (used for this markup: `text`) to use for all documents.
-#default_role = None
+html_theme = 'default'
+html_static_path = []
 
-# If true, '()' will be appended to :func: etc. cross-reference text.
-#add_function_parentheses = True
-
-# If true, the current module name will be prepended to all description
-# unit titles (such as .. function::).
-#add_module_names = True
-
-# If true, sectionauthor and moduleauthor directives will be shown in the
-# output. They are ignored by default.
-#show_authors = False
-
-# The name of the Pygments (syntax highlighting) style to use.
-pygments_style = 'sphinx'
-
-# A list of ignored prefixes for module index sorting.
-#modindex_common_prefix = []
-
-
-# -- Options for HTML output ---------------------------------------------------
-
-# The theme to use for HTML and HTML Help pages.  See the documentation for
-# a list of builtin themes.
-html_theme = 'default'
-
-# Theme options are theme-specific and customize the look and feel of a theme
-# further.  For a list of options available for each theme, see the
-# documentation.
-#html_theme_options = {}
-
-# Add any paths that contain custom themes here, relative to this directory.
-#html_theme_path = []
-
-# The name for this set of Sphinx documents.  If None, it defaults to
-# "<project> v<release> documentation".
-#html_title = None
-
-# A shorter title for the navigation bar.  Default is the same as html_title.
-#html_short_title = None
-
-# The name of an image file (relative to this directory) to place at the top
-# of the sidebar.
-#html_logo = None
-
-# The name of an image file (within the static path) to use as favicon of the
-# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
-# pixels large.
-#html_favicon = None
-
-# Add any paths that contain custom static files (such as style sheets) here,
-# relative to this directory. They are copied after the builtin static files,
-# so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = ['_static']
-
-# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
-# using the given strftime format.
-#html_last_updated_fmt = '%b %d, %Y'
-
-# If true, SmartyPants will be used to convert quotes and dashes to
-# typographically correct entities.
-#html_use_smartypants = True
-
-# Custom sidebar templates, maps document names to template names.
-#html_sidebars = {}
-
-# Additional templates that should be rendered to pages, maps page names to
-# template names.
-#html_additional_pages = {}
-
-# If false, no module index is generated.
-#html_domain_indices = True
-
-# If false, no index is generated.
-#html_use_index = True
-
-# If true, the index is split into individual pages for each letter.
-#html_split_index = False
-
-# If true, links to the reST sources are added to the pages.
-#html_show_sourcelink = True
-
-# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
-#html_show_sphinx = True
-
-# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
-#html_show_copyright = True
-
-# If true, an OpenSearch description file will be output, and all pages will
-# contain a <link> tag referring to it.  The value of this option must be the
-# base URL from which the finished HTML is served.
-#html_use_opensearch = ''
-
-# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
-#html_file_suffix = ''
-
-# Output file base name for HTML help builder.
-htmlhelp_basename = 'sphinxcontrib-epydocdoc'
-
-
-# -- Options for LaTeX output --------------------------------------------------
-
-# The paper size ('letter' or 'a4').
-#latex_paper_size = 'letter'
-
-# The font size ('10pt', '11pt' or '12pt').
-#latex_font_size = '10pt'
-
-# Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title, author, documentclass [howto/manual]).
-latex_documents = [
-  ('index', 'sphinxcontrib-epydoc.tex', u'sphinxcontrib-epydoc Documentation',
-   u'Sebastian Wiesner', 'manual'),
-]
-
-# The name of an image file (relative to this directory) to place at the top of
-# the title page.
-#latex_logo = None
-
-# For "manual" documents, if this is true, then toplevel headings are parts,
-# not chapters.
-#latex_use_parts = False
-
-# If true, show page references after internal links.
-#latex_show_pagerefs = False
-
-# If true, show URL addresses after external links.
-#latex_show_urls = False
-
-# Additional stuff for the LaTeX preamble.
-#latex_preamble = ''
-
-# Documents to append as an appendix to all manuals.
-#latex_appendices = []
-
-# If false, no module index is generated.
-#latex_domain_indices = True
-
-
-# -- Options for manual page output --------------------------------------------
-
-# One entry per manual page. List of tuples
-# (source start file, name, description, authors, manual section).
-man_pages = [
-    ('index', 'sphinxcontrib-epydoc', u'sphinxcontrib-epydoc Documentation',
-     [u'Sebastian Wiesner'], 1)
-]
-
-
-# Example configuration for intersphinx: refer to the Python standard library.
-intersphinx_mapping = {'http://docs.python.org/': None,
-                       'http://sphinx.pocoo.org/': None}
+intersphinx_mapping = {'python': ('http://docs.python.org/', None),
+                       'sphinx': ('http://sphinx.pocoo.org/', None)}
 
 
 def setup(app):

epydoc/doc/index.rst

 .. highlight:: rest
 
-:mod:`lunar.sphinx.ext.epydoc` -- Epydoc crossreferences
-========================================================
+:mod:`sphinxcontrib.epydoc` -- Epydoc crossreferences
+=====================================================
 
-.. module:: lunar.sphinx.ext.epydoc
+.. module:: sphinxcontrib.epydoc
    :synopsis: Cross-reference epydoc documentation
 
 This extension for Sphinx_ cross-references API documentation generated by
 Contribution
 ------------
 
-Please contact the author or create an issue in the issue tracker of the
+Please contact the author or create an issue in the `issue tracker`_ of the
 sphinx-contrib_ repository, if you have found any bugs or miss some
 functionality (e.g. integration of some other issue tracker).  Patches are
 welcome!
    changes.rst
 
 
-.. _`Sphinx`: http://sphinx.pocoo.org/latest
+.. _`Sphinx`: http://sphinx.pocoo.org/
 .. _epydoc: http://epydoc.sourceforge.net/
 .. _`paludis.PackageID`: http://paludis.pioto.org/api/python/paludis.PackageID-class.html
 .. _`sphinx-contrib`: http://bitbucket.org/birkenfeld/sphinx-contrib

epydoc/sphinxcontrib/epydoc.py

 from docutils import nodes
 
 
+def filename_for_object(objtype, name):
+    if objtype == 'exception':
+        # exceptions are classes for epydoc
+        objtype = 'class'
+    if not (objtype == 'module' or objtype == 'class'):
+        name, attribute = name.rsplit('.', 1)
+        anchor = '#%s' % attribute
+        if objtype == 'function' or objtype == 'data':
+            objtype = 'module'
+        else:
+            objtype = 'class'
+    else:
+        anchor = ''
+    return '%s-%s.html%s' % (name, objtype, anchor)
+
+
 def resolve_reference_to_epydoc(app, env, node, contnode):
     """
     Resolve a reference to an epydoc documentation.
                  'cannot resolve to epydoc' % target)
         return
 
-    if objtype == 'exception':
-        # exceptions are classes for epydoc
-        objtype = 'class'
-    if not (objtype == 'module' or objtype == 'class'):
-        target, attribute = target.rsplit('.', 1)
-        anchor = '#%s' % attribute
-        if objtype == 'function' or objtype == 'data':
-            objtype = 'module'
-        else:
-            objtype = 'class'
-    else:
-        anchor = ''
-    filename = '%s-%s.html%s' % (target, objtype, anchor)
-    uri = posixpath.join(baseurl, filename)
+    uri = posixpath.join(baseurl, filename_for_object(objtype, target))
 
     newnode = nodes.reference('', '')
     newnode['class'] = 'external-xref'

epydoc/test_epydoc.py

+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from functools import partial
+
+from docutils import nodes
+from mock import Mock
+
+from sphinxcontrib import epydoc
+
+
+FILENAME_TEST_DATA = {
+    'class': {
+        'Hello': 'Hello-class.html',
+        'world.Hello': 'world.Hello-class.html',
+        },
+    'module': {
+        'hello': 'hello-module.html',
+        'hello.world': 'hello.world-module.html',
+        },
+    'function': {
+        'hello.world': 'hello-module.html#world',
+        'hello.world.say': 'hello.world-module.html#say',
+        },
+    'method': {
+        'hello.world': 'hello-class.html#world',
+        'hello.world.say': 'hello.world-class.html#say',
+        }
+    }
+
+for left, right in [('exception', 'class'), ('data', 'function'),
+                    ('attr', 'method')]:
+    FILENAME_TEST_DATA[left] = FILENAME_TEST_DATA[right]
+
+
+def pytest_generate_tests(metafunc):
+    if metafunc.function == test_filename_for_object:
+        for objtype, testcases in FILENAME_TEST_DATA.iteritems():
+            for name, expected in testcases.iteritems():
+                args = dict(objtype=objtype, name=name,
+                            expected=expected)
+                id = '%s "%s"' % (objtype, name)
+                metafunc.addcall(funcargs=args, id=id)
+
+
+def pytest_funcarg__app(request):
+    app = Mock()
+    app.config.epydoc_mapping = {
+        'http://example.com/': [r'hello\..*']}
+    return app
+
+
+def pytest_funcarg__env(request):
+    env = Mock()
+    env.domains = {'py': Mock()}
+    return env
+
+
+def pytest_funcarg__node(request):
+    node = nodes.reference(text='foo')
+    node['refdomain'] = 'py'
+    node['reftype'] = 'method'
+    node['reftarget'] = 'hello.World.say'
+    return node
+
+
+def pytest_funcarg__resolve(request):
+    app = request.getfuncargvalue('app')
+    env = request.getfuncargvalue('env')
+    node = request.getfuncargvalue('node')
+    return partial(epydoc.resolve_reference_to_epydoc, app, env,
+                   node, node[0])
+
+
+def test_filename_for_object(objtype, name, expected):
+    assert epydoc.filename_for_object(objtype, name) == expected
+
+
+def test_resolve_reference_to_epydoc_invalid_domain(resolve, node):
+    node['refdomain'] = 'foo'
+    assert resolve() is None
+
+def test_resolve_reference_to_epydoc_not_matching(resolve, node):
+    node['reftarget'] = 'foo.bar'
+    assert resolve() is None
+
+def test_resolve_reference_to_epydoc_ambiguous_objtype(
+    resolve, node, app, env):
+    env.domains['py'].objtypes_for_role.return_value = ('foo', 'bar')
+    assert resolve() is None
+    assert app.warn.called
+    app.warn.assert_called_with('ambiguous object types for %s, cannot '
+                                'resolve to epydoc' % node['reftarget'])
+
+def test_resolve_reference_to_epydoc_success(resolve, node, env):
+    env.domains['py'].objtypes_for_role.return_value = ('method',)
+    new_node = resolve()
+    uri = 'http://example.com/hello.World-class.html#say'
+    assert new_node
+    assert new_node['class'] == 'external-xref'
+    assert new_node['refuri'] == uri
+    assert new_node['reftitle'] == 'Epydoc crossreference'
+    assert new_node[0] is node[0]
+
+def test_setup(app):
+    epydoc.setup(app)
+    app.add_config_value.assert_called_With('epydoc_mapping', {}, 'env')
+    app.connect.assert_called_with('missing-reference',
+                                   epydoc.resolve_reference_to_epydoc)
+
+
+def main():
+    import py
+    py.cmdline.pytest()
+
+
+if __name__ == '__main__':
+    main()
+[tox]
+envlist=python,doc
+
+[testenv:python]
+deps=
+    mock
+    py
+commands=
+    py.test --junitxml={envlogdir}/tests.xml []
+
+[testenv:doc]
+deps=
+    sphinx
+    lxml
+    sphinxcontrib-issuetracker
+commands=
+    sphinx-build -W -b linkcheck -d {envtmpdir}/doctrees doc {envtmpdir}/linkcheck
+    sphinx-build -W -b html -d {envtmpdir}/doctrees doc {envtmpdir}/html
 It creates an RSS feed of recently updated sphinx pages.
 '''
 
-requires = ['Sphinx>=0.6', 'dateutil']
+requires = ['Sphinx>=0.6', 'python-dateutil']
 
 setup(
     name='feed',

issuetracker/CHANGES.rst

+0.5.1 (Jul 25, 2010)
+====================
+
+- Fixed client string for launchpad access
+
+
 0.5 (Jul 21, 2010)
 ==================
 

issuetracker/MANIFEST.in

 include README
 include LICENSE
 include CHANGES.*
+include test_issuetracker.py
 recursive-include sphinxcontrib *.css
 recursive-include doc *.rst *.py Makefile
 prune doc/_build

issuetracker/doc/conf.py

 # -*- coding: utf-8 -*-
-#
-# sphinxcontrib-issuetracker documentation build configuration file, created by
-# sphinx-quickstart on Sun Jul 11 15:28:12 2010.
-#
-# This file is execfile()d with the current directory set to its containing dir.
-#
-# Note that not all possible configuration values are present in this
-# autogenerated file.
-#
-# All configuration values have a default; values that are commented out
-# serve to show the default.
 
 import sys, os
 
-# If extensions (or modules to document with autodoc) are in another directory,
-# add these directories to sys.path here. If the directory is relative to the
-# documentation root, use os.path.abspath to make it absolute, like shown here.
-#sys.path.insert(0, os.path.abspath('.'))
+needs_sphinx = '1.0'
 
-# -- General configuration -----------------------------------------------------
-
-# If your documentation needs a minimal Sphinx version, state it here.
-#needs_sphinx = '1.0'
-
-# Add any Sphinx extension module names here, as strings. They can be extensions
-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx',
               'sphinxcontrib.issuetracker']
 
-# Add any paths that contain templates here, relative to this directory.
-templates_path = ['_templates']
-
-# The suffix of source filenames.
 source_suffix = '.rst'
-
-# The encoding of source files.
-#source_encoding = 'utf-8-sig'
-
-# The master toctree document.
 master_doc = 'index'
 
-# General information about the project.
 project = u'sphinxcontrib-issuetracker'
 copyright = u'2010, Sebastian Wiesner'
+version = '0.5'
+release = '0.5.1'
 
-# The version info for the project you're documenting, acts as replacement for
-# |version| and |release|, also used in various other places throughout the
-# built documents.
-#
-# The short X.Y version.
-version = '0.5'
-# The full version, including alpha/beta/rc tags.
-release = '0.5'
-
-# The language for content autogenerated by Sphinx. Refer to documentation
-# for a list of supported languages.
-#language = None
-
-# There are two options for replacing |today|: either, you set today to some
-# non-false value, then it is used:
-#today = ''
-# Else, today_fmt is used as the format for a strftime call.
-#today_fmt = '%B %d, %Y'
-
-# List of patterns, relative to source directory, that match files and
-# directories to ignore when looking for source files.
 exclude_patterns = ['_build']
 
-# The reST default role (used for this markup: `text`) to use for all documents.
-#default_role = None
+html_theme = 'default'
+html_static_path = []
 
-# If true, '()' will be appended to :func: etc. cross-reference text.
-#add_function_parentheses = True
+intersphinx_mapping = {'python': ('http://docs.python.org/', None),
+                       'sphinx': ('http://sphinx.pocoo.org/', None)}
 
-# If true, the current module name will be prepended to all description
-# unit titles (such as .. function::).
-#add_module_names = True
-
-# If true, sectionauthor and moduleauthor directives will be shown in the
-# output. They are ignored by default.
-#show_authors = False
-
-# The name of the Pygments (syntax highlighting) style to use.
-pygments_style = 'sphinx'
-
-# A list of ignored prefixes for module index sorting.
-#modindex_common_prefix = []
-
-
-# -- Options for HTML output ---------------------------------------------------
-
-# The theme to use for HTML and HTML Help pages.  See the documentation for
-# a list of builtin themes.
-html_theme = 'default'
-
-# Theme options are theme-specific and customize the look and feel of a theme
-# further.  For a list of options available for each theme, see the
-# documentation.
-#html_theme_options = {}
-
-# Add any paths that contain custom themes here, relative to this directory.
-#html_theme_path = []
-
-# The name for this set of Sphinx documents.  If None, it defaults to
-# "<project> v<release> documentation".
-#html_title = None
-
-# A shorter title for the navigation bar.  Default is the same as html_title.
-#html_short_title = None
-
-# The name of an image file (relative to this directory) to place at the top
-# of the sidebar.
-#html_logo = None
-
-# The name of an image file (within the static path) to use as favicon of the
-# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
-# pixels large.
-#html_favicon = None
-
-# Add any paths that contain custom static files (such as style sheets) here,
-# relative to this directory. They are copied after the builtin static files,
-# so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = ['_static']
-
-# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
-# using the given strftime format.
-#html_last_updated_fmt = '%b %d, %Y'
-
-# If true, SmartyPants will be used to convert quotes and dashes to
-# typographically correct entities.
-#html_use_smartypants = True
-
-# Custom sidebar templates, maps document names to template names.
-#html_sidebars = {}
-
-# Additional templates that should be rendered to pages, maps page names to
-# template names.
-#html_additional_pages = {}
-
-# If false, no module index is generated.
-#html_domain_indices = True
-
-# If false, no index is generated.
-#html_use_index = True
-
-# If true, the index is split into individual pages for each letter.
-#html_split_index = False
-
-# If true, links to the reST sources are added to the pages.
-#html_show_sourcelink = True
-
-# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
-#html_show_sphinx = True
-
-# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
-#html_show_copyright = True
-
-# If true, an OpenSearch description file will be output, and all pages will
-# contain a <link> tag referring to it.  The value of this option must be the
-# base URL from which the finished HTML is served.
-#html_use_opensearch = ''
-
-# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
-#html_file_suffix = ''
-
-# Output file base name for HTML help builder.
-htmlhelp_basename = 'sphinxcontrib-issuetrackerdoc'
-
-
-# -- Options for LaTeX output --------------------------------------------------
-
-# The paper size ('letter' or 'a4').
-#latex_paper_size = 'letter'
-
-# The font size ('10pt', '11pt' or '12pt').
-#latex_font_size = '10pt'
-
-# Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title, author, documentclass [howto/manual]).
-latex_documents = [
-  ('index', 'sphinxcontrib-issuetracker.tex', u'sphinxcontrib-issuetracker Documentation',
-   u'Sebastian Wiesner', 'manual'),
-]
-
-# The name of an image file (relative to this directory) to place at the top of
-# the title page.
-#latex_logo = None
-
-# For "manual" documents, if this is true, then toplevel headings are parts,
-# not chapters.
-#latex_use_parts = False
-
-# If true, show page references after internal links.
-#latex_show_pagerefs = False
-
-# If true, show URL addresses after external links.
-#latex_show_urls = False
-
-# Additional stuff for the LaTeX preamble.
-#latex_preamble = ''
-
-# Documents to append as an appendix to all manuals.
-#latex_appendices = []
-
-# If false, no module index is generated.
-#latex_domain_indices = True
-
-
-# -- Options for manual page output --------------------------------------------
-
-# One entry per manual page. List of tuples
-# (source start file, name, description, authors, manual section).
-man_pages = [
-    ('index', 'sphinxcontrib-issuetracker', u'sphinxcontrib-issuetracker Documentation',
-     [u'Sebastian Wiesner'], 1)
-]
-
-
-# Example configuration for intersphinx: refer to the Python standard library.
-intersphinx_mapping = {'http://docs.python.org/': None,
-                       'http://sphinx.pocoo.org/latest/': None,}
-
-
-# issuetracker settings
 issuetracker = 'bitbucket'
 issuetracker_project = 'sphinx-contrib'
 issuetracker_user = 'birkenfeld'

issuetracker/doc/index.rst

 Contribution
 ------------
 
-Please contact the author or create an issue in the issue tracker of the
+Please contact the author or create an issue in the `issue tracker`_ of the
 sphinx-contrib_ repository, if you have found any bugs or miss some
 functionality (e.g. integration of some other issue tracker).  Patches are
 welcome!
    changes.rst
 
 
-.. _`Sphinx`: http://sphinx.pocoo.org/latest
+.. _`Sphinx`: http://sphinx.pocoo.org/
 .. _`Sphinx issue tracker`: http://bitbucket.org/birkenfeld/sphinx/issues/
 .. _`lxml`: http://codespeak.net/lxml
 .. _`simplejson`: http://pypi.python.org/pypi/simplejson/

issuetracker/setup.py

 
 setup(
     name='sphinxcontrib-issuetracker',
-    version='0.5',
+    version='0.5.1',
     url='http://packages.python.org/sphinxcontrib-issuetracker',
     download_url='http://pypi.python.org/pypi/sphinxcontrib-issuetracker',
     license='BSD',

issuetracker/sphinxcontrib/issuetracker.py

     if not launchpad:
         from launchpadlib.launchpad import Launchpad
         launchpad = Launchpad.login_anonymously(
-            'lunar.sphinx.ext.issuetracker', service_root='production')
+            'sphinxcontrib.issuetracker', service_root='production')
         env.issuetracker_launchpad = launchpad
     try:
         # get the bug
     }
 
 
-
-class issue_reference(nodes.reference):
-    """
-    A reference to an issue in an issue tracker.
-
-    This node always has the ``issue_id`` attribute, which contains the ID
-    of the referenced issue.
-    """
-    pass
-
-
 class IssuesReferences(Transform):
     """
-    Transform plain text issue numbers (e.g. #10) into
-    :class:`issue_reference` nodes.
+    Transform plain text issue numbers (e.g. #10) into ``pending_xref``
+    nodes, which are then resolved through the sphinx reference resolving
+    mechanism.
     """
 
     default_priority = 999
     app.add_transform(IssuesReferences)
     app.connect('builder-inited', auto_connect_builtin_issue_resolvers)
     app.add_config_value('issuetracker_issue_pattern',
-                         re.compile('#(\d+)'), 'env')
+                         re.compile(r'#(\d+)'), 'env')
     app.add_config_value('issuetracker_user', None, 'env')
     app.add_config_value('issuetracker_project', None, 'env')
     app.add_config_value('issuetracker', None, 'env')

issuetracker/test_issuetracker.py

+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import re
+
+import py.test
+from mock import Mock
+from docutils import nodes
+from sphinx.addnodes import pending_xref
+
+from sphinxcontrib import issuetracker
+
+
+def pytest_funcarg__issue_info(request):
+    return dict(uri='http://example.com/issues/10', closed=False)
+
+
+def pytest_funcarg__get_issue_information(request):
+    get_issue_information = Mock()
+    info = request.getfuncargvalue('issue_info')
+    get_issue_information.return_value = info
+    return get_issue_information
+
+
+def pytest_funcarg__resolver(request):
+    return issuetracker.make_issue_reference_resolver(
+        request.getfuncargvalue('get_issue_information'))
+
+
+def pytest_funcarg__config(request):
+    config = Mock()
+    config.project = 'issuetracker'
+    config.issuetracker = 'spamtracker'
+    config.issuetracker_user = 'foobar'
+    config.issuetracker_project = None
+    config.issuetracker_issue_pattern = re.compile(r'#(\d+)')
+    return config
+
+def pytest_funcarg__app(request):
+    app = Mock()
+    app.config = request.getfuncargvalue('config')
+    return app
+
+
+def pytest_funcarg__env(request):
+    env = Mock()
+    env.config = request.getfuncargvalue('config')
+    return env
+
+
+def pytest_funcarg__node(request):
+    node = pending_xref()
+    node['reftype'] = 'issue'
+    node['reftarget'] = '10'
+    node.append(nodes.Text('#10'))
+    return node
+
+
+def pytest_funcarg__doc(request):
+    doc = nodes.paragraph()
+    doc.append(nodes.Text('foo #1 bar'))
+    em = nodes.emphasis()
+    em.append(nodes.Text('see #2 if you are #abc brave'))
+    doc.append(em)
+    doc.settings = Mock()
+    doc.settings.language_code = ''
+    doc.settings.env = request.getfuncargvalue('env')
+    return doc
+
+
+def test_make_isssue_reference_resolver_invalid_reftype(
+    app, env, resolver, node):
+    node['reftype'] = 'spam'
+    assert resolver(app, env, node, node[0]) is None
+
+
+def test_make_issue_reference_resolver_no_issue(
+    app, env, resolver, node, get_issue_information):
+    get_issue_information.return_value = None
+    assert resolver(app, env, node, node[0]) is None
+
+
+def test_make_issue_reference_resolver_no_uri(
+    app, env, resolver, node, issue_info):
+    del issue_info['uri']
+    assert resolver(app, env, node, node[0]) is None
+
+
+def test_make_issue_reference_resolver_open_issue(
+    app, env, resolver, node, issue_info):
+    contnode = node[0]
+    node = resolver(app, env, node, node[0])
+    assert isinstance(node, nodes.reference)
+    assert node[0] is contnode
+    assert node['refuri'] == issue_info['uri']
+    assert 'reference-issue' in node['classes']
+    assert 'issue-closed' not in node['classes']
+
+
+def test_make_issue_reference_resolver_closed_issue(
+    app, env, resolver, node, issue_info):
+    issue_info['closed'] = True
+    contnode = node[0]
+    node = resolver(app, env, node, node[0])
+    assert isinstance(node, nodes.reference)
+    assert node[0] is contnode
+    assert node['refuri'] == issue_info['uri']
+    assert 'reference-issue' in node['classes']
+    assert 'issue-closed' in node['classes']
+
+
+def test_get_issue_information_called(
+    app, env, resolver, node, get_issue_information):
+    resolver(app, env, node, node[0])
+    get_issue_information.assert_called_with(
+        'issuetracker', 'foobar', '10', env)
+    app.config.issuetracker_project = 'spam with eggs'
+    resolver(app, env, node, node[0])
+    get_issue_information.assert_called_with(
+        'spam with eggs', 'foobar', '10', env)
+
+
+def test_builtin_issue_trackers():
+    for tracker in ('github', 'bitbucket',
+                    'launchpad', 'google code'):
+        assert tracker in issuetracker.BUILTIN_ISSUE_TRACKERS
+
+
+def _assert_text(node, text):
+    assert isinstance(node, nodes.Text)
+    assert node.astext() == text
+
+
+def _assert_xref(node, target):
+    assert isinstance(node, pending_xref)
+    _assert_text(node[0], '#%s' % target)
+    assert node['reftype'] == 'issue'
+    assert node['reftarget'] == target
+
+
+def test_issues_references(doc):
+    transformer = issuetracker.IssuesReferences(doc)
+    transformer.apply()
+    assert isinstance(doc, nodes.paragraph)
+    assert doc.astext() == 'foo #1 barsee #2 if you are #abc brave'
+    _assert_text(doc[0], 'foo ')
+    _assert_xref(doc[1], '1')
+    _assert_text(doc[2], ' bar')
+    em = doc[3]
+    assert isinstance(em, nodes.emphasis)
+    _assert_text(em[0], 'see ')
+    _assert_xref(em[1], '2')
+    _assert_text(em[2], ' if you are #abc brave')
+
+
+def test_auto_connect_builtin_issue_resolvers_known_tracker(app):
+    app.config.issuetracker = 'bitbucket'
+    issuetracker.auto_connect_builtin_issue_resolvers(app)
+    assert app.connect.called
+
+
+def test_auto_connect_builtin_issue_resolvers_unknown_tracker(app):
+    app.config.issuetracker = 'spamtracker'
+    with py.test.raises(KeyError):
+        issuetracker.auto_connect_builtin_issue_resolvers(app)
+
+
+def test_auto_connect_builtin_issue_resolvers_no_tracker(app):
+    app.config.issuetracker = None
+    issuetracker.auto_connect_builtin_issue_resolvers(app)
+    assert not app.connect.called
+
+
+def test_add_stylesheet(app):
+    issuetracker.add_stylesheet(app)
+    app.add_stylesheet.assert_called_with('issuetracker.css')
+
+
+def test_setup(app):
+    issuetracker.setup(app)
+    app.require_sphinx.assert_called_with('1.0')
+    app.add_transform.assert_called_with(issuetracker.IssuesReferences)
+    app.connect.call_args_list = [
+        (('builder-inited',
+          issuetracker.auto_connect_builtin_issue_resolvers), {}),
+        (('builder-inited', issuetracker.add_stylesheet), {}),
+        (('build-finished', issuetracker.copy_stylesheet), {})]
+    app.add_config_value.call_args_list = [
+        (('issuetracker_issue_pattern', re.compile(r'#(\d+)'), 'env'), {}),
+        (('issuetracker_user', None, 'env'), {}),
+        (('issuetracker_project', None, 'env'), {}),
+        (('issuetracker', None, 'env'), {})]
+
+
+def main():
+    import py
+    py.cmdline.pytest()
+
+
+if __name__ == '__main__':
+    main()

issuetracker/tox.ini

+[tox]
+envlist=python,doc
+
+[testenv:python]
+deps=
+    mock
+    py
+commands=
+    py.test --junitxml={envlogdir}/tests.xml []
+
+[testenv:doc]
+deps=
+    sphinx
+    lxml
+    sphinxcontrib-issuetracker
+commands=
+    sphinx-build -W -b linkcheck -d {envtmpdir}/doctrees doc {envtmpdir}/linkcheck
+    sphinx-build -W -b html -d {envtmpdir}/doctrees doc {envtmpdir}/html
 
 shutil.copytree('_template', name)
 
-fp = open('_template/setup.py', 'r')
-tmp = string.Template(fp.read())
-fp.close()
-fp = open(os.path.join(name, 'setup.py'), 'w')
-fp.write(tmp.safe_substitute(**locals()))
-fp.close()
+def templated(filename):
+    fp = open(os.path.join('_template', filename), 'r')
+    tmp = string.Template(fp.read())
+    fp.close()
+    fp = open(os.path.join(name, filename), 'w')
+    fp.write(tmp.safe_substitute(**globals()))
+    fp.close()
+
+templated('setup.py')
+templated('README')
 
 print 'Created new package in directory', name

programoutput/CHANGES.rst

+0.4 (May 21, 2010)
+==================
+
+- Initial release

programoutput/MANIFEST.in

+include README
+include LICENSE
+include CHANGES.*
+include test_programoutput.py
+recursive-include doc *.rst *.py Makefile
+prune doc/_build

programoutput/README

+###########################
+sphinxcontrib-programoutput
+###########################
+
+http://packages.python.org/sphinxcontrib-programoutput
+
+This Sphinx_ 1.0 extension executes programs during the build step and
+includes their output into the documentation.  It supports the
+`sphinxcontrib-ansi`_ extension to turn colored output of programs in
+pretty-formatted HTML.
+
+
+Installation
+------------
+
+This extension can be installed from the Python Package Index::
+
+   pip install sphinx-contrib.programoutput
+
+Alternatively, you can clone the sphinx-contrib_ repository from BitBucket,
+and install the extension directly from the repository::
+
+   hg clone http://bitbucket.org/birkenfeld/sphinx-contrib
+   cd sphinx-contrib/programoutput
+   python setup.py install
+
+
+Usage
+-----
+
+Please refer to the documentation_ for further information.
+
+
+.. _`Sphinx`: http://sphinx.pocoo.org/latest
+.. _`sphinxcontrib-ansi`: http://packages.python.org/sphinxcontrib-ansi
+.. _`sphinx-contrib`: http://bitbucket.org/birkenfeld/sphinx-contrib
+.. _documentation: http://packages.python.org/sphinxcontrib-programoutput

programoutput/doc/Makefile

+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+PAPER         =
+BUILDDIR      = _build
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html       to make standalone HTML files"
+	@echo "  dirhtml    to make HTML files named index.html in directories"
+	@echo "  singlehtml to make a single large HTML file"
+	@echo "  pickle     to make pickle files"
+	@echo "  json       to make JSON files"
+	@echo "  htmlhelp   to make HTML files and a HTML help project"
+	@echo "  qthelp     to make HTML files and a qthelp project"
+	@echo "  devhelp    to make HTML files and a Devhelp project"
+	@echo "  epub       to make an epub"
+	@echo "  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  latexpdf   to make LaTeX files and run them through pdflatex"
+	@echo "  text       to make text files"
+	@echo "  man        to make manual pages"
+	@echo "  changes    to make an overview of all changed/added/deprecated items"
+	@echo "  linkcheck  to check all external links for integrity"
+	@echo "  doctest    to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+	-rm -rf $(BUILDDIR)/*
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+	@echo
+	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+	@echo
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
+	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/sphinxcontrib-programoutput.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/sphinxcontrib-programoutput.qhc"
+
+devhelp:
+	$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+	@echo
+	@echo "Build finished."
+	@echo "To view the help file:"
+	@echo "# mkdir -p $$HOME/.local/share/devhelp/sphinxcontrib-programoutput"
+	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/sphinxcontrib-programoutput"
+	@echo "# devhelp"
+
+epub:
+	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+	@echo
+	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+	@echo "Run \`make' in that directory to run these through (pdf)latex" \
+	      "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through pdflatex..."
+	make -C $(BUILDDIR)/latex all-pdf
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+	@echo
+	@echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+	@echo
+	@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+	@echo
+	@echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest: