Skip to content

Don't show the implicit self parameter in the function signature #7

Closed

Description

@bear24rw

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

I would like to not show the implicit self parameter in the function signatures. Since the documentation is most often read by a user of the object there is no need to show them to the explicit self parameter. The built in python help() docstring renderer does not show it.

Describe the solution you'd like

A config option to disable show self would be ideal. Defaulting to "dont show self" would be even better.

Describe alternatives you've considered

An alternative is to not have a config option and just never show it.

Activity

  1. bear24rw commented on Mar 3, 2022

    @bear24rw
    Author

    I think what I am after can be achieved with this patch. I'd argue that this is the correct thing to do by default for class methods.

    diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/class.html b/src/mkdocstrings_handlers/python/templates/material/_base/class.html
    index 8f47fb8..6a27c08 100644
    --- a/src/mkdocstrings_handlers/python/templates/material/_base/class.html
    +++ b/src/mkdocstrings_handlers/python/templates/material/_base/class.html
    @@ -105,10 +105,12 @@
             {% endif %}
           {% endif %}
    
    -      {% with obj = class %}
    -        {% set root = False %}
    -        {% set heading_level = heading_level + 1 %}
    -        {% include "children.html" with context %}
    +      {% with no_self = True %}
    +        {% with obj = class %}
    +          {% set root = False %}
    +          {% set heading_level = heading_level + 1 %}
    +          {% include "children.html" with context %}
    +        {% endwith %}
           {% endwith %}
         </div>
  2. pawamoy commented on Mar 3, 2022

    @pawamoy
    Member

    You're probably right, we're documenting APIs and users never have to pass self so I guess it'd be reasonable to always hide it.
    Then cls should be hidden as well right?

  3. bear24rw commented on Mar 4, 2022

    @bear24rw
    Author

    Then cls should be hidden as well right?

    I believe so!

  4. pawamoy commented on Mar 5, 2022

    @pawamoy
    Member

    Done in version 0.6.6

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions