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

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

Closed
bear24rw opened this issue Mar 3, 2022 · 4 comments
Closed

Comments

@bear24rw
Copy link

bear24rw commented Mar 3, 2022

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.

@bear24rw
Copy link
Author

bear24rw commented Mar 3, 2022

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>

@pawamoy
Copy link
Member

pawamoy commented Mar 3, 2022

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?

@bear24rw
Copy link
Author

bear24rw commented Mar 4, 2022

Then cls should be hidden as well right?

I believe so!

pawamoy added a commit that referenced this issue Mar 5, 2022
@pawamoy
Copy link
Member

pawamoy commented Mar 5, 2022

Done in version 0.6.6

@pawamoy pawamoy closed this as completed Mar 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants