Skip to content

Commit

Permalink
Fix package extension doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobjpeters committed Jun 14, 2024
1 parent 21e0e80 commit 367345d
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 46 deletions.
6 changes: 0 additions & 6 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,3 @@
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
Luxor = "ae8d54c2-7ccd-5906-9d76-62fc9837b5bc"
Typst_jll = "eb4b1da6-20f6-5c66-9826-fdb8ad410d0e"

[compat]
Documenter = "1"
Luxor = "3 - 4"
Typst_jll = "0.11"
35 changes: 19 additions & 16 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

using Base: get_extension
using Dates: Dates, Date, DateTime, Day, Hour, Minute, Second, Time, Week
using Documenter: Documenter, Docs, DocMeta, deploydocs, makedocs
using .Docs: HTML, Text
using .DocMeta: setdocmeta!
using Documenter: Documenter, deploydocs, makedocs
using LaTeXStrings: LaTeXStrings, LaTeXString, @L_str
using Luxor: Drawing, finish, julia_blue, julia_green, julia_purple, julia_red, rect, sethue
using Markdown: Markdown, MD, @md_str
using Typstry: _show_typst, enclose, join_with, preamble, typst_mime
using Typstry

const assets = joinpath(@__DIR__, "src", "assets")
const assets = joinpath(@__DIR__, "source", "assets")
const examples = Vector{Pair{Any, Type}}[]
const logo = joinpath(assets, "logo.svg")
const modes = instances(Mode)
Expand All @@ -19,11 +19,13 @@ const modules = [Typstry]
const extensions = ["Dates", "LaTeXStrings", "Markdown"]
const template = joinpath(assets, "template.typ")

setdocmeta!(Typstry, :DocTestSetup, :(using Typstry); recursive = true)
_setdocmeta!(_module, x) = setdocmeta!(_module, :DocTestSetup, x; recursive = true)

_setdocmeta!(Typstry, :(using Typstry))

for extension in extensions
_module = get_extension(Typstry, Symbol(extension, :Extension))
setdocmeta!(_module, :DocTestSetup, :(using Typstry; using $extension); recursive = true)
_setdocmeta!(_module, :(using Typstry; using $extension))
push!(modules, _module)
push!(examples, _module.examples)
end
Expand Down Expand Up @@ -124,16 +126,17 @@ for (package, examples) in append!([("Typstry", Typstry.examples)], zip(extensio
run(TypstCommand(["compile", "--font-path=" * julia_mono, "--format=svg", path]))
end

makedocs(; modules, sitename = "Typstry.jl", format = Documenter.HTML(edit_link = "main"), pages = [
"Home" => "index.md",
"Getting Started" => "getting_started.md",
"Tutorials" => ["Interface" => "tutorials/interface.md"],
"Manual" => map(page -> uppercasefirst(page) => joinpath("manual", page * ".md"),
["strings", "commands", "extensions", "internals"])
])

deploydocs(;
devbranch = "main",
devurl = "development",
repo = "github.com/jakobjpeters/Typstry.jl.git"
makedocs(; modules,
format = Documenter.HTML(edit_link = "main"),
pages = [
"Home" => "index.md",
"Getting Started" => "getting_started.md",
"Tutorials" => ["Interface" => "tutorials/interface.md"],
"Manual" => map(page -> uppercasefirst(page) => joinpath("manual", page * ".md"),
["strings", "commands", "extensions", "internals"])
],
sitename = "Typstry.jl",
source = "source"
)

deploydocs(; devurl = "development", repo = "github.com/jakobjpeters/Typstry.jl.git")
File renamed without changes.
4 changes: 4 additions & 0 deletions docs/src/index.md → docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ typst`compile input.typ output.pdf`
- Default `auto::Mode`?
- Automatically determine the Typst syntactic context
- Use a tree-sitter grammar or jll package
- Documenter.jl
- Backend
- Docstrings
- Implement Typst formatting for more types
- `Base`
- `AbstractDict`
Expand Down Expand Up @@ -116,4 +119,5 @@ typst`compile input.typ output.pdf`
- [LaTeXStrings.jl](https://github.com/JuliaStrings/LaTeXStrings.jl)
- [LatexPrint.jl](https://github.com/scheinerman/LatexPrint.jl)
- [MakieTeX.jl](https://github.com/JuliaPlots/MakieTeX.jl)
- Supports Typstry.jl
- [MathJaxRenderer.jl](https://github.com/MichaelHatherly/MathJaxRenderer.jl)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 0 additions & 7 deletions docs/src/assets/logo.svg

This file was deleted.

6 changes: 0 additions & 6 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
Documenter = "1"
28 changes: 17 additions & 11 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,22 @@ using Markdown: Markdown
using Test: @testset, @test, detect_ambiguities, detect_unbound_args
using Typstry

const MarkdownExtension = get_extension(Typstry, :MarkdownExtension)
setdocmeta!(
Typstry,
:DocTestSetup,
:(using Typstry),
recursive = true
)

_doctest(_module, name) = doctest(_module; manual = "source", testset = "$name.jl Doctests")

_doctest(Typstry, "Typstry")

for extension in [:Dates, :LaTeXStrings, :Markdown]
_module = get_extension(Typstry, Symbol(extension, "Extension"))
setdocmeta!(_module, :DocTestSetup, :(using Typstry; using $extension); recursive = true)
_doctest(_module, extension)
end

@testset "ExplicitImports.jl" begin
@test isnothing(check_all_explicit_imports_are_public(Typstry; ignore = (:MD, :Stateful,
Expand All @@ -28,16 +43,7 @@ const MarkdownExtension = get_extension(Typstry, :MarkdownExtension)
@test isnothing(check_no_stale_explicit_imports(Typstry))
end

@testset "`detect_ambiguities` and `detect_unbound_args`" begin
@testset "Test.jl" begin
@test isempty(detect_ambiguities(Typstry))
@test isempty(detect_unbound_args(Typstry))
end

setdocmeta!(
Typstry,
:DocTestSetup,
:(using Typstry),
recursive = true
)

doctest(Typstry)

0 comments on commit 367345d

Please sign in to comment.