Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ExternalDocstrings #43

Merged
merged 8 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ jobs:
uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.julia-version }}
# Use `JULIA_PKG_SERVER` mitigation implemented in julia-buildpkg:
- uses: julia-actions/julia-buildpkg@v1
- run: julia -e 'using Pkg; pkg"add [email protected]"'
- run: julia -e 'using Run; Run.prepare("test/environments/main")'
- run: julia -e 'using Run; Run.test(project="test/environments/main")'
Expand Down
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ version = "0.1.6-DEV"
[deps]
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
ExprTools = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
ExternalDocstrings = "e189563c-0753-4f5e-ad5c-be4293c83fb4"

[compat]
Compat = "2, 3"
ExprTools = "0.1"
ExternalDocstrings = "0.1"
julia = "1"

[extras]
Expand Down
9 changes: 7 additions & 2 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ git-tree-sha1 = "6f0517056812fd6aa3af23d4b70d5325a2ae4e95"
uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
version = "0.1.1"

[[ExternalDocstrings]]
git-tree-sha1 = "6d60956074103b5f61356ade2a9d0da8f6888661"
uuid = "e189563c-0753-4f5e-ad5c-be4293c83fb4"
version = "0.1.0"

[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Expand Down Expand Up @@ -79,10 +84,10 @@ deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[Maybe]]
deps = ["Compat", "ExprTools"]
deps = ["Compat", "ExprTools", "ExternalDocstrings"]
path = ".."
uuid = "334f122f-1118-46cc-837f-bff747ee6f78"
version = "0.1.0"
version = "0.1.6-DEV"

[[Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
Expand Down
2 changes: 2 additions & 0 deletions src/Maybe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ using ..Maybe: Maybe
using Base: @propagate_inbounds
using Base.Meta: isexpr
using ExprTools: combinedef, splitdef
using ExternalDocstrings: @define_docstrings

import ..Maybe: @something

Expand All @@ -65,5 +66,6 @@ finalize_implementations()
end

Implementations.finalize_package()
Implementations.@define_docstrings

end
24 changes: 0 additions & 24 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,10 @@ function finalize_implementations()
define_liftr()
end

# See ThreadsX.jl
function define_docstrings()
docstrings = Pair[:Maybe=>joinpath(dirname(@__DIR__), "README.md")]
docsdir = joinpath(@__DIR__, "docs")
for filename in readdir(docsdir)
stem, ext = splitext(filename)
ext == ".md" || continue
name = Symbol(stem)
if name in names(Maybe, all = true)
push!(docstrings, name => joinpath(docsdir, filename))
elseif name in names(Maybe.Extras, all = true)
push!(docstrings, :(Extras.$name) => joinpath(docsdir, filename))
end
end
for (name, path) in docstrings
include_dependency(path)
doc = read(path, String)
doc = replace(doc, r"^```julia"m => "```jldoctest $name")
doc = replace(doc, "<kbd>TAB</kbd>" => "_TAB_")
@eval Maybe $Base.@doc $doc $name
end
end

function finalize_package()
@eval Maybe begin
const T = Implementations.MaybeType
const $(Symbol("@?")) = Implementations.$(Symbol("@?"))
export $(Symbol("@?"))
end
define_docstrings()
end
7 changes: 6 additions & 1 deletion test/environments/main/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ git-tree-sha1 = "6f0517056812fd6aa3af23d4b70d5325a2ae4e95"
uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
version = "0.1.1"

[[ExternalDocstrings]]
git-tree-sha1 = "6d60956074103b5f61356ade2a9d0da8f6888661"
uuid = "e189563c-0753-4f5e-ad5c-be4293c83fb4"
version = "0.1.0"

[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Expand Down Expand Up @@ -79,7 +84,7 @@ deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[Maybe]]
deps = ["Compat", "ExprTools"]
deps = ["Compat", "ExprTools", "ExternalDocstrings"]
path = "../../.."
uuid = "334f122f-1118-46cc-837f-bff747ee6f78"
version = "0.1.0"
Expand Down