Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doctest: Need a way to locally disable the trimming of doctest flags #6698

Closed
JulienPalard opened this issue Sep 12, 2019 · 0 comments
Closed
Labels
extensions type:enhancement enhance or introduce a new feature
Milestone

Comments

@JulienPalard
Copy link
Contributor

Is your feature request related to a problem? Please describe.

In cpython, we have the doctest documentation, in this we're having for example:

This test also passes, and also requires a directive to do
so::

   >>> print(list(range(20))) # doctest: +ELLIPSIS
   [0, 1, ..., 18, 19]

So in this specific case, we need the "# doctest: +ELLIPSIS" to still be visible in the generated documents, because it's part of what's we're documenting.

Describe the solution you'd like
I'd like to be able to locally disable the stripping by something like:

.. doctest::
   :trim_flags: False

   >>> print(list(range(20))) # doctest: +NORMALIZE_WHITESPACE
   [0,   1,  2,  3,  4,  5,  6,  7,  8,  9,
   10,  11, 12, 13, 14, 15, 16, 17, 18, 19]

Describe alternatives you've considered
In cpython we were messing with self.highlighter.trim_doctest_flags, which is now deprecated. trim_doctest_flags still exists but as a global option, so it's harder to trick it to act on a single code block with not too much ugly tricks.

Additional context
https://bugs.python.org/issue36675

@JulienPalard JulienPalard added the type:enhancement enhance or introduce a new feature label Sep 12, 2019
tk0miya added a commit to tk0miya/sphinx that referenced this issue Aug 1, 2020
…options

To control trimming doctest flags manually, this adds new options
:trim-flags: and :no-trim-flags: to doctest directives.  It helps
to describes doctest module itself in python doc (see sphinx-doc#6698).
@tk0miya tk0miya added this to the 3.2.0 milestone Aug 1, 2020
tk0miya added a commit to tk0miya/sphinx that referenced this issue Aug 1, 2020
…options

To control trimming doctest flags manually, this adds new options
:trim-flags: and :no-trim-flags: to doctest directives.  It helps
to describes doctest module itself in python doc (see sphinx-doc#6698).
@tk0miya tk0miya closed this as completed in 059dc10 Aug 5, 2020
tk0miya added a commit that referenced this issue Aug 5, 2020
Close #6698: doctest: Add :trim-flags: and :no-trim-flags: options
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
extensions type:enhancement enhance or introduce a new feature
Projects
None yet
Development

No branches or pull requests

2 participants