Skip to content

Commit

Permalink
Merge pull request #17 from Suzhou-Tongyuan/sjh/helpdoc
Browse files Browse the repository at this point in the history
support help doc
  • Loading branch information
songjhaha committed Apr 17, 2024
2 parents ae68612 + b1ba951 commit c856973
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "tyjuliacall"
version = "0.7.3"
version = "0.7.4"
description = "Python-Julia interops."
authors = ["Suzhou-Tongyuan <support@tongyuan.cc>"]
packages = [
Expand Down
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 c856973

Please sign in to comment.