Git Product home page Git Product logo

stubdoc's People

Contributors

cschulzetlk avatar currenttv avatar simon-ritchie avatar tobiasah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

stubdoc's Issues

Limitation: does not support native modules

I was hoping to make docs for lcm's python bindings.

stubgen  -p lcm
stubdoc -m lcm/__init__.py -s out/lcm/__init__.pyi
stubdoc -m lcm/_lcm.so -s out/lcm/_lcm.pyi

The docs are successfully scraped from the python source init file and added to its stub, but the stub for the native module remains unchanged. Pydoc does display help for this native module.

Probably a fair bit more complicated to support, but making this issue at least for documentation.

Add support for class-level docstring

Hi! Awesome library.

Currently, stubdoc only supports adding docstring to functions and class methods.

if '.' not in callable_name:
stub_str = _add_doctring_to_target_function(
stub_str=stub_str,
function_name=callable_name,
module=module,
)
continue
stub_str = _add_docstring_to_class_method(
stub_str=stub_str,
method_name=callable_name,
module=module,
)

It would be great if it supported class-level docstrings as well as class getters and setters (@property).

Stub file with docstring generated by stubdoc:

class NamedNode:
    @property
    def value(self) -> str: ...
    def __init__(self, value: str) -> None:
        """
        Initialize self.  See help(type(self)) for accurate signature.
        """
    def __str__(self) -> str: ...
    def __repr__(self) -> str: ...
    def __hash__(self) -> int: ...
    def __eq__(self, other: Any) -> bool: ...
    def __ge__(self, other: Any) -> bool: ...
    def __gt__(self, other: Any) -> bool: ...
    def __le__(self, other: Any) -> bool: ...
    def __lt__(self, other: Any) -> bool: ...
    def __ne__(self, other: Any) -> bool: ...

Desired output:

class NamedNode:
    """An RDF `node identified by an IRI <https://www.w3.org/TR/rdf11-concepts/#dfn-iri>`_.

    :param value: the IRI as a string.
    :raises ValueError: if the IRI is not valid according to `RFC 3987 <https://tools.ietf.org/rfc/rfc3987>`_.

    The :py:func:`str` function provides a serialization compatible with N-Triples, Turtle, and SPARQL:

    >>> str(NamedNode('http://example.com'))
    '<http://example.com>'
    """
    @property
    def value(self) -> str:
        """the named node IRI.
        
        >>> NamedNode("http://example.com").value
        'http://example.com'
        """
    def __init__(self, value: str) -> None:
        """
        Initialize self.  See help(type(self)) for accurate signature.
        """
    def __str__(self) -> str: ...
    def __repr__(self) -> str: ...
    def __hash__(self) -> int: ...
    def __eq__(self, other: Any) -> bool: ...
    def __ge__(self, other: Any) -> bool: ...
    def __gt__(self, other: Any) -> bool: ...
    def __le__(self, other: Any) -> bool: ...
    def __lt__(self, other: Any) -> bool: ...
    def __ne__(self, other: Any) -> bool: ...

Docstring missing for imported classes

Given the following module files:

# packages/package/parent.py

class Parent:
    def shared(self):
        """This should be shared by Child, too."""
# packages/package/child.py

class Child(Parent):
    pass

And the following stub files:

# stubs/package/child.pyi

class Child(Parent):
    def shared(self):
        ...

The following command does not copy over the docstring:

stubdoc --module_path=packages/package/child.py --stub_path=stubs/package/child.pyi

Module import error

\pypoetry\cache\virtualenvs\stubdoc-kaloics5-py3.8\lib\site-packages\stubdoc\stubdoc.py", line 409, in _read_module
    module: ModuleType = importlib.import_module(name)
...\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named '...'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.