Use a separate project for deploying docs

This commit is contained in:
Chris de Graaf 2018-12-14 14:55:13 -06:00
parent 44a03f1a5d
commit adb2581a75
4 changed files with 30 additions and 16 deletions

View File

@ -74,9 +74,9 @@ uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
[[Tables]] [[Tables]]
deps = ["Requires", "Test"] deps = ["Requires", "Test"]
git-tree-sha1 = "c7fb447deab835fa70ce6717e78c68b0f466a42c" git-tree-sha1 = "940944e6b68a35046282897a2218891c7cf14a32"
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
version = "0.1.11" version = "0.1.12"
[[Test]] [[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]

View File

@ -12,7 +12,7 @@ matrix:
fast_finish: true fast_finish: true
notifications: notifications:
email: false email: false
{{#AFTER}} {{#COVERAGE}}
after_success: after_success:
{{#CODECOV}} {{#CODECOV}}
- julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())' - julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())'
@ -20,7 +20,16 @@ after_success:
{{#COVERALLS}} {{#COVERALLS}}
- julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder())' - julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder())'
{{/COVERALLS}} {{/COVERALLS}}
{{/COVERAGE}}
{{#DOCUMENTER}} {{#DOCUMENTER}}
- julia -e 'if VERSION >= v"0.7.0"; using Pkg; ps=Pkg.PackageSpec(name="Documenter", version="0.19"); Pkg.add(ps); Pkg.pin(ps); else; Pkg.add("Documenter"); end; include(joinpath("docs", "make.jl"))' jobs:
include:
- stage: Documentation
julia: {{VERSION}}
script: julia --project=docs -e '
using Pkg;
Pkg.develop(PackageSpec(path=pwd()));
Pkg.instantiate();
include("docs/make.jl");'
after_success: skip
{{/DOCUMENTER}} {{/DOCUMENTER}}
{{/AFTER}}

View File

@ -20,14 +20,23 @@ abstract type Documenter <: CustomPlugin end
function gen_plugin(p::Documenter, t::Template, pkg_name::AbstractString) function gen_plugin(p::Documenter, t::Template, pkg_name::AbstractString)
path = joinpath(t.dir, pkg_name) path = joinpath(t.dir, pkg_name)
docs_dir = joinpath(path, "docs", "src") docs_dir = joinpath(path, "docs")
mkpath(docs_dir) mkpath(docs_dir)
# Create the documentation project.
proj = Base.current_project()
try
Pkg.activate(docs_dir)
Pkg.add("Documenter")
finally
proj === nothing ? Pkg.activate() : Pkg.activate(proj)
end
tab = repeat(" ", 4) tab = repeat(" ", 4)
assets_string = if !isempty(p.assets) assets_string = if !isempty(p.assets)
mkpath(joinpath(docs_dir, "assets")) mkpath(joinpath(docs_dir, "src", "assets"))
for file in p.assets for file in p.assets
cp(file, joinpath(docs_dir, "assets", basename(file))) cp(file, joinpath(docs_dir, "src", "assets", basename(file)))
end end
# We want something that looks like the following: # We want something that looks like the following:
@ -55,7 +64,7 @@ function gen_plugin(p::Documenter, t::Template, pkg_name::AbstractString)
kws = [keys(p.additional_kwargs)...] kws = [keys(p.additional_kwargs)...]
valid_keys = filter(k -> !in(Symbol(k), STANDARD_KWS), kws) valid_keys = filter(k -> !in(Symbol(k), STANDARD_KWS), kws)
if length(p.additional_kwargs) > length(valid_keys) if length(p.additional_kwargs) > length(valid_keys)
invalid_keys = filter(k -> in(Symbol(k), STANDARD_KWS), kws) invalid_keys = filter(k -> Symbol(k) in STANDARD_KWS, kws)
@warn string( @warn string(
"Ignoring predefined Documenter kwargs ", "Ignoring predefined Documenter kwargs ",
join(map(repr, invalid_keys), ", "), join(map(repr, invalid_keys), ", "),
@ -72,7 +81,7 @@ function gen_plugin(p::Documenter, t::Template, pkg_name::AbstractString)
makedocs(; makedocs(;
modules=[$pkg_name], modules=[$pkg_name],
format=:html, format=Documenter.HTML(),
pages=[ pages=[
"Home" => "index.md", "Home" => "index.md",
], ],
@ -93,8 +102,8 @@ function gen_plugin(p::Documenter, t::Template, pkg_name::AbstractString)
``` ```
""" """
gen_file(joinpath(dirname(docs_dir), "make.jl"), make) gen_file(joinpath(docs_dir, "make.jl"), make)
gen_file(joinpath(docs_dir, "index.md"), docs) gen_file(joinpath(docs_dir, "src", "index.md"), docs)
end end
function Base.show(io::IO, p::Documenter) function Base.show(io::IO, p::Documenter)

View File

@ -50,10 +50,6 @@ function gen_plugin(p::GitHubPages, t::Template, pkg_name::AbstractString)
deploydocs(; deploydocs(;
repo="$(t.host)/$(t.user)/$pkg_name.jl", repo="$(t.host)/$(t.user)/$pkg_name.jl",
target="build",
julia="1.0",
deps=nothing,
make=nothing,
) )
""" """
) )