Building documentation on travis via Documenter: can't find the installed packages

I would very much so appreciate some help with building documentation on Travis. I have this package which the only thing it does is host the documentation: https://github.com/JuliaMusic/JuliaMusic_documentation.jl

with source

module JuliaMusic_documentation

using Reexport
@reexport using MIDI, MotifSequenceGenerator, MusicManipulations

end

(all the above packages are in the REQUIRE).

My travis build is trivial, it has no “script”, (uses the default) and after that I have

after_success:
  - julia -e 'Pkg.add("Documenter"); Pkg.add("Literate")'
  - julia -e 'cd(Pkg.dir("JuliaMusic_documentation")); include(joinpath("docs", "make.jl"))'

My make.jl is

using JuliaMusic_documentation

using Documenter, Literate

docdir = @__DIR__
docdir *= "/src/"

tobe = ["motif/musicexample.jl"]

for file in tobe
    f = docdir*file
    Literate.markdown(f, dirname(f))
end

makedocs(modules=[JuliaMusic_documentation], doctest=false)

#%% Deploy

deploydocs(
    deps   = Deps.pip("Tornado>=4.0.0,<5.0.0", "mkdocs",
    "mkdocs-material" ,"python-markdown-math", "pygments", "pymdown-extensions"),
    repo   = "github.com/JuliaMusic/JuliaMusic_documentation.jl.git",
    julia  = "nightly",
    osname = "linux"
)

Here is the problem: When I run on travis, it tells me that when documeter runs, it can’t find the packages MIDI, MusicManipulations, etc. I don’t know why!

WARNING: importing deprecated binding Base.gamma into Combinatorics.
Documenter: setting up build directory.
Documenter: expanding markdown templates.
 !! failed to run code block.
ArgumentError("Package MusicManipulations not found in current path:\n- Run `Pkg.add(\"MusicManipulations\")` to install the MusicManipulations package.\n") [src/mm/quantizing.md]
 !! failed to run code block.
ArgumentError("Package MIDI not found in current path:\n- Run `Pkg.add(\"MIDI\")` to install the MIDI package.\n") [src/midi/notes.md]
 !! failed to run code block.
UndefVarError(:midi) [src/midi/notes.md]
 !! failed to run code block.

The travis fail is here: Travis CI - Test and Deploy Your Code with Confidence

Changing my Travis.yml to

after_success:
  - julia -e 'Pkg.add("Documenter"); Pkg.add("Literate")'
  - julia -e 'Pkg.add("MIDI"); Pkg.add("MotifSequenceGenerator"); Pkg.add("MusicManipulations")'
  - julia -e 'cd(Pkg.dir("JuliaMusic_documentation")); include(joinpath("docs", "make.jl"))'

solved the problem. But why? It seems that I lack fundamental understanding of the new package system.

Since my REQUIRE has

julia 0.7-beta2
Reexport
MIDI 0.8
MotifSequenceGenerator 0.1
MusicManipulations 0.1

and since the module JuliaMusic_documentation does

module JuliaMusic_documentation

using Reexport
@reexport using MIDI, MotifSequenceGenerator, MusicManipulations

end

Shouldn’t the moment I do using JuliaMusic_documentation have access to all names from e.g. MIDI, including MIDI itself? Why is Documenter complaining?

The problem is that you’re importing package dependencies in the @example blocks (e.g. using MusicManipulations in src/mm/quantizing.md). When building docs on 0.7, if you need to do a import/using on a package dependency directly, you first need to pkg add them explicitly, as if they are an external dependency (just like you would in the REPL).

So I think the best course of action would be to add all the dependencies you use directly in the docs as Pkg.add()s in the after_success part.

1 Like

Or later, when the Project.toml story is finished, you would not need to add but just have them in the project file.