|
1 | 1 | using StreamingSampling |
2 | 2 | using Documenter |
| 3 | +using DocumenterCitations |
| 4 | +using Literate |
3 | 5 |
|
4 | | -DocMeta.setdocmeta!(StreamingSampling, :DocTestSetup, :(using StreamingSampling); recursive=true) |
5 | | - |
6 | | -makedocs(; |
7 | | - modules=[StreamingSampling], |
8 | | - authors="Emmanuel Lujan", |
9 | | - sitename="StreamingSampling.jl", |
10 | | - format=Documenter.HTML(; |
11 | | - canonical="https://emmanuellujan.github.io/StreamingSampling.jl", |
12 | | - edit_link="main", |
13 | | - assets=String[], |
14 | | - ), |
15 | | - pages=[ |
16 | | - "Home" => "index.md", |
17 | | - ], |
| 6 | +DocMeta.setdocmeta!( |
| 7 | + StreamingSampling, |
| 8 | + :DocTestSetup, |
| 9 | + :(using StreamingSampling); |
| 10 | + recursive = true, |
| 11 | +) |
| 12 | + |
| 13 | +ENV["BASE_PATH"] = joinpath(@__DIR__, "../") |
| 14 | + |
| 15 | +# Citations #################################################################### |
| 16 | +bib = CitationBibliography(joinpath(@__DIR__, "citation.bib")) |
| 17 | + |
| 18 | + |
| 19 | +# Generate examples ############################################################ |
| 20 | +const examples_path = joinpath(@__DIR__, "..", "examples") |
| 21 | +const output_path = joinpath(@__DIR__, "src/generated") |
| 22 | +function create_examples(examples, examples_path, output_path) |
| 23 | + for (_, example_path) in examples |
| 24 | + s = split(example_path, "/") |
| 25 | + sub_path, file_name = string(s[1:end-1]...), s[end] |
| 26 | + example_filepath = joinpath(examples_path, example_path) |
| 27 | + Literate.markdown(example_filepath, |
| 28 | + joinpath(output_path, sub_path), |
| 29 | + documenter = true) |
| 30 | + end |
| 31 | + examples = [title => joinpath("generated", replace(example_path, ".jl" => ".md")) |
| 32 | + for (title, example_path) in examples] |
| 33 | + return examples |
| 34 | +end |
| 35 | + |
| 36 | +# Basic examples |
| 37 | +examples = [ |
| 38 | + "Simple example" => "simple-example/simple-example.jl", |
| 39 | +] |
| 40 | +basic_examples = create_examples(examples, examples_path, output_path) |
| 41 | + |
| 42 | +# Make and deploy docs ######################################################### |
| 43 | + |
| 44 | +makedocs( |
| 45 | + root = joinpath(dirname(pathof(StreamingSampling)), "..", "docs"), |
| 46 | + source = "src", |
| 47 | + build = "build", |
| 48 | + clean = true, |
| 49 | + doctest = true, |
| 50 | + modules = [StreamingSampling], |
| 51 | + repo = "https://github.com/JuliaLabs/StreamingSampling.jl/blob/{commit}{path}#{line}", |
| 52 | + highlightsig = true, |
| 53 | + sitename = "StreamingSampling.jl", |
| 54 | + expandfirst = [], |
| 55 | + draft = false, |
| 56 | + pages = ["Home" => "index.md", |
| 57 | + "Install and run examples" => "install-and-run-examples.md", |
| 58 | + "Basic examples" => basic_examples, |
| 59 | + "API" => "api.md"], |
| 60 | + format = Documenter.HTML(; |
| 61 | + prettyurls = get(ENV, "CI", "false") == "true", |
| 62 | + canonical = "https://github.com/JuliaLabs/StreamingSampling.jl", |
| 63 | + assets = String[], |
| 64 | + ), |
| 65 | + plugins=[bib] |
18 | 66 | ) |
19 | 67 |
|
20 | 68 | deploydocs(; |
21 | | - repo="github.com/emmanuellujan/StreamingSampling.jl", |
22 | | - devbranch="main", |
| 69 | + repo = "https://github.com/JuliaLabs/StreamingSampling.jl", |
| 70 | + devbranch = "main", |
| 71 | + push_preview = true, |
23 | 72 | ) |
| 73 | + |
0 commit comments