Description
I'm opening this ticket to unify discussion of docstring flavors. We have a wide range of requests for these, including:
- Google style [Add support for Google Style #101]
- reStructuredText [ __docformat__ reStructuredText/rst etc input as well as Markdown #111]
- Markdown variants [Markdown tables not rendered as tables #64]
- Handling of doctests [Doctests are interpreted by the HTML template #63]
- Epytext [Parsing Epytext #35]
- UML diagrams [UML Diagrams #22]
- ASCII Doc [AsciiDoc support #108]
- Pre-formatted docstrings [use pre tag for docstring #114]
- Formulas [Formulas in pdoc #87]
I'm going to close all these tickets so that we can explore which direction to take in one place. When I first took on pdoc, I thought we could get away with supporting one and only one format. Having read carefully through all of the related tickets, I've now softened that a bit, and I think that there's an argument for being pragmatic.
My feeling is that we should clearly cater for doctests and pre-formatted docstrings, and choose a more flexible markdown renderer that includes Github-style tables and the like. Equally, I feel we should clearly not include support for reStructuredText, which is way too large and complicated. I'm undecided about things like Google style and EpyText, which are intermediate.
It's possible that we could use a Github-style type marker for this:
"""raw
This is a pre-formatted docstring.
Indentation will be preserved.
"""
And:
"""google
A Google-style docstring.
Arguments:
argname (type): Description.
secondarg (type : default): Description.
Returns:
boolean: True on success.
"""
The downside of this is that it introduces a weirdness to docstrings that make them less nice for both humans in code editors and other documentation tools. Another possibility (fronted in some PRs) is to control this unilaterally for an entire module with a command-line flag. This has the issue that the format is not specified in the code (where I feel it should be), and that many modules will be heterogenous and require support for multiple formats. Thoughts?