-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve docs and tie things together
- Loading branch information
1 parent
2b220b5
commit 46f0ce2
Showing
11 changed files
with
126 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
/docs/Manifest.toml | ||
/docs/build/ | ||
/docs/package-lock.json | ||
/docs/src/source | ||
/docs/src/source | ||
*/node_modules/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ authors = ["Anshul Singhvi <[email protected]>", "Jacob Zelko <jacobszelko | |
version = "0.0.1-DEV" | ||
|
||
[deps] | ||
KernelDensity = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b" | ||
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
[deps] | ||
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" | ||
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
DocumenterVitepress = "4710194d-e776-4893-9690-8d956a29c365" | ||
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306" | ||
RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b" | ||
SwarmMakie = "0b1c068e-6a84-4e66-8136-5c95cafa83ed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,78 @@ | ||
using SwarmMakie | ||
using Documenter, DocumenterVitepress | ||
using Documenter, DocumenterVitepress, Literate | ||
using CairoMakie | ||
|
||
CairoMakie.activate!(type="svg", pt_per_unit = 0.75) | ||
|
||
DocMeta.setdocmeta!(SwarmMakie, :DocTestSetup, :(using SwarmMakie); recursive=true) | ||
|
||
|
||
# Now, we convert the source code to markdown files using Literate.jl | ||
source_path = joinpath(dirname(@__DIR__), "src") | ||
output_path = joinpath(@__DIR__, "src", "source") | ||
mkpath(output_path) | ||
|
||
literate_pages = Any[] | ||
|
||
# We don't want Literate to convert the code into Documenter blocks, so we use a custom postprocessor | ||
# to add the `@meta` block to the markdown file, which will be used by Documenter to add an edit link. | ||
function _add_meta_edit_link_generator(path) | ||
return function (input) | ||
return """ | ||
```@meta | ||
EditURL = "$(path).jl" | ||
``` | ||
""" * input # we add `.jl` because `relpath` eats the file extension, apparently :shrug: | ||
end | ||
end | ||
|
||
# First letter of `str` is made uppercase and returned | ||
ucfirst(str::String) = string(uppercase(str[1]), str[2:end]) | ||
|
||
function process_literate_recursive!(pages::Vector{Any}, path::String; source_path, output_path) | ||
if isdir(path) | ||
contents = [] | ||
process_literate_recursive!.((contents,), normpath.(readdir(path; join = true)); source_path, output_path) | ||
push!(pages, ucfirst(splitdir(path)[2]) => contents) | ||
elseif isfile(path) | ||
if endswith(path, ".jl") | ||
relative_path = relpath(path, source_path) | ||
output_dir = joinpath(output_path, splitdir(relative_path)[1]) | ||
Literate.markdown( | ||
path, output_dir; | ||
flavor = Literate.CommonMarkFlavor(), | ||
postprocess = _add_meta_edit_link_generator(joinpath(relpath(source_path, output_dir), relative_path)) | ||
) | ||
push!(pages, joinpath("source", splitext(relative_path)[1] * ".md")) | ||
end | ||
end | ||
end | ||
|
||
withenv("JULIA_DEBUG" => "Literate") do # allow Literate debug output to escape to the terminal! | ||
global literate_pages | ||
vec = [] | ||
process_literate_recursive!(vec, source_path; source_path, output_path) | ||
literate_pages = vec[1][2] # this is a hack to get the pages in the correct order, without an initial "src" folder. | ||
# TODO: We should probably fix the above in `process_literate_recursive!`. | ||
end | ||
|
||
makedocs(; | ||
modules=[SwarmMakie], | ||
authors="Anshul Singhvi <[email protected]>, Jacob Zelko <[email protected]>, Michael Krabbe Borregaard <[email protected]>, and contributors", | ||
sitename="SwarmMakie.jl", | ||
format=DocumenterVitepress.MarkdownVitepress(; | ||
repo = "https://github.com/asinghvi17/SwarmMakie.jl", | ||
devurl = "dev", | ||
devbranch = "main", | ||
), | ||
pages=[ | ||
"Introduction" => "introduction.md", | ||
"Algorithms" => "algorithms.md", | ||
"API Reference" => "api.md", | ||
"Source code" => literate_pages, | ||
], | ||
warnonly = true, | ||
) | ||
|
||
deploydocs(; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Algorithms | ||
|
||
SwarmMakie offers several beeswarm algorithms, which give different results. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# API Reference | ||
|
||
```@index | ||
``` | ||
|
||
```@autodocs; canonical=true | ||
Modules = [SwarmMakie] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters