|
2 | 2 | # This Source Code Form is subject to the terms of the MIT License |
3 | 3 | # This source code is adapted from that of Plasmo.jl which can be found at https://github.com/plasmo-dev/Plasmo.jl/blob/main/docs/make.jl |
4 | 4 |
|
5 | | -using Documenter, Plasmo, Suppressor, Graphs |
6 | | -using Base: walkdir |
7 | | - |
8 | | -doc_pkg = get(ENV, "DOC_PKG", "PlasmoBenders") # default to PlasmoBenders |
9 | | - |
10 | | -if doc_pkg == "PlasmoBenders" |
11 | | - @info "Building docs for PlasmoBenders" |
12 | | - using PlasmoBenders |
13 | | - DocMeta.setdocmeta!(PlasmoBenders, :DocTestSetup, :(using PlasmoBenders); recursive=true) |
14 | | -elseif doc_pkg == "PlasmoSchwarz" |
15 | | - @info "Building docs for PlasmoSchwarz" |
16 | | - using PlasmoSchwarz |
17 | | - DocMeta.setdocmeta!(PlasmoSchwarz, :DocTestSetup, :(using PlasmoSchwarz); recursive=true) |
18 | | -else |
19 | | - error("Unsupported DOC_PKG=$(doc_pkg). Expected PlasmoBenders or PlasmoSchwarz.") |
20 | | -end |
| 5 | +using Documenter, Plasmo, Suppressor, Graphs, PlasmoBenders, PlasmoSchwarz |
21 | 6 |
|
22 | 7 | DocMeta.setdocmeta!(Plasmo, :DocTestSetup, :(using Plasmo); recursive=true) |
23 | | -DocMeta.setdocmeta!(Plasmo, :DocTestSetup, :(using Plasmo); recursive=true) |
24 | | - |
25 | | -pages_benders = [ |
26 | | - "Introduction" => "index.md", |
27 | | - "PlasmoBenders.jl" => [ |
28 | | - "Introduction" => "PlasmoBenders/introduction.md", |
29 | | - "Algorithm" => "PlasmoBenders/algorithm.md", |
30 | | - "Quickstart" => "PlasmoBenders/quickstart.md", |
31 | | - "Solver Options" => "PlasmoBenders/solver.md", |
32 | | - "Exploiting Graph Structure" => "PlasmoBenders/graph_structure.md", |
33 | | - "API Documentation" => "PlasmoBenders/api_docs.md", |
34 | | - "Tutorials" => [ |
35 | | - "Storage Operation" => "PlasmoBenders/storage_tutorial.md", |
36 | | - "Equipment Sizing" => "PlasmoBenders/sizing_tutorial.md" |
37 | | - ], |
38 | | - ], |
39 | | -] |
40 | | - |
41 | | -pages_schwarz = [ |
42 | | - "Introduction" => "index.md", |
43 | | - "PlasmoSchwarz.jl" => [ |
44 | | - "Introduction" => "PlasmoSchwarz/introduction.md", |
45 | | - "Quickstart" => "PlasmoSchwarz/quickstart.md", |
46 | | - "Algorithm" => "PlasmoSchwarz/algorithm.md", |
47 | | - "API Documentation" => "PlasmoSchwarz/api_docs.md", |
48 | | - ] |
49 | | -] |
| 8 | +DocMeta.setdocmeta!(PlasmoBenders, :DocTestSetup, :(using PlasmoBenders); recursive=true) |
| 9 | +DocMeta.setdocmeta!(PlasmoSchwarz, :DocTestSetup, :(using PlasmoSchwarz); recursive=true) |
50 | 10 |
|
51 | | -modules_sel = doc_pkg == "PlasmoBenders" ? [PlasmoBenders] : [PlasmoSchwarz] |
52 | | -pages_sel = doc_pkg == "PlasmoBenders" ? pages_benders : pages_schwarz |
53 | | - |
54 | | -# Build in a filtered temporary source directory to avoid processing pages |
55 | | -# of the other package when building docs for one package. |
56 | | -src_root = joinpath(@__DIR__, "src") |
57 | | -tmp_src = mktempdir() |
58 | | - |
59 | | -# Always include index.md |
60 | | -mkpath(tmp_src) |
61 | | -cp(joinpath(src_root, "index.md"), joinpath(tmp_src, "index.md"); force=true) |
62 | | - |
63 | | -# Include shared figures folder so relative image links work |
64 | | -fig_src = joinpath(src_root, "figures") |
65 | | -fig_dst = joinpath(tmp_src, "figures") |
66 | | -if isdir(fig_src) |
67 | | - mkpath(fig_dst) |
68 | | - for (root, dirs, files) in walkdir(fig_src) |
69 | | - rel = replace(root, fig_src => "") |
70 | | - target_root = joinpath(fig_dst, rel) |
71 | | - mkpath(target_root) |
72 | | - for f in files |
73 | | - cp(joinpath(root, f), joinpath(target_root, f); force=true) |
74 | | - end |
75 | | - end |
76 | | -end |
77 | | - |
78 | | -if doc_pkg == "PlasmoBenders" |
79 | | - # Copy only PlasmoBenders pages directory |
80 | | - src_dir = joinpath(src_root, "PlasmoBenders") |
81 | | - dest_dir = joinpath(tmp_src, "PlasmoBenders") |
82 | | - mkpath(dest_dir) |
83 | | - for (root, dirs, files) in walkdir(src_dir) |
84 | | - rel = replace(root, src_dir => "") |
85 | | - target_root = joinpath(dest_dir, rel) |
86 | | - mkpath(target_root) |
87 | | - for f in files |
88 | | - cp(joinpath(root, f), joinpath(target_root, f); force=true) |
89 | | - end |
90 | | - end |
91 | | -else |
92 | | - # Copy only PlasmoSchwarz pages directory |
93 | | - src_dir = joinpath(src_root, "PlasmoSchwarz") |
94 | | - dest_dir = joinpath(tmp_src, "PlasmoSchwarz") |
95 | | - mkpath(dest_dir) |
96 | | - for (root, dirs, files) in walkdir(src_dir) |
97 | | - rel = replace(root, src_dir => "") |
98 | | - target_root = joinpath(dest_dir, rel) |
99 | | - mkpath(target_root) |
100 | | - for f in files |
101 | | - cp(joinpath(root, f), joinpath(target_root, f); force=true) |
102 | | - end |
103 | | - end |
104 | | -end |
105 | | - |
106 | | -makedocs(; |
107 | | - sitename="PlasmoAlgorithms.jl - $(doc_pkg)", |
108 | | - modules=modules_sel, |
| 11 | +makedocs(; |
| 12 | + sitename="PlasmoAlgorithms.jl", |
| 13 | + modules=[PlasmoBenders], |
109 | 14 | doctest=true, |
110 | 15 | checkdocs=:export, |
111 | | - source=tmp_src, |
112 | | - format=Documenter.HTML(; prettyurls=get(ENV, "CI", nothing) == "true", edit_link = nothing), |
| 16 | + format=Documenter.HTML(; prettyurls=get(ENV, "CI", nothing) == "true"), |
113 | 17 | authors="Jordan Jalving and David Cole", |
114 | | - pages=pages_sel, |
| 18 | + pages=[ |
| 19 | + "Introduction" => "index.md", |
| 20 | + "PlasmoBenders.jl" => [ |
| 21 | + "Introduction" => "PlasmoBenders/introduction.md", |
| 22 | + "Algorithm" => "PlasmoBenders/algorithm.md", |
| 23 | + "Quickstart" => "PlasmoBenders/quickstart.md", |
| 24 | + "Solver Options" => "PlasmoBenders/solver.md", |
| 25 | + "Exploiting Graph Structure" => "PlasmoBenders/graph_structure.md", |
| 26 | + "API Documentation" => "PlasmoBenders/api_docs.md", |
| 27 | + "Tutorials" => [ |
| 28 | + "Storage Operation" => "PlasmoBenders/storage_tutorial.md", |
| 29 | + "Equipment Sizing" => "PlasmoBenders/sizing_tutorial.md" |
| 30 | + ], |
| 31 | + ], |
| 32 | + "PlasmoSchwarz.jl" => [ |
| 33 | + "Introduction" => "PlasmoSchwarz/introduction.md", |
| 34 | + "Quickstart" => "PlasmoSchwarz/quickstart.md", |
| 35 | + "Algorithm" => "PlasmoSchwarz/algorithm.md", |
| 36 | + "API Documentation" => "PlasmoSchwarz/api_docs.md", |
| 37 | + ] |
| 38 | + ], |
115 | 39 | ) |
116 | 40 |
|
117 | | -devurl = doc_pkg == "PlasmoBenders" ? "benders" : "schwarz" |
118 | | -deploydocs(; repo="github.com/plasmo-dev/PlasmoAlgorithms.jl.git", devurl=devurl) |
| 41 | +deploydocs(; repo="github.com/plasmo-dev/PlasmoAlgorithms.jl.git") |
0 commit comments