Howto find documentation?


#1

In python, I can use help(function, module, etc) to get documentation. Even if not documented, I can use dir(object) to discover things about it (e.g., find what’s in a module).

How do I do this with julia?


#2

In the REPL, you can use ?function to get interactive documentation.


#3

This also works in the IJulia (Jupyter) notebook.


#4

Both in the REPL and in a script:

@doc function-name

But, really, the best way to discover how to read the documentation is to read the documentation :wink:


#5

As previously mentioned, in the REPL a line starting with ? is a documentation lookup. E.g. ?map will give you documentation about the function map; this also works with types. Interestingly, this also works with packages; you can do ?PackageName to see the readme for installed package PackageName.

Sometimes you don’t know the function you need. Then you can use apropos (not in help mode) to search. For example, maybe I don’t know how to create an identity matrix. apropos("identity") will give a list of functions which may match.

Sometimes you have an object and don’t know what you can do with it. You can try methodswith(typeof(object)) (or just methodswith(T) if T is a type) to see available methods.


#6

Since you also mentioned dir(object), you may also be interested in fieldnames(...) which lists all fields of an object or type:

type MyType
    x::Int
    y::Int
end

fieldnames(MyType)               # called on type ==>  [:x, :y]
fieldnames(MyType(1, 2))         # called on instances ==> [:x, :y]

In case you want to look at actual implementation, you can use @edit macro. For example:

@edit qr(rand(3,3))

will open qr.jl in configured editor and point you to the corresponding lines (if editor support it).


#7

I have had a blog post on this “in the works” for quite awhile. Right now it’s just a huge list of commands, and I want a little bit of a walk through it. Here’s a “public preview”

http://www.stochasticlifestyle.com/?p=96&preview=1&_ppp=8821b19e7b

If anyone wants to help me finish it, just let me know.


#8

There’s also a nice overview by @astrieanna here: http://www.juliabloggers.com/julia-helps/


#9

It’s not accessible


#10

Huh, public preview links must reset after a few days.

http://www.stochasticlifestyle.com/?p=96&preview=1&_ppp=9f2c7dab73


#11

Nice list! Seems to be missing “methods”.


#12

thanks, preview link’s been expired again. This is a replicate of ChrisRackauckas’s original post.