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

[Feature request] Integrate Python docstrings with Julia help #46

Closed
malmaud opened this issue Oct 23, 2013 · 12 comments
Closed

[Feature request] Integrate Python docstrings with Julia help #46

malmaud opened this issue Oct 23, 2013 · 12 comments

Comments

@malmaud
Copy link
Contributor

malmaud commented Oct 23, 2013

Not sure how implausible this is, but it would be great if typing
?[python function]
at the julia REPL gave back the docstring of that function/module, just as IPython's ? does.

@stevengj
Copy link
Member

help(o::PyObject) of a Python object works to get the docstring. The problem is that there is no documented way to associate help strings with new Julia functions.

The help function internally uses a Base.Help.FUNCTION_DICT dictionary, but I'm not sure if it is kosher to modify this. @StefanKarpinski, @loladiro?

@StefanKarpinski
Copy link

Relevant: JuliaLang/julia#3988. I'd really like a proscribed way to do this. cc: @JeffBezanson

@stevengj
Copy link
Member

(I think you mean "prescribed". A proscribed technique would not be very useful. ;-)

@StefanKarpinski
Copy link

Hahah. Yes, that is what I meant.

@malmaud
Copy link
Contributor Author

malmaud commented Oct 24, 2013

haha

@kskyten
Copy link

kskyten commented Jan 12, 2017

This is now possible with the @doc macro. Is it possible to apply this to the methods of an object also so that ? object[:method] would provide something useful?

@stevengj
Copy link
Member

@MichaelHatherly, I can't figure out how to hook into the @doc macro so that it calls a custom lookup function for a PyObject.

Ideally, it would be enough to just define a Base.Docs.doc(o::PyObject) method (and, in fact, I currently define such a method), but this doesn't work because doc is only called with a Binding object.

Does a hook function need to be added to Base.Docs for custom (lazy) docstring lookup?

@MichaelHatherly
Copy link

Does a hook function need to be added to Base.Docs for custom (lazy) docstring lookup?

Something like that might work. I'm not all that familiar with PyCall though, so couldn't say for certain.

@stevengj
Copy link
Member

stevengj commented Jan 13, 2017

The point is that for o::PyObject, there is a function doc(o) to that returns a help string at runtime (this has to be called "lazily"...i.e., when help is requested, not when the object is created). Is there any way to fix Base.Docs so that this or a similar method could be called when you do ?o?

@MichaelHatherly
Copy link

In that case, yes we'd need to add support for that in Base.Docs. I've not got much time at the moment to work on this myself at present though.

@malmaud
Copy link
Contributor Author

malmaud commented Jan 24, 2017

OK, we can do this now!

@stevengj
Copy link
Member

Awesome, thanks for getting this in!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants