Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8520f30

Browse files
authored
Merge pull request #13503 from martinRenou/sphinxify
Update sphinxify usage
2 parents 000c27e + c9a8d0b commit 8520f30

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

IPython/core/interactiveshell.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,17 @@
9090
try:
9191
import docrepr.sphinxify as sphx
9292

93-
def sphinxify(doc):
94-
with TemporaryDirectory() as dirname:
95-
return {
96-
'text/html': sphx.sphinxify(doc, dirname),
97-
'text/plain': doc
98-
}
93+
def sphinxify(oinfo):
94+
wrapped_docstring = sphx.wrap_main_docstring(oinfo)
95+
96+
def sphinxify_docstring(docstring):
97+
with TemporaryDirectory() as dirname:
98+
return {
99+
"text/html": sphx.sphinxify(wrapped_docstring, dirname),
100+
"text/plain": docstring,
101+
}
102+
103+
return sphinxify_docstring
99104
except ImportError:
100105
sphinxify = None
101106

@@ -772,7 +777,7 @@ def init_virtualenv(self):
772777
while p.is_symlink():
773778
p = Path(os.readlink(p))
774779
paths.append(p.resolve())
775-
780+
776781
# In Cygwin paths like "c:\..." and '\cygdrive\c\...' are possible
777782
if p_venv.parts[1] == "cygdrive":
778783
drive_name = p_venv.parts[2]
@@ -1621,7 +1626,9 @@ def _inspect(self, meth, oname, namespaces=None, **kw):
16211626
This function is meant to be called by pdef, pdoc & friends.
16221627
"""
16231628
info = self._object_find(oname, namespaces)
1624-
docformat = sphinxify if self.sphinxify_docstring else None
1629+
docformat = (
1630+
sphinxify(self.object_inspect(oname)) if self.sphinxify_docstring else None
1631+
)
16251632
if info.found:
16261633
pmethod = getattr(self.inspector, meth)
16271634
# TODO: only apply format_screen to the plain/text repr of the mime
@@ -1668,7 +1675,11 @@ def object_inspect_mime(self, oname, detail_level=0, omit_sections=()):
16681675
with self.builtin_trap:
16691676
info = self._object_find(oname)
16701677
if info.found:
1671-
docformat = sphinxify if self.sphinxify_docstring else None
1678+
docformat = (
1679+
sphinxify(self.object_inspect(oname))
1680+
if self.sphinxify_docstring
1681+
else None
1682+
)
16721683
return self.inspector._get_info(
16731684
info.obj,
16741685
oname,

0 commit comments

Comments
 (0)