Skip to content

Type annotations for variables/properties #121

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
whitelynx opened this issue Nov 5, 2019 · 2 comments
Closed

Type annotations for variables/properties #121

whitelynx opened this issue Nov 5, 2019 · 2 comments
Labels
enhancement New feature or request help wanted 🤷 Extra attention is needed

Comments

@whitelynx
Copy link

Example code:

class Porkline:
    """A porkline. A porkline corresponds to one example class."""

    type: str = None
    """The porkline type"""

    def __init__(self, name: str) -> None:
        self.name: str = name
        """The porkline name"""

    def compare(self, name: str) -> bool:
        """Check if the porkline's name matches the given name."""
        return name == self.name

Expected Behavior

In the given example, the types of Porkline.type and self.name should be shown in the documentation.

Actual Behavior

The annotated types are missing from the documentation.

2019-11-05-141226_803x628_scrot

Additional info

  • pdoc version: 0.7.1
@whitelynx
Copy link
Author

This is the same issue mentioned by @DaniGuardiola at #6 (comment)

@kernc
Copy link
Member

kernc commented Nov 6, 2019

This is the relevant place if you care to tweak it:

pdoc/pdoc/__init__.py

Lines 252 to 254 in 1b644f6

elif isinstance(assign_node, ast_AnnAssign):
target = assign_node.target
# TODO: use annotation

@kernc kernc added the enhancement New feature or request label Nov 6, 2019
@kernc kernc added the help wanted 🤷 Extra attention is needed label Jan 11, 2020
@kernc kernc changed the title Class and instance variable/property types are not included in documentation Type annotations for variables/properties Jan 11, 2020
@kernc kernc closed this as completed in 2f3db5f Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted 🤷 Extra attention is needed
Development

No branches or pull requests

2 participants