Skip to content
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

Support Epytext docstring syntax (@param) #275

Open
thehale opened this issue Jun 9, 2021 · 7 comments
Open

Support Epytext docstring syntax (@param) #275

thehale opened this issue Jun 9, 2021 · 7 comments

Comments

@thehale
Copy link

thehale commented Jun 9, 2021

Problem Description

As noted in #143 , many Python projects use the format :param <param-name>: <description> or @param <param-name>: <description>, but this format for documenting function parameters is not recognized by pdoc.

Proposal

I would love to see pdoc add support for these formats for documenting function parameters. I work with several projects that use this format. Additionally, I feel like this format looks better in the code (particularly inside of IDE help texts).

Alternatives

Converting these docstrings to the google or numpydoc formats described in #153 is burdensome for larger projects that want to switch to using pdoc, especially since pdoc otherwise works so beautifully out of the box.

Additional context

n/a

@mhils
Copy link
Member

mhils commented Jun 9, 2021

Is there a name for that format? Is that Epytext? If this is remotely standardized and not completely homegrown I'd be happy to merge a PR that adds support for it. :)

If you (or anyone else) wants to contribute this, I'm happy to rig it up with the rest of pdoc.

@loldebyte
Copy link

loldebyte commented Jun 15, 2021

The @param synthax is indeed Epytext, but the :param <param_name>: one is reST as used by Sphinx so i guess it is pretty structured.
That docstring format is also the default for Jetbrains' Pycharm.

mhils added a commit to mhils/pdoc that referenced this issue Mar 30, 2022
@mhils mhils changed the title Support documenting function parameters using :param or @param syntax Support Epytext docstring syntax (@param) Mar 30, 2022
@mhils
Copy link
Member

mhils commented Mar 30, 2022

Quick update: pdoc now supports :param <param_name>: declarations (#369). 😃 If someone wants to contribute epytext I'm happy to guide them, but I think the Sphinx syntax covers the majority of use cases.

@gerardsimons
Copy link

So :returns: are not yet supported?

@mhils
Copy link
Member

mhils commented Jul 20, 2022

:return: should work just fine. Is :returns: a standard thing? That would be trivial to add here if it is.

@gerardsimons
Copy link

Oh lol, it's supposed to be :return:! Works like a charm :-)

@savchenko
Copy link

Apologies for interrupting the thread, but this doesn't seem to work.

Test code

def random_ascii(length: int = 32) -> str:  # {{{
    """
    Return a random string of ASCII letters and digits.

    :param length: Length of the random string.
    :return: Random ASCII string.
    """
    return "".join(choices(ascii_letters + digits, k=length))  # }}}

Rendered documentation

image

pdoc v15.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants