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 PEP 484 type hints #6

Closed
nbraud opened this issue Jan 22, 2019 · 6 comments

Comments

3 participants
@nbraud
Copy link

commented Jan 22, 2019

Expected Behavior

When generating doc for a package that is annotated with PEP 484 type hints, I would expect the type hints to be present in the documentation.

For example, the following definition

def foo(x: Bar, repeat : int = 1):
    """Foo-cate a Bar a number of times (default: 1)."""
    ...

results in the type hints being available in the REPL's help():

>>> help(foo)
foo(x: __main__.Bar, repeat: int = 1)
    Foo-cate a Bar a number of times (default: 1).

and it should well as be present in the pdoc-generated documents:

$ pdoc example.py
Module example
==============

Functions
---------

`foo(x: Bar, repeat: int = 1)`
:   Foo-cate a Bar a number of times (default: 1).

Classes
-------

`Bar`

Actual Behavior

pdoc ignores the type-hints:

$ pdoc example.py
Module example
==============

Functions
---------

`foo(x, repeat=1)`
:   Foo-cate a Bar a number of times (default: 1).

Classes
-------

`Bar`

Type hints document the expected types of parameters and return values. As such, they convey a lot of information for the documentation's user, when present.

See PEP 484 for a discussion of type hints.

Steps to Reproduce

Generate documentation for a module that uses type hints

Additional info

  • pdoc version: 0.5.1
  • Python version: 3.7.2 (default, Jan 3 2019, 02:55:40)
@kernc

This comment has been minimized.

Copy link
Contributor

commented Jan 23, 2019

Would you be interested in doing a pull request for that?

You would need to

nbraud added a commit to nbraud/pdoc that referenced this issue Jan 23, 2019

@kernc kernc added the enhancement label Jan 27, 2019

@nbraud

This comment has been minimized.

Copy link
Author

commented Feb 1, 2019

@kernc Sorry, I had entirely missed you replied here. Yes, obviously I'm pretty interested in writing the code for this ^.^

@omtinez

This comment has been minimized.

Copy link

commented Apr 7, 2019

@nbraud do you plan on submitting a PR with your commit?

@nbraud nbraud referenced this issue Apr 7, 2019

Closed

WiP: Add support for PEP 484 type hints #7

3 of 4 tasks complete
@kernc

This comment has been minimized.

Copy link
Contributor

commented Apr 10, 2019

@omtinez PR #7 is in progress. Welcome to continue where it's left off.

@kernc kernc closed this in 5df06cd Apr 21, 2019

@kernc kernc reopened this Apr 22, 2019

@kernc

This comment has been minimized.

Copy link
Contributor

commented Apr 22, 2019

This is not done. Text template doesn't look into config.mako nor does it print types by default. I'll see what I can do about that and about hyperlinking documented types in HTML output.

kernc added a commit that referenced this issue Apr 24, 2019

@kernc kernc closed this in 4faccce Apr 24, 2019

@kernc

This comment has been minimized.

Copy link
Contributor

commented Apr 24, 2019

Hyperlinked types testable with:

pdoc --html -c show_type_annotations=True your_module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.