|
| 1 | +#!/usr/bin/env julia |
| 2 | +# |
| 3 | +# |
| 4 | + |
| 5 | +using Pkg |
| 6 | +using Plots, RecipesBase, Manifolds, ManifoldsBase, Documenter, PythonPlot |
| 7 | +using ManifoldsGPU |
| 8 | +using DocumenterCitations, DocumenterInterLinks |
| 9 | +# required for loading methods that handle differential equation solving |
| 10 | +# required for loading the manifold tests functions |
| 11 | +using Test |
| 12 | +ENV["GKSwstype"] = "100" |
| 13 | + |
| 14 | +# (e) add CONTRIBUTING.md and NEWS.md to docs |
| 15 | + |
| 16 | +function add_links(line::String, url::String = "https://github.com/JuliaManifolds/ManifoldsGPU.jl") |
| 17 | + # replace issues (#XXXX) -> ([#XXXX](url/issue/XXXX)) |
| 18 | + while (m = match(r"\(\#([0-9]+)\)", line)) !== nothing |
| 19 | + id = m.captures[1] |
| 20 | + line = replace(line, m.match => "([#$id]($url/issues/$id))") |
| 21 | + end |
| 22 | + # replace ## [X.Y.Z] -> with a link to the release [X.Y.Z](url/releases/tag/vX.Y.Z) |
| 23 | + while (m = match(r"\#\# \[([0-9]+.[0-9]+.[0-9]+)\] (.*)", line)) !== nothing |
| 24 | + tag = m.captures[1] |
| 25 | + date = m.captures[2] |
| 26 | + line = replace(line, m.match => "## [$tag]($url/releases/tag/v$tag) ($date)") |
| 27 | + end |
| 28 | + return line |
| 29 | +end |
| 30 | + |
| 31 | +generated_path = joinpath(@__DIR__, "src", "misc") |
| 32 | +base_url = "https://github.com/JuliaManifolds/ManifoldsGPU.jl/blob/main/" |
| 33 | +isdir(generated_path) || mkdir(generated_path) |
| 34 | +for fname in ["NEWS.md"] |
| 35 | + open(joinpath(generated_path, fname), "w") do io |
| 36 | + # Point to source license file |
| 37 | + println( |
| 38 | + io, |
| 39 | + """ |
| 40 | + ```@meta |
| 41 | + EditURL = "$(base_url)$(fname)" |
| 42 | + ``` |
| 43 | + """, |
| 44 | + ) |
| 45 | + # Write the contents out below the meta block |
| 46 | + for line in eachline(joinpath(dirname(@__DIR__), fname)) |
| 47 | + println(io, add_links(line)) |
| 48 | + end |
| 49 | + end |
| 50 | +end |
| 51 | + |
| 52 | +# (f) final step: render the docs |
| 53 | +bib = CitationBibliography(joinpath(@__DIR__, "src", "references.bib"); style = :alpha) |
| 54 | +links = InterLinks( |
| 55 | + "ManifoldsBase" => ("https://juliamanifolds.github.io/ManifoldsBase.jl/stable/"), |
| 56 | + "Manifolds" => ("https://juliamanifolds.github.io/Manifolds.jl/stable/"), |
| 57 | +) |
| 58 | + |
| 59 | +# We'd like to build docs on CI, so we can't load the CUDA extension |
| 60 | +# The rendered docs need to be in the main module |
| 61 | +modules = [ |
| 62 | + ManifoldsGPU, |
| 63 | +] |
| 64 | + |
| 65 | +if modules isa Vector{Union{Nothing, Module}} |
| 66 | + error("At least one module has not been properly loaded: ", modules) |
| 67 | +end |
| 68 | + |
| 69 | +makedocs(; |
| 70 | + format = Documenter.HTML( |
| 71 | + prettyurls = (get(ENV, "CI", nothing) == "true") || ("--prettyurls" ∈ ARGS), |
| 72 | + assets = ["assets/favicon.ico", "assets/citations.css", "assets/link-icons.css"], |
| 73 | + search_size_threshold_warn = 1000 * 2^10, # raise slightly from 500 to 1 MiB |
| 74 | + size_threshold_warn = 200 * 2^10, # raise slightly from 100 to 200 KiB |
| 75 | + size_threshold = 300 * 2^10, # raise slightly 200 to 300 KiB |
| 76 | + ), |
| 77 | + modules = modules, |
| 78 | + authors = "Mateusz Baran, Shiwen An, and contributors.", |
| 79 | + sitename = "ManifoldsGPU.jl", |
| 80 | + pages = [ |
| 81 | + "Home" => "index.md", |
| 82 | + "Miscellanea" => [ |
| 83 | + "Changelog" => "misc/NEWS.md", |
| 84 | + "Internals" => "misc/internals.md", |
| 85 | + "References" => "misc/references.md", |
| 86 | + ], |
| 87 | + ], |
| 88 | + plugins = [bib, links], |
| 89 | +) |
| 90 | +deploydocs(repo = "github.com/JuliaManifolds/ManifoldsGPU.jl.git", push_preview = true) |
| 91 | +#back to main env |
| 92 | +Pkg.activate() |
0 commit comments