Skip to content

Commit

Permalink
support help doc
Browse files Browse the repository at this point in the history
  • Loading branch information
songjhaha committed Apr 17, 2024
1 parent ae68612 commit 9510695
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tyjuliacall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,31 @@

JV = _load_pyjulia_core().JV
sys.meta_path.insert(0, JuliaFinder()) # type: ignore


def _setup_help():
import pydoc

class Helper(object):
def __init__(self):
if isinstance(__builtins__, dict):
self.help = __builtins__['help']
else:
self.help = __builtins__.help

def __call__(self, obj):
if isinstance(obj, JV):
# get Julia documentation
jdoc_func = JuliaEvaluator["jdoc_func = Base.string ∘ Base.Docs.doc"]
return pydoc.pager(jdoc_func(obj))
else:
return self.help(obj)

if isinstance(__builtins__, dict):
__builtins__['help'] = Helper()
else:
__builtins__.help = Helper()


_setup_help()
del _setup_help

0 comments on commit 9510695

Please sign in to comment.