On 1/14/20 12:44 PM, Soni L. wrote:
We have importlib resources. We should put it to use.
Imagine if you could separate your docs from your code and yet include
them in your package.
```
f"""{from mymodule.docs include main.rst}"""
def foo():
f"""{from mymodule.docs include foo.rst}"""
pass
class Bar:
f"""{from mymodule.docs include bar.rst}"""
pass
template = f"{from mymodule.templates include index.html}"
```
etc. I think this would be pretty cool!
It's already possible:
def doc_from_file(filename):
def _decorator(thing):
with open(filename) as f:
thing.__doc__ = f.read()
return thing
return _decorator
@doc_from_file("func.rst")
def func(a, b):
return a + b
--Ned.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/APY4RJMQWM4LB6SMVGDUUG3ACZSCVOSB/
Code of Conduct: http://python.org/psf/codeofconduct/