Skip to content

Set markdown format via __docformat__ or command line --docformat #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
peterjc opened this issue Feb 21, 2020 · 3 comments
Closed

Set markdown format via __docformat__ or command line --docformat #169

peterjc opened this issue Feb 21, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@peterjc
Copy link

peterjc commented Feb 21, 2020

I note that pdoc3 supports pure Markdown (with extensions), numpydoc, and Google-style docstrings formats, and you have partial reStructuredText support (see #110).

I do not see that you allow explicit declaration of which markup language (or flavour) is being used, although I see internally variable docformat can be "numpy" or "google".

I would like to be able to set a default at the command line with --docformat ... and/or override this at individual file level using__docformat__ = "..." as done in epydoc. See also rejected PEP258:

https://www.python.org/dev/peps/pep-0258/#choice-of-docstring-format
http://epydoc.sourceforge.net/manual-usage.html

Cross reference mitmproxy/pdoc#153 on the original pdoc project, and #158 on enabling markdown extensions.

@kernc kernc added the enhancement New feature or request label Mar 26, 2020
@kernc
Copy link
Member

kernc commented Mar 29, 2020

Happy to change default param value to docformat=None and infer either supported format ('numpy' or 'google') from the passed module.obj.__docformat__, if available.

pdoc/pdoc/html_helpers.py

Lines 378 to 379 in b8758dd

def to_html(text: str, docformat: str = 'numpy,google', *,
module: pdoc.Module = None, link: Callable[..., str] = None,

Shouldn't be hard at all. PR welcome.


Not so thrilled about the CLI switch. What case doesn't work for you that you wanted to limit to either 'numpy' or 'google'?

@peterjc
Copy link
Author

peterjc commented Mar 29, 2020

Personally I want to use --docformat restructuredtext at the command line (RST spelt out in full to match the convention established by epydoc).

@kernc
Copy link
Member

kernc commented Apr 16, 2020

This should now work.

To set it from the command line, one can use: pdoc --config='docformat="numpy"' ...

Whether to support reStructuredText, and how, is a different issue (#110).

kernc added a commit that referenced this issue Apr 16, 2020
E.g.

    --config='docformat="numpy"'

Fixes #169
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants