CodeTracking.jl icon indicating copy to clipboard operation
CodeTracking.jl copied to clipboard

"definition" cannot read function defined within Jupyter notebook

Open mossr opened this issue 5 years ago • 6 comments

When calling definition in a Jupyter notebook:

f(x,y) = x^2 + y^2
definition(String, @which(f(Int,Int)))

I get the following error: SystemError: opening file "In[52]": No such file or directory

Seems to just not handled reading from the notebook's In because it works when reading from functions defined purely in the REPL.

mossr avatar Jan 29 '20 01:01 mossr

It feels a bit tricky to support this. For the REPL, we can look in the history file but for a potentially unsaved notebook file I don't see where we would find the source.

KristofferC avatar Jan 29 '20 10:01 KristofferC

The .ipynb files are auto saved into a .ipynb_checkpoints local directory and marked with the In[#] execution_count number. Would that be sufficient?

mossr avatar Jan 29 '20 18:01 mossr

Yeah, I don't know how often they are autosaved but parsing that would indeed be a possibility.

KristofferC avatar Jan 29 '20 18:01 KristofferC

I get a pretty similar error when calling

f(x) = x
code_string(f, (Float64,))

in a Documenter.jl setup. Error: MethodError: no method matching getindex(::Nothing, ::Int64)

Getting the same when calling the code in JupyterNotebook: grafik

But in the REPL, it works perfectly. Did you find a solution or a possible reason for this by now?

bennibolm avatar Mar 14 '22 10:03 bennibolm

I don't think anyone has tried. From the discussion above it seems likely to require a new feature, and that requires someone who uses IJulia being willing to contribute.

timholy avatar Mar 14 '22 12:03 timholy

I guess code_string should return nothing if definition returns nothing though?

KristofferC avatar Mar 14 '22 13:03 KristofferC