I also realized I need another option, namely to say under which
version a particular doctest should be run. So I had a brainwave, and
the solution to my problems is obvious: I'll write a custom doctest
extension for Sphinx.

On Thu, Dec 31, 2009 at 13:03, Lennart Regebro <[email protected]> wrote:
> On Thu, Dec 31, 2009 at 12:38, Chris Withers <[email protected]> wrote:
>> Not with Sphinx's hidden code blocks...
>
> Sure, but I don't get Manuel to pick those up.
>
> I want this to work:
>
> .. testcode::
>
>    from setuptools import setup, find_packages
>    readme = open('docs/README.txt', 'rt').read()
>    changes = open('docs/CHANGES.txt', 'rt').read()
>
>    setup(name='Porting to Python 3 examples',
>          version=1.0,
>          description="The example project for Porting to Python 2",
>          long_description=readme + '\n' + changes,
>          classifiers=[
>              "Programming Language :: Python :: 2",
>              "Topic :: Software Development :: Documentation",
>          ],
>          keywords='python3 porting documentation examples',
>          author='Lennart Regebro',
>          author_email='[email protected]',
>          license='GPL',
>          packages=find_packages(exclude=['ez_setup']),
>          include_package_data=True,
>    )
>
> .. testoutput::
>    :hide:
>    Traceback (most recent call last):
>    ...
>
> and I also want this to work:
>
> .. doctest::
>
>    >>> from __future__ import division
>    >>> 5/2
>    2.5
>
> It's as simple, and complicated, as that.
>
> The get the future import to work in a >>> block, I need to provide my
> own test parser.
> To get the hidden codeblock to work, I need to use sphinx-build -b doctest.
>
> Best solution would be if I could make sphinx-build -b doctest use my
> testparser, but I can't figure out a way to do that. I've also tried
> using unittest.TextTestRunner() with standard doctests, but it will
> not pick up sphinx code block. I've also tried using Manuel, but it
> will not pick up the sphinx code block.
>
> --
> Lennart Regebro: Python, Zope, Plone, Grok
> http://regebro.wordpress.com/
> +33 661 58 14 64
>

--

You received this message because you are subscribed to the Google Groups 
"sphinx-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sphinx-dev?hl=en.


Reply via email to