GeezerVison is showing github.com — Get doctests in shape to be tested by tox · Issue #212 · googleapis/google-cloud-python
Get doctests in shape to be tested by tox #212DescriptionMake tox test all the doctests in the Sphinx docs.
Ours aren't in shape to do that (yet, might be hard to get there).
See comment by @tseaver for more context Activitytseaver commented on Feb 9, 2015 After making some stab at it, I'm going to abandon this one: the doctest snippets are basically regression-like tests, and can't be exercised without having those environment variables set up. dhermes commented on Feb 9, 2015 ContributorAuthor More actions dhermes commented on Jul 10, 2015 ContributorAuthor More actions jgeewax commented on Jul 11, 2015 Wait -- those comments sounded like they were saying "we shouldn't test the examples in docstrings".
I'm glad this is re-opened though. Should we instead make a call on what the proper environment is to run these tests? (I'd expect to have the system-test-like environment in place when running docstring examples...) tseaver commented on Jul 20, 2015 @jgeewax I'd like to separate the "API documentation" (which uses the :type foo: / :param foo: / :rtype: / :returns: / :raises: markers to specify the contract) from the examples used to support narrative: I believe the best place for those examples is in Sphinx .. doctest:: sections. I've made such examples testable on other projects: see, for instance, zope.component:
- its tox.ni uses
sphinx-build -b doctest to exercise the snippets.
- see the configure.rst document uses
.. testsetup:: and .. testcleanup:: to handle "offstage" setup / teardown.
In our case, we would have to test those examples inside an environment like our current system-tests (with appropriate credentials, etc.) jgeewax commented on Jul 20, 2015 tseaver commented on Jul 20, 2015 If we leave the examples embedded in method docstrings, we are pretty much giving up on testing them: the Sphinx facilities for doing setup / teardown are not going to mesh with that choice. Moving the examples to narrative docs allows for testing them, as well as giving the method docstrings tighter focus. jgeewax commented on Jul 20, 2015 I hear you -- there must be a way to allow .. doctest:: or .. example:: sections in a docstring to be tested, and still live alongside the methods...
The narrative docs are nice, but not nearly as useful to users as the examples in the context of the method... tseaver commented on Jul 20, 2015 I am arguing from the perspective the two kinds of docs are aimed at different classes of users, who need different tone / format:
- Well-structured narrative docs with good examples are aimed at users who are new to the library, and need the "guided tour" approach which the examples support. They focus on the "main path" / common case, and expose the new user to concepts in an order which aids them in building an understanding of why to use various features, more than the nitty-gritty details. In Sphinx, the narrative docs should always contain links to the appropriate sections of the reference docs.
- API reference docs are most useful for refreshing an experienced user's memory of an API's precise signature / contract: conciseness / precision is most helpful for them. Building explicit references from the reference docs is tricky / confusing, because the narrative docs may have multiple locations which discuss a given API.
For an extensive example of documents built using these principals, see Pyramid's narrative docs versus its API reference docs.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|