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

Allow customizing the "self" reference #11

Open
johnpmcconnell opened this issue Feb 18, 2021 · 2 comments
Open

Allow customizing the "self" reference #11

johnpmcconnell opened this issue Feb 18, 2021 · 2 comments

Comments

@johnpmcconnell
Copy link

johnpmcconnell commented Feb 18, 2021

THANK YOU! This is pretty much exactly what I was looking for.

Currently, this plug in generates "signatures" (for lack of a better term) that use the name self to reference the object. It would improve the output if we could customize this name somehow. A couple of ways of doing it that I can think of:

  • Define a directive or parameter that's read from the docstring.
  • Pick up on names other than self from the code.

I'd prefer to explicitly declare the name in the docstring, personally. self is a very strong naming convention that I wouldn't want to violate.

@cspotcode
Copy link

cspotcode commented May 26, 2023

Is this going to happen?

I would like a simple config I can put in conf.py, something like:

prettyspecialmethods_self_format = "pascal_to_snake" # current behavior is "self"

When set, the class's name FooBar is converted to foo_bar e.g. len(foo_bar) or len(scheduler_list)for a hypotheticalclass SchedulerList`

If that is not sufficient, then there can also be an event emitted which is allowed to return the string to use.

app.connect("prettyspecialmethods-self-format", my_function)

@cspotcode
Copy link

An example of this in python's official docs:

https://docs.python.org/3/library/stdtypes.html#dict

Linked from here: #6 (comment)

Python's official docs avoid using self. They use d to refer to a dictionary, as in len(d), then describe it like this: "Return the number of items in the dictionary d."

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