bulwark icon indicating copy to clipboard operation
bulwark copied to clipboard

Auto-add docstrings to decorators

Open ZaxR opened this issue 7 years ago • 5 comments

Inherit BaseDecorator and the functions' docstrings w / doc

ZaxR avatar Jan 15 '19 22:01 ZaxR

Tried the following, which works from within the library, but NOT in sphinx docs build:

def decorator_factory(decorator_name, func):
    """Takes in a function and outputs a class that can be used as a decorator."""
    class decorator_name(BaseDecorator):
        __doc__ = ("Decorator version of `{func_name}`. "
                   "See `{func_name}`'s docstring for arguments and examples."
                   .format(func_name=func.__name__))
        check_func = staticmethod(func)

    return decorator_name

The html docs still say alias of bulwark.decorators.decorator_factory.<locals>.decorator_name in every case.

ZaxR avatar Mar 02 '20 16:03 ZaxR

May want to reference and/or parse func.doc

ZaxR avatar May 31 '20 04:05 ZaxR

Update re the alias of issue w/ Sphinx autodoc - looks like there might be a fix coming in 3.1.0: https://github.com/sphinx-doc/sphinx/pull/7749

ZaxR avatar May 31 '20 04:05 ZaxR

My PR only changes the behavior of GenericAliases. It does not change the behavior of decorators. I don't know what is happened on your document. So please let me know your problem in our issues. Thanks,

tk0miya avatar May 31 '20 14:05 tk0miya

Thanks for reaching out here. I'll create an issue.

ZaxR avatar May 31 '20 16:05 ZaxR