Another new library release: DocStrands lets you re-use segments of your docstrings between functions.
Copy-pasting docstrings has long frustrated me, so I came up with my own solution!
Another new library release: DocStrands lets you re-use segments of your docstrings between functions.
Copy-pasting docstrings has long frustrated me, so I came up with my own solution!
@pawamoy No I evidently missed that PEP in my research, thanks for pointing me to it. I should probably align with that spec by using Doc instead of my own custom Description.
DocStrands still works a tad differently from griffe-typingdoc because it updates the docstring at runtime, and also has additional APIs for copying e.g. the description.
As an aside, I wanted to use griffe for this, but it doesn't have a deparse method for converting back to docstrings. Had you thought about making one?
@multimeric I could imagine a Griffe extension for DocStrands ☺️
Yes, I have actually started working on an unparser, which would unlock interesting use-case indeed. Specifically, parsing (and caching) docstrings too early can be problematic, and I want to provide an easy way for extension authors to modify the raw docstring instead of parsed sections. Ideally we'd have a complete unparser, as well as a more performant "injector" which just splits sections (no parsing) to insert text in between.
@pawamoy Great! If that gets implemented then I'll likely use it. DocStrands shouldn't need a dedicated Griffe plugin as long as the dynamic parser is enabled. I have Griffe as part of the test suite for that reason.
Not exactly sure about the context of the caching issue but I solved it for DocStrands by lazily deparsing the docstring only when __doc__ was requested.