simon-ritchie / stubdoc Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
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.
Hi! Awesome library.
Currently, stubdoc only supports adding docstring to functions and class methods.
Lines 37 to 48 in 0e77e00
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: ...
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
\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 '...'
Related PR: #7
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.