NiklasRosenstein / pydoc-markdown

Create Python API documentation in Markdown format.
http://niklasrosenstein.github.io/pydoc-markdown/
Other
459 stars 102 forks source link

Mangles typing.NewType #35

Closed ghost closed 4 years ago

ghost commented 6 years ago

If I have an argument to a function that is a custom type using the new Python 3 type annotations, e.g.

from typing import NewType
NodeID = NewType('NodeID', str)

Currently, pydoc-markdown mangles this:

class GraphDriver:
    def get_node(self, node_id: NodeID):
      """ method """

to: GraphDriver.get_node(self, node_id:<function NewType.<locals>.new_type at 0x1023bb7b8>)

Instead of:

GraphDriver.get_node(self, node_id:NodeID) or GraphDriver.get_node(self, node_id:<module_name>.types.NodeID)

I keep my custom types in <module_name>.types so the latter would be my desired behavior. Is there a way to disable this behavior, or should it be special-cased?

NiklasRosenstein commented 6 years ago

Hi @sda-amfam, sorry for the late reply. This would need to be handled separately in pydocmd.loader.PythonLoader.load_section().

NiklasRosenstein commented 4 years ago

This is auto-magically resolved in v3 due to the way code is parsed (with lib2to3).