Skip to content

MAINT: DRY our docstrings #5753

Closed
Closed

Description

@larsoner

We could vendor doccer from SciPy to do things like this:

https://github.com/scipy/scipy/blob/69cfe48f37f08c71bc571956b4d044e4c5107e37/scipy/ndimage/filters.py#L54-L71

It should reduce code dup without hurting readability much. I actually think it will help readability in the long run since you 1) immediately know it's a standard MNE param and 2) there is less docstring to skip through / ignore to see the actual code.

If it seems worthwhile, I can make a quick PR to do this for verbose, and then incorporate it in #4511 for picks. Eventually it could also help with n_jobs (two flavors probably: cuda-allowed and cpu-only) and probably other params, too. It seems like it would cut down on a lot of otherwise unnecessary code (docstring) dup in the long run, and probably wouldn't make too much rebase difficulty in the meantime.

Activity

  1. added this to the 0.18 milestone on Nov 28, 2018
  2. self-assigned this
    on Nov 28, 2018
  3. mmagnuski commented on Nov 28, 2018

    @mmagnuski
    Member

    looks cool :)

  4. jasmainak commented on Nov 28, 2018

    @jasmainak
    Member

    Indeed, great idea !

  5. agramfort commented on Nov 29, 2018

    @agramfort
    SponsorMember
  6. larsoner commented on Nov 29, 2018

    @larsoner
    MemberAuthor

    Have you looked at #4511? It shows why it would be advantageous. (The PR would basically be done instead of a ton of copy pastes pending review.)

    In the future, if we want to improve this docstring, without this proposal we have to change something in 50 or so places instead of one. Same with our verbose docstring; I would be very hesitant to improve its wording even if it needs it because replacing them all correctly would be a huge pain. And reviewing it properly similarly annoying.

    In the SciPy code, it seems very simple to infer that the docstring is being filled, so the extra developer learning overhead should be very small.

    But if you insist that I wear out my Ctrl and V keys I will do it. :)

  7. jasmainak commented on Nov 29, 2018

    @jasmainak
    Member

    I think this would benefit a lot of lazy developers. For example, I recently discovered that in the documentation of spatio_temporal_cluster_test, the tail parameter says: "See permutation_cluster_test". No link or anything. Nobody is going to complain because there is nothing technically wrong here -- just that it increases the barrier for people to understand the function and use it.

  8. massich commented on Jan 18, 2019

    @massich
    Contributor

    I've no idea how this one skipped my radar. But yes +1 to this one. And it would be even better if we can link them somehow to the sphinx terms.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions