diff --git a/docs/make.jl b/docs/make.jl index 3f5e2a52..7a98b16c 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -2,67 +2,85 @@ push!(LOAD_PATH, "../src/") using Documenter, POMDPs, POMDPTools -makedocs( - modules = [POMDPs, POMDPTools], - format = Documenter.HTML(), - sitename = "POMDPs.jl", - pages = [ - ############################################## - ## MAKE SURE TO SYNC WITH docs/src/index.md ## - ############################################## - "Basics" => [ - "index.md", - "install.md", - "get_started.md", - "concepts.md" - ], - - "Defining (PO)MDP Models" => [ - "def_pomdp.md", - "interfaces.md", - ], - - "Writing Solvers" => [ - "def_solver.md", - "offline_solver.md", - "online_solver.md" - ], - - "Writing Belief Updaters" => [ - "def_updater.md" - ], +page_order = [ + "POMDPs.jl" => "index.md", + "Basics" => [ + "install.md", + "get_started.md", + "concepts.md" + ], + "Defining (PO)MDP Models" => [ + "def_pomdp.md", + "interfaces.md" + ], + "Writing Solvers" => [ + "def_solver.md", + "offline_solver.md", + "online_solver.md" + ], + "Writing Belief Updaters" => [ + "def_updater.md" + ], + "Analyzing Results" => [ + "simulation.md", + "run_simulation.md", + "policy_interaction.md" + ], + "Examples and Gallery" => [ + "examples.md", + "example_defining_problems.md", + "example_solvers.md", + "example_simulations.md", + "example_gridworld_mdp.md", + "gallery.md" + ], + "POMDPTools" => [ + "POMDPTools/index.md", + "POMDPTools/distributions.md", + "POMDPTools/model.md", + "POMDPTools/visualization.md", + "POMDPTools/beliefs.md", + "POMDPTools/policies.md", + "POMDPTools/simulators.md", + "POMDPTools/common_rl.md", + "POMDPTools/testing.md" + ], + "References" => [ + "faq.md", + "api.md" + ] +] - "Analyzing Results" => [ - "simulation.md", - "run_simulation.md", - "policy_interaction.md" - ], - - "Examples and Gallery" => [ - "examples.md", - "example_defining_problems.md", - "example_solvers.md", - "example_simulations.md", - "example_gridworld_mdp.md", - "gallery.md" - ], +# Append the @contents blocks to the index.md file +index_md_file = joinpath(@__DIR__, "src", "index.md") - "POMDPTools" => [ - "POMDPTools/index.md", - "POMDPTools/distributions.md", - "POMDPTools/model.md", - "POMDPTools/visualization.md", - "POMDPTools/beliefs.md", - "POMDPTools/policies.md", - "POMDPTools/simulators.md", - "POMDPTools/common_rl.md", - "POMDPTools/testing.md" - ], +# Copy original index.md to restore it after the build +original_index_md_file = joinpath(@__DIR__, "src", "original_index.md") +cp(index_md_file, original_index_md_file) - "faq.md", - "api.md", +open(index_md_file, "a") do f + write(f, "\n\n") + # Loop over the sections and generate a @contents block for each. + for (section, pages) in page_order + if section isa String && pages isa Vector{String} # Only sections with pages + write(f, "### $(section)\n\n") + write(f, "```@contents\n") + write(f, "Pages = $(pages)\n") + if section == "Defining (PO)MDP Models" + write(f, "Depth = 3\n") + else + write(f, "Depth = 2\n") + end + write(f, "```\n\n") + end + end +end - ], +makedocs( + modules = [POMDPs, POMDPTools], + format = Documenter.HTML(), + sitename = "POMDPs.jl", + pages = page_order, warnonly = [:missing_docs] ) @@ -70,3 +88,8 @@ deploydocs( repo = "github.com/JuliaPOMDP/POMDPs.jl.git", push_preview=true ) + +# Restore the original index.md file +if isfile(original_index_md_file) + mv(original_index_md_file, index_md_file, force=true) +end diff --git a/docs/src/index.md b/docs/src/index.md index 7d162e36..d449682d 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -20,49 +20,3 @@ Documentation comes in three forms: 1. An explanatory guide is available in the sections outlined below. 2. How-to examples are available throughout this documentation with specicic examples in [Examples](@ref examples_section) and [Gallery of POMDPs.jl Problems](@ref). 3. Reference docstrings for the entire POMDPs.jl interface are available in the [API Documentation](@ref) section. - -!!! note - When updating these documents, make sure this is synced with [docs/make.jl](https://github.com/JuliaPOMDP/POMDPs.jl/blob/master/docs/make.jl)!! - -### Basics - -```@contents -Pages = ["install.md", "get_started.md", "concepts.md"] -``` - -### Defining POMDP Models - -```@contents -Pages = [ "def_pomdp.md", "interfaces.md"] -Depth = 3 -``` - -### Writing Solvers and Updaters - -```@contents -Pages = [ "def_solver.md", "offline_solver.md", "online_solver.md", "def_updater.md" ] -``` - -### Analyzing Results - -```@contents -Pages = [ "simulation.md", "run_simulation.md", "policy_interaction.md" ] -``` - -### Examples and Gallery - -```@contents -Pages = [ "examples.md", "example_defining_problems.md", "example_solvers.md", "example_simulations.md", "example_gridworld_mdp.md", "gallery.md"] -``` - -### POMDPTools - the standard library for POMDPs.jl - -```@contents -Pages = ["POMDPTools/index.md", "POMDPTools/distributions.md", "POMDPTools/model.md", "POMDPTools/visualization.md", "POMDPTools/beliefs.md", "POMDPTools/policies.md", "POMDPTools/simulators.md", "POMDPTools/common_rl.md", "POMDPTools/testing.md"] -``` - -### Reference - -```@contents -Pages = ["faq.md", "api.md"] -```