From 9b38d75942d96768dda6adf09270cbb06a32b9b4 Mon Sep 17 00:00:00 2001 From: Chris de Graaf Date: Fri, 28 Sep 2018 16:38:48 -0500 Subject: [PATCH] Use autodocs for generated documentation --- src/plugins/documenter.jl | 21 ++++++++++++--------- test/plugins/githubpages.jl | 11 ++--------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/plugins/documenter.jl b/src/plugins/documenter.jl index e7b57a8..a7eb250 100644 --- a/src/plugins/documenter.jl +++ b/src/plugins/documenter.jl @@ -32,7 +32,7 @@ function gen_plugin(p::Documenter, t::Template, pkg_name::AbstractString) "[]" end - text = """ + make = """ using Documenter, $pkg_name makedocs(; @@ -47,16 +47,19 @@ function gen_plugin(p::Documenter, t::Template, pkg_name::AbstractString) assets=$assets_string, ) """ + docs = """ + # $pkg_name.jl - gen_file(joinpath(dirname(docs_dir), "make.jl"), text) + ```@index + ``` - # If the README exists, use it as the default docs. - readme_path = joinpath(t.dir, pkg_name, "README.md") - if isfile(readme_path) - cp(readme_path, joinpath(docs_dir, "index.md")) - else - gen_file(joinpath(docs_dir, "index.md"), "# $pkg_name") - end + ```@autodocs + Modules = [$pkg_name] + ``` + """ + + gen_file(joinpath(dirname(docs_dir), "make.jl"), make) + gen_file(joinpath(docs_dir, "index.md"), docs) end function Base.show(io::IO, p::Documenter) diff --git a/test/plugins/githubpages.jl b/test/plugins/githubpages.jl index 8844608..9681b74 100644 --- a/test/plugins/githubpages.jl +++ b/test/plugins/githubpages.jl @@ -30,7 +30,7 @@ pkg_dir = joinpath(t.dir, test_pkg) @test isdir(joinpath(pkg_dir, "docs", "src")) @test isfile(joinpath(pkg_dir, "docs", "src", "index.md")) index = readchomp(joinpath(pkg_dir, "docs", "src", "index.md")) - @test index == "# $test_pkg" + @test occursin("autodocs", index) rm(joinpath(pkg_dir, "docs"); recursive=true) p = GitHubPages(; assets=[test_file]) @test gen_plugin(p, t, test_pkg) == ["docs/"] @@ -57,18 +57,11 @@ pkg_dir = joinpath(t.dir, test_pkg) temp_dir = mktempdir() t = Template(; user=me, dir=temp_dir, plugins=[GitHubPages()]) generate(test_pkg, t) - pkg_dir = joinpath(t.dir, test_pkg) # Check that the gh-pages branch exists. - repo = LibGit2.GitRepo(pkg_dir) + repo = LibGit2.GitRepo(joinpath(t.dir, test_pkg)) branches = map(b -> LibGit2.shortname(first(b)), LibGit2.GitBranchIter(repo)) @test in("gh-pages", branches) - - # Check that the generated docs root is just the copied README. - readme = read(joinpath(pkg_dir, "README.md"), String) - index = read(joinpath(pkg_dir, "docs", "src", "index.md"), String) - @test readme == index - rm(temp_dir; recursive=true) end end