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

If decorator is used, function disappears from mkdocstrings documentation #32

Closed
kmcquade opened this issue May 10, 2020 · 4 comments
Closed
Labels
bug Something isn't working module:loader

Comments

@kmcquade
Copy link

Describe the bug

When a decorator is used before a function, the function does NOT appear in the documentation:

To reproduce, try placing this as a decorator before any function:

import functools

@functools.lru_cache(maxsize=1024)
def my_function(some_arg):
    print()

Screenshots
When this decorator is used, the function does NOT appear in the documentation:
image

When the decorator is not used, the function DOES appear in the documentation:

image

System (please complete the following information):

  • pytkdocs version: latest
  • Python version: 3.7
  • OS: Mac OS X
@kmcquade kmcquade changed the title If decorator is used, function is not recorded If decorator is used, function disappears from mkdocstrings documentation May 10, 2020
@pawamoy
Copy link
Member

pawamoy commented May 10, 2020

Indeed, I was able to reproduce. I will investigate right now 🙂 Thank you for the report @kmcquade

@pawamoy
Copy link
Member

pawamoy commented May 10, 2020

A few leads: the object is an _lru_cache_wrapper instance. It has a __qualname__ attribute (value is a partial dotted-path to the actual function), but probably more importantly a __wrapped__ attribute which is the actual function. I guess we could check for each member if it has a __wrapped__ attribute, and use it instead of the member itself. This will need more testing.

@pawamoy pawamoy added bug Something isn't working module:loader labels May 10, 2020
@kmcquade
Copy link
Author

Yes it would be great it this could be added. The functions that leverage this are pretty important. I can't remove the func_tools.lru_cache decorator from the function because it made my program so much faster lol

@pawamoy
Copy link
Member

pawamoy commented May 10, 2020

I think we can safely use inspect.unwrap() on every member 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module:loader
Projects
None yet
Development

No branches or pull requests

2 participants