mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-10 07:41:51 +08:00
Fix a stub docs issue
This commit is contained in:
@@ -341,6 +341,12 @@ class TreeNameDefinition(AbstractTreeName):
|
||||
def py__doc__(self):
|
||||
api_type = self.api_type
|
||||
if api_type in ('function', 'class', 'property'):
|
||||
if self.parent_context.get_root_context().is_stub():
|
||||
from jedi.inference.gradual.conversion import convert_names
|
||||
names = convert_names([self], prefer_stub_to_compiled=False)
|
||||
if self not in names:
|
||||
return _merge_name_docs(names)
|
||||
|
||||
# Make sure the names are not TreeNameDefinitions anymore.
|
||||
return clean_scope_docstring(self.tree_name.get_definition())
|
||||
|
||||
|
||||
@@ -37,6 +37,17 @@ def test_operator_doc(Script):
|
||||
assert len(d.docstring()) > 100
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'code, help_part', [
|
||||
('str', 'Create a new string object'),
|
||||
('str.strip', 'Return a copy of the string'),
|
||||
]
|
||||
)
|
||||
def test_stdlib_doc(Script, code, help_part):
|
||||
h, = Script(code).help()
|
||||
assert help_part in h.docstring(raw=True)
|
||||
|
||||
|
||||
def test_lambda(Script):
|
||||
d, = Script('lambda x: x').help(column=0)
|
||||
assert d.type == 'keyword'
|
||||
|
||||
Reference in New Issue
Block a user