Git Product home page Git Product logo

Comments (12)

stevengj avatar stevengj commented on June 16, 2024

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?

from pycall.jl.

StefanKarpinski avatar StefanKarpinski commented on June 16, 2024

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

from pycall.jl.

stevengj avatar stevengj commented on June 16, 2024

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

from pycall.jl.

StefanKarpinski avatar StefanKarpinski commented on June 16, 2024

Hahah. Yes, that is what I meant.

from pycall.jl.

malmaud avatar malmaud commented on June 16, 2024

haha

from pycall.jl.

kskyten avatar kskyten commented on June 16, 2024

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?

from pycall.jl.

stevengj avatar stevengj commented on June 16, 2024

@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?

from pycall.jl.

MichaelHatherly avatar MichaelHatherly commented on June 16, 2024

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.

from pycall.jl.

stevengj avatar stevengj commented on June 16, 2024

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?

from pycall.jl.

MichaelHatherly avatar MichaelHatherly commented on June 16, 2024

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.

from pycall.jl.

malmaud avatar malmaud commented on June 16, 2024

OK, we can do this now!

from pycall.jl.

stevengj avatar stevengj commented on June 16, 2024

Awesome, thanks for getting this in!

from pycall.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.