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

Directives should only be specified inline #127

Closed
catch22 opened this issue Nov 11, 2015 · 7 comments
Closed

Directives should only be specified inline #127

catch22 opened this issue Nov 11, 2015 · 7 comments

Comments

@catch22
Copy link
Collaborator

catch22 commented Nov 11, 2015

I was thinking that perhaps we should not allow to pass directives as part of the doctest call. Instead, all directives should be specified inline (as comments in the actual doctests). My rationale is that doctests should be self-documenting and self-contained: it should always be possible to call doctest <function>.

Let me know what you think; I'm happy to provide a PR.

@cbm755
Copy link
Collaborator

cbm755 commented Nov 12, 2015

A much weaker position would be allow it but stop advertising it at the top of doctest.m's help text: I'd be ok with that for 0.4.x.

@catch22
Copy link
Collaborator Author

catch22 commented Nov 12, 2015

Sounds good! Do you have any thoughts on eventually phasing out that capability?

@cbm755
Copy link
Collaborator

cbm755 commented Nov 12, 2015

Have not really thought about it yet. As a general rule, fewer knobs is good: add them once support them forever.

But to add a data point: I think Python doctest does allow specifying directives globally. No idea how much this is used in practice.

@cbm755
Copy link
Collaborator

cbm755 commented Jun 21, 2016

While we're thinking about this project again, should we at least take the "weaker position" mentioned above?

@catch22
Copy link
Collaborator Author

catch22 commented Jun 21, 2016

Just out of curiosity - have you ever found a use case for this functionality?

@cbm755
Copy link
Collaborator

cbm755 commented Jun 21, 2016

No, not in practice.

I guess theoretically the WHITESPACE one could be used in this way: I figured projects might have project-wide preferences about these things...

@catch22
Copy link
Collaborator Author

catch22 commented Jun 21, 2016

That's true. I feel that it is desirable that doctest <target> always works -- possibly after some setup script has been run that configures paths etc. One might also want to run doctests for targets in different projects, so this seems to preclude any solution that modifies the default directives by setting some global variables.

I think doctest could load the closest .doctestrc file in the target's directory or one of its parent directories before running doctests. I can't think of a major downside (it should be reasonably fast since it will only be done once for invocations like doctest .), but am not so inclined to implement it without a user/use case.

How about we (1) deprecate and subsequently remove support for specifying directives at the command level in the next major version, and (2) accept patches for adding project-global support for modifying directives (using e.g. a .doctestrc file).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants