From 367345de3c1a0cd37a762dd24ee612255806ba23 Mon Sep 17 00:00:00 2001 From: Jakob Peters Date: Thu, 13 Jun 2024 17:17:42 -0700 Subject: [PATCH] Fix package extension doctests --- docs/Project.toml | 6 ---- docs/make.jl | 35 +++++++++++---------- docs/{src => source}/getting_started.md | 0 docs/{src => source}/index.md | 4 +++ docs/{src => source}/manual/commands.md | 0 docs/{src => source}/manual/extensions.md | 0 docs/{src => source}/manual/internals.md | 0 docs/{src => source}/manual/strings.md | 0 docs/{src => source}/tutorials/interface.md | 0 docs/src/assets/logo.svg | 7 ----- test/Project.toml | 6 ---- test/runtests.jl | 28 ++++++++++------- 12 files changed, 40 insertions(+), 46 deletions(-) rename docs/{src => source}/getting_started.md (100%) rename docs/{src => source}/index.md (97%) rename docs/{src => source}/manual/commands.md (100%) rename docs/{src => source}/manual/extensions.md (100%) rename docs/{src => source}/manual/internals.md (100%) rename docs/{src => source}/manual/strings.md (100%) rename docs/{src => source}/tutorials/interface.md (100%) delete mode 100644 docs/src/assets/logo.svg diff --git a/docs/Project.toml b/docs/Project.toml index 7db2580..af6c92f 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -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" diff --git a/docs/make.jl b/docs/make.jl index 5720b1b..8c466a6 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -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) @@ -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 @@ -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") diff --git a/docs/src/getting_started.md b/docs/source/getting_started.md similarity index 100% rename from docs/src/getting_started.md rename to docs/source/getting_started.md diff --git a/docs/src/index.md b/docs/source/index.md similarity index 97% rename from docs/src/index.md rename to docs/source/index.md index cf4306f..f8bf33f 100644 --- a/docs/src/index.md +++ b/docs/source/index.md @@ -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` @@ -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) diff --git a/docs/src/manual/commands.md b/docs/source/manual/commands.md similarity index 100% rename from docs/src/manual/commands.md rename to docs/source/manual/commands.md diff --git a/docs/src/manual/extensions.md b/docs/source/manual/extensions.md similarity index 100% rename from docs/src/manual/extensions.md rename to docs/source/manual/extensions.md diff --git a/docs/src/manual/internals.md b/docs/source/manual/internals.md similarity index 100% rename from docs/src/manual/internals.md rename to docs/source/manual/internals.md diff --git a/docs/src/manual/strings.md b/docs/source/manual/strings.md similarity index 100% rename from docs/src/manual/strings.md rename to docs/source/manual/strings.md diff --git a/docs/src/tutorials/interface.md b/docs/source/tutorials/interface.md similarity index 100% rename from docs/src/tutorials/interface.md rename to docs/source/tutorials/interface.md diff --git a/docs/src/assets/logo.svg b/docs/src/assets/logo.svg deleted file mode 100644 index 63c3cc8..0000000 --- a/docs/src/assets/logo.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/test/Project.toml b/test/Project.toml index 37779d6..e8303ea 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -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" diff --git a/test/runtests.jl b/test/runtests.jl index b35ecdc..8abb460 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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, @@ -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)