Problem using Documenter.jl

I am doing a project in julia, and was attempting to use doctest.jl for documentation. I was following the intstructions on github, and had everything working until running make.jl from the docs directory. Here is the code I used:

julia> cd("C:\\Arya's desktop\\Arya\\Programming\\Julia\\ConsistentSampler\\docs")

julia> make.jl
ERROR: UndefVarError: make not defined

Here is my folder structure:
C:\Arya’s desktop\Arya\Programming\Julia\ConsistentSampler\src: consistent_sampler.jl, demo_consistent_sampler.jl
C:\Arya’s desktop\Arya\Programming\Julia\ConsistentSampler\docs: index.md, make.jl
C:\Arya’s desktop\Arya\Programming\Julia\ConsistentSampler\docs\src: empty

Could anyone please let me know what to do?

1 Like

You should use include("make.jl").

A full working example is available here: https://github.com/juliamatlab/MatLang/tree/master/docs

Follow my instructions here:

it is better to have two make.jl and makeLocal.jl. makeLocal.jl can be the same as this link’s code:


But for make.jl, we should remove 1st 4 lines of code

My instructions are as follows:

To build the documentation locally

Running inside Julia REPL:

cd to docs folder cd("path to docs\\MatLang\\docs") and run the following command:

include("makeLocal.jl") 

Running inside OS Terminal:

cd to docs folder using OS terminal and run the following command (Julia path should be added to OS path):

julia --color=yes makeLocal.jl

Alternatively, you can use make.jl but using the following method:
cd to package folder using OS terminal and run the following commands:

julia -e 'using Pkg; Pkg.activate(); push!(LOAD_PATH, pwd());'
julia --project=docs/ -e 'using Pkg; Pkg.activate();  push!(LOAD_PATH,pwd());'

julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate();'
julia --project=docs/ --color=yes docs/make.jl

To build the documentation online using Travis

Use this Travis script:

- julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd()));
                                               Pkg.instantiate()'
- julia --project=docs/ docs/make.jl
4 Likes

Thank you so much. It works. You are a life saver!:pray:

1 Like

This is generally not needed, you can just start your julia process with that project activated, eg

julia --project=@. make.jl

when you are in docs/.

3 Likes

Neither of those lines does anything persistent, and are not needed.

1 Like

Without those, user will run into errors:
Ruining 3rd line without the first two:

julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate();'
ERROR: expected a `name` entry in project file at C:\Users\yahyaaba\Documents\GitHub\MatLang\docs\Project.toml
Stacktrace:
 [1] pkgerror(::String) at C:\Julia-1.2.0\share\julia\stdlib\v1.2\Pkg\src\Types.jl:112
 [2] (::getfield(Pkg.Types, Symbol("#_throw_package_err#69")){String})(::String) at C:\Julia-1.2.0\share\julia\stdlib\v1.2\Pkg\src\Types.jl:455
 [3] read_package(::String) at C:\Julia-1.2.0\share\julia\stdlib\v1.2\Pkg\src\Types.jl:458
 [4] parse_package!(::Pkg.Types.Context, ::Pkg.Types.PackageSpec, ::String) at C:\Julia-1.2.0\share\julia\stdlib\v1.2\Pkg\src\Types.jl:734
 [5] explicit_dev_path(::Pkg.Types.Context, ::Pkg.Types.PackageSpec) at C:\Julia-1.2.0\share\julia\stdlib\v1.2\Pkg\src\Types.jl:524
 [6] handle_repos_develop!(::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}, ::Bool) at C:\Julia-1.2.0\share\julia\stdlib\v1.2\Pkg\src\Types.jl:592
 [7] #develop#17(::Bool, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(Pkg.API.develop), ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at C:\Julia-1.2.0\share\julia\stdlib\v1.2\Pkg\src\API.jl:54
 [8] develop at C:\Julia-1.2.0\share\julia\stdlib\v1.2\Pkg\src\API.jl:39 [inlined]
 [9] #develop#16 at C:\Julia-1.2.0\share\julia\stdlib\v1.2\Pkg\src\API.jl:36 [inlined]
 [10] develop at C:\Julia-1.2.0\share\julia\stdlib\v1.2\Pkg\src\API.jl:36 [inlined]
 [11] #develop#12 at C:\Julia-1.2.0\share\julia\stdlib\v1.2\Pkg\src\API.jl:33 [inlined]
 [12] develop(::Pkg.Types.PackageSpec) at C:\Julia-1.2.0\share\julia\stdlib\v1.2\Pkg\src\API.jl:33
 [13] top-level scope at none:1

This gives an error:

 julia --project=@. make.jl

ERROR: LoadError: ArgumentError: Package MatLang [05b439c0-bb3c-11e9-1d8d-1f0a9ebca87a] is required but does not seem to be installed:

  • Run Pkg.instantiate() to install all recorded dependencies.

Stacktrace:
[1] _require(::Base.PkgId) at .\loading.jl:982
[2] require(::Base.PkgId) at .\loading.jl:911
[3] require(::Module, ::Symbol) at .\loading.jl:906
[4] include at .\boot.jl:328 [inlined]
[5] include_relative(::Module, ::String) at .\loading.jl:1094
[6] include(::Module, ::String) at .\Base.jl:31
[7] exec_options(::Base.JLOptions) at .\client.jl:295
[8] _start() at .\client.jl:464
in expression starting at C:\Users\yahyaaba\Documents\GitHub\MatLang\docs\make.jl:1

The code that I wrote works for any situation, no matter if the package is installed or not. That is what a beginner needs.

No they don’t. The error you’re seeing is because you were already in the docs/ directory when you called that line. The error is thrown by the Pkg.develop call, which tries to develop the docs/Project.toml (implying that pwd() was already docs/). That fails as it is not a package and is missing the name entry.

Yes, the implicit assumption is that you have deved your package in the global environment.

See

for the recommended setup.