diff --git a/src/DocumentationGenerator.jl b/src/DocumentationGenerator.jl index ce273aa1..f8ed7837 100644 --- a/src/DocumentationGenerator.jl +++ b/src/DocumentationGenerator.jl @@ -244,6 +244,18 @@ function generate_dependency_list(packages; end end +function with_juliaenv(func, temp_path=tempname()) + current_project = Base.active_project() + Pkg.activate(temp_path) + try + func() + catch ex + rethrow() + finally + Pkg.activate(current_project) + end +end + function start_builder(package, version; basepath = error("`basepath` is a required argument."), juliacmd = error("`juliacmd` is a required argument."), @@ -276,39 +288,41 @@ function start_builder(package, version; isdir(builddir) || mkpath(builddir) logfile = joinpath(builddir, "..", "$(version).log") - - thisproject = Base.active_project() - - ## api_url needs to be set to "-", since empty string should not be passed as CLI argument - pkgimagesopt = VERSION >= v"1.9" ? "--pkgimages=no" : "" - - cmd = ``` - $(juliacmd) - --project="$(thisproject)" - --color=no - --compiled-modules=no - $(isempty(pkgimagesopt) ? [] : pkgimagesopt) - -O0 - $workerfile - $uuid - $name - $url - $version - $builddir - $registry_path - $deployment_url - $src_prefix - $href_prefix - $(server_type) - $(isempty(api_url) ? "-" : api_url) - $(update_only ? "update" : "build") - ``` - process, task = run_with_timeout(cmd, - log=logfile, - name = string("docs build for ", name, "@", version, " (", uuid, ")"), - timeout = timeout, - max_timeout = max_timeout, - kill_timeout = kill_timeout) - return process + docgen_path = dirname(dirname(Base.find_package("DocumentationGenerator"))) + with_juliaenv() do + Pkg.develop(path=docgen_path) + Pkg.add("Pkg") + ## api_url needs to be set to "-", since empty string should not be passed as CLI argument + pkgimagesopt = VERSION >= v"1.9" ? "--pkgimages=no" : "" + cmd = ``` + $(juliacmd) + --project=$(Base.active_project()) + --color=no + --compiled-modules=no + $(isempty(pkgimagesopt) ? [] : pkgimagesopt) + -O0 + $workerfile + $uuid + $name + $url + $version + $builddir + $registry_path + $deployment_url + $src_prefix + $href_prefix + $(server_type) + $(isempty(api_url) ? "-" : api_url) + $(update_only ? "update" : "build") + + ``` + process, task = run_with_timeout(cmd, + log=logfile, + name = string("docs build for ", name, "@", version, " (", uuid, ")"), + timeout = timeout, + max_timeout = max_timeout, + kill_timeout = kill_timeout) + return process + end end end