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!
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.
participants (2)
-
Ned Batchelder
-
Soni L.