Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support help doc #17

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <[email protected]>"]
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
Loading