CodeTracking.jl
CodeTracking.jl copied to clipboard
"definition" cannot read function defined within Jupyter notebook
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.
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.
The .ipynb files are auto saved into a .ipynb_checkpoints local directory and marked with the In[#] execution_count number. Would that be sufficient?
Yeah, I don't know how often they are autosaved but parsing that would indeed be a possibility.
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:

But in the REPL, it works perfectly. Did you find a solution or a possible reason for this by now?
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.
I guess code_string should return nothing if definition returns nothing though?