diff --git a/jedi/inference/names.py b/jedi/inference/names.py index f90f9749..3e17ecd8 100644 --- a/jedi/inference/names.py +++ b/jedi/inference/names.py @@ -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()) diff --git a/test/test_api/test_documentation.py b/test/test_api/test_documentation.py index b86c68fc..4c09d612 100644 --- a/test/test_api/test_documentation.py +++ b/test/test_api/test_documentation.py @@ -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'