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

Pick up docstrings from pyi files #613

Closed
benruijl opened this issue Aug 30, 2023 · 1 comment
Closed

Pick up docstrings from pyi files #613

benruijl opened this issue Aug 30, 2023 · 1 comment

Comments

@benruijl
Copy link

I have a .pyi file that looks like this:

"""
Symbolica Python API.
"""

from __future__ import annotations
from typing import Callable, overload, Iterator, Optional, Sequence, Tuple, List


class Expression:
    """A Symbolica expression."""

    def var(_cls, name: str) -> Expression:
        """
        Creates a Symbolica expression that is a single variable.

        Examples
        --------
        >>> var_x = Expression.var('x')
        >>> print(var_x)
        x
        """

    @classmethod
    def vars(_cls, *names: str) -> Sequence[Expression]:
        """
        Create a Symbolica variable for every name in `*names`.
        """

    @classmethod
    def fun(_cls, name: str, is_symmetric: bool = False) -> Function:
        """
        Creates a new Symbolica function with a given name.

        Examples
        --------
        >>> f = Expression.fun('f')
        >>> e = f(1,2)
        >>> print(e)
        f(1,2)
        """

    @classmethod
    def funs(_cls, *names: str) -> Sequence[Function]:
        """
        Create a Symbolica function for every name in `*names`.
        """

    @classmethod
    def parse(_cls, input: str) -> Expression:
        """
        Parse a Symbolica expression from a string.

        Parameters
        ----------
        input: str
            An input string. UTF-8 character are allowed.

        Examples
        --------
        >>> e = Expression.parse('x^2+y+y*4')
        >>> print(e)
        x^2+5*y

        Raises
        ------
        ValueError
            If the input is not a valid Symbolica expression.
        """

    def __copy__(self) -> Expression:
        """
        Copy the expression.
        """

With many more entries. When generating the pdoc output for this using either:

 python -m pdoc ./symbolica.pyi

or

python -m pdoc ./symbolica.so

I get

output

The output is missing some functions, such as __copy__, and is missing most documentation. For some reason, some functions do contain documentation.

VS Code has no problems showing the documentation:

image

Do you have any idea what is going on?

@benruijl benruijl added the bug label Aug 30, 2023
@mhils
Copy link
Member

mhils commented Aug 30, 2023

We currently only copy over annotations from pyi files, but I agree that docstrings would be super useful as well!

The right place to do this is at https://github.com/mitmproxy/pdoc/blob/v14.0.0/pdoc/doc_pyi.py#L58, contributions are welcome! :)

@mhils mhils added enhancement and removed bug labels Aug 30, 2023
@mhils mhils changed the title Missing documentation from .pyi file Pick up docstrings from pyi files Aug 30, 2023
mhils added a commit to mhils/pdoc that referenced this issue Sep 6, 2023
mhils added a commit to mhils/pdoc that referenced this issue Sep 6, 2023
@mhils mhils closed this as completed in 8b99723 Sep 6, 2023
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

2 participants