I am following the official Documenter.jl’s Guide and I am running into problems.
To give some context:
I have a numerical “library” I made for my research I want to make public with Documenter.jl using GitHub. It is very basic, essentially a
/src
folder containing all the source code for the simulations and a/experiments
folder that usesinclude("/src/src_file.jl")
to perform various numerical experiments.
What I’ve tried:
I figured that in essence my code structure is the same as if everything was inside a massive
src.jl
file which gets called byexperiment_1.jl
files. So I created the following minimal example:
repo/
│── repo_env/ # Environment folder (only contains Documenter.jl)
│ │── Manifest.toml
│ │── Project.toml
│── src/
│ │── src.jl # Module file
│ │── test.jl # A file the module calls
│── docs/
│ │── make.jl # The Guide example
with the following contents:
# src/src.jl
module Test_Module
export test
include("test.jl")
end # end of module
# src/test.jl
function test(x)
return 2*x
end
push!(LOAD_PATH,"../src/")
using Documenter, .Test_Module
makedocs(sitename="My Documentation")
The reason I made a module (something I wouldnt normally do since I dont use/understand them properly) is because I sense that it is needed. In fact, the official Guide mentions that “Firstly, we need a Julia module to document. This could be a package generated via
PkgDev.generate
or a single.jl
script accessible via Julia’sLOAD_PATH
.”
Results/errors:
To be fair I’ve tried a plethora of little tweaks and none work with slightly different errors. I’m gonna put this one as it’s the one I expect to learn the most from:
(base) alex@Lord-Commander-Flagship Quantum_Geometric_Complexity % julia --project=repo_env docs/make.jl
ERROR: LoadError: UndefVarError: `Test_Module` not defined in `Main`
Suggestion: check for spelling errors or missing imports.
in expression starting at /Users/alex/Documents/GitHub/Quantum_Geometric_Complexity/docs/make.jl:3
So it’s obviously not finding the module
Test_Module
despite following the official Guide advice on this issue:
"
If your source directory is not accessible through Julia’s LOAD_PATH, you might wish to add the following line at the top of make.jlpush!(LOAD_PATH,"../src/")
"
Help!
I would love to see a minimal working example for something as basic as what I am doing and understand why I get the errors I get.
Unsolicited opinion:
For what is worth, I believe that the way the official Guide is written, it implicitly assumes the reader is versed in Modules, Packages and what not. This is fine and should probably be a good idea to learn anyways. However, there are many Julia users like myself who limit to writting efficient (yet unproffessional) numerical code and wish to share it. I know many Julia users in my enviroment that would follow a very similar workflow as what I described in the context above. Perhaps this could be addressed! (I would love to if I manage to understand what’s going on…)