Skip to content

Commit

Permalink
Remove more of the internal modules (#2214)
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenpi authored Aug 17, 2023
1 parent 4c4760c commit 6486643
Show file tree
Hide file tree
Showing 34 changed files with 418 additions and 491 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* Documenter now uses [MarkdownAST](https://github.com/JuliaDocs/MarkdownAST.jl) to internally represent Markdown documents. While this change should not lead to any visible changes to the user, it is a major refactoring of the code. Please report any novel errors or unexpected behavior you encounter when upgrading to 0.28 on the [Documenter issue tracker](https://github.com/JuliaDocs/Documenter.jl/issues). ([#1892], [#1912], [#1924], [#1948])

* The code layout has changed considerably, with many of the internal submodules removed. This **may be breaking** for code that hooks into various Documenter internals, as various types and functions now live at different code paths. ([#1977])
* The code layout has changed considerably, with many of the internal submodules removed. This **may be breaking** for code that hooks into various Documenter internals, as various types and functions now live at different code paths. ([#1976], [#1977], [#2191], [#2214])


## Version [v0.27.25] - 2023-07-03
Expand Down Expand Up @@ -1599,6 +1599,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#1962]: https://github.com/JuliaDocs/Documenter.jl/issues/1962
[#1969]: https://github.com/JuliaDocs/Documenter.jl/issues/1969
[#1970]: https://github.com/JuliaDocs/Documenter.jl/issues/1970
[#1976]: https://github.com/JuliaDocs/Documenter.jl/issues/1976
[#1977]: https://github.com/JuliaDocs/Documenter.jl/issues/1977
[#1980]: https://github.com/JuliaDocs/Documenter.jl/issues/1980
[#1983]: https://github.com/JuliaDocs/Documenter.jl/issues/1983
Expand Down Expand Up @@ -1631,9 +1632,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#2170]: https://github.com/JuliaDocs/Documenter.jl/issues/2170
[#2181]: https://github.com/JuliaDocs/Documenter.jl/issues/2181
[#2187]: https://github.com/JuliaDocs/Documenter.jl/issues/2187
[#2191]: https://github.com/JuliaDocs/Documenter.jl/issues/2191
[#2194]: https://github.com/JuliaDocs/Documenter.jl/issues/2194
[#2205]: https://github.com/JuliaDocs/Documenter.jl/issues/2205
[#2213]: https://github.com/JuliaDocs/Documenter.jl/issues/2213
[#2214]: https://github.com/JuliaDocs/Documenter.jl/issues/2214
[JuliaLang/julia#36953]: https://github.com/JuliaLang/julia/issues/36953
[JuliaLang/julia#38054]: https://github.com/JuliaLang/julia/issues/38054
[JuliaLang/julia#39841]: https://github.com/JuliaLang/julia/issues/39841
Expand Down
3 changes: 2 additions & 1 deletion docs/src/lib/internals/anchors.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Anchors

```@autodocs
Modules = [Documenter.Anchors]
Modules = [Documenter]
Pages = ["anchors.jl"]
```
3 changes: 2 additions & 1 deletion docs/src/lib/internals/builder.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Builder

```@autodocs
Modules = [Documenter.Builder]
Modules = [Documenter, Documenter.Builder]
Pages = ["builder_pipeline.jl"]
```
3 changes: 2 additions & 1 deletion docs/src/lib/internals/docchecks.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# DocChecks

```@autodocs
Modules = [Documenter.DocChecks]
Modules = [Documenter]
Pages = ["docchecks.jl"]
```
3 changes: 2 additions & 1 deletion docs/src/lib/internals/doctests.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# DocTests

```@autodocs
Modules = [Documenter.DocTests]
Modules = [Documenter]
Pages = ["doctests.jl"]
```
3 changes: 2 additions & 1 deletion docs/src/lib/internals/expanders.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Expanders

```@autodocs
Modules = [Documenter.Expanders]
Modules = [Documenter, Documenter.Expanders]
Pages = ["expander_pipeline.jl"]
```
4 changes: 2 additions & 2 deletions docs/src/man/doctests.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,10 @@ julia> @time [1,2,3,4]
or to understand why a filter is not working).

To enable the debug output, you can set the `JULIA_DEBUG` environment variable to
Documenter's `DocTests` module, e.g. by doing the following in the `make.jl` script:
`Documenter`, e.g. by doing the following in the `make.jl` script:

```julia
ENV["JULIA_DEBUG"] = "DocTests"
ENV["JULIA_DEBUG"] = "Documenter"
```

## Doctesting as Part of Testing
Expand Down
14 changes: 8 additions & 6 deletions src/Documenter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ $(EXPORTS)
module Documenter

import AbstractTrees
import IOCapture
import Markdown
import MarkdownAST
using MarkdownAST: MarkdownAST, Node
import REPL
import Unicode
# Additional imported names
using Test: @testset, @test
Expand Down Expand Up @@ -67,13 +69,13 @@ include("utilities/TextDiff.jl")
include("utilities/utilities.jl")
include("DocMeta.jl")
include("DocSystem.jl")
include("Anchors.jl")
include("anchors.jl")
include("documents.jl")
include("Expanders.jl")
include("DocTests.jl")
include("Builder.jl")
include("expander_pipeline.jl")
include("doctests.jl")
include("builder_pipeline.jl")
include("cross_references.jl")
include("DocChecks.jl")
include("docchecks.jl")
include("writers.jl")
include("html/HTMLWriter.jl")
include("latex/LaTeXWriter.jl")
Expand Down
47 changes: 19 additions & 28 deletions src/Anchors.jl → src/anchors.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
"""
Defines the [`Anchor`](@ref) and [`AnchorMap`](@ref) types.
`Anchor`s and `AnchorMap`s are used to represent links between objects within a document.
"""
module Anchors

using DocStringExtensions
import MarkdownAST
# Defines the [`Anchor`](@ref) and [`AnchorMap`](@ref) types.
#
# `Anchor`s and `AnchorMap`s are used to represent links between objects within a document.

# Types.
# ------
Expand Down Expand Up @@ -60,7 +54,7 @@ Adds a new [`Anchor`](@ref) to the [`AnchorMap`](@ref) for a given `id` and `fil
Either an actual [`Anchor`](@ref) object may be provided or any other object which is
automatically wrapped in an [`Anchor`](@ref) before being added to the [`AnchorMap`](@ref).
"""
function add!(m::AnchorMap, anchor::Anchor, id, file)
function anchor_add!(m::AnchorMap, anchor::Anchor, id, file)
filemap = get!(m.map, id, Dict{String, Vector{Anchor}}())
anchors = get!(filemap, file, Anchor[])
push!(anchors, anchor)
Expand All @@ -70,7 +64,7 @@ function add!(m::AnchorMap, anchor::Anchor, id, file)
anchor.nth = length(anchors)
anchor
end
add!(m::AnchorMap, object, id, file) = add!(m, Anchor(object), id, file)
anchor_add!(m::AnchorMap, object, id, file) = anchor_add!(m, Anchor(object), id, file)

# Anchor existence.
# -----------------
Expand All @@ -81,9 +75,9 @@ $(SIGNATURES)
Does the given `id` exist within the [`AnchorMap`](@ref)? A `file` and integer `n` may also
be provided to narrow the search for existence.
"""
exists(m::AnchorMap, id, file, n) = exists(m, id, file) && 1 n length(m.map[id][file])
exists(m::AnchorMap, id, file) = exists(m, id) && haskey(m.map[id], file)
exists(m::AnchorMap, id) = haskey(m.map, id)
anchor_exists(m::AnchorMap, id, file, n) = anchor_exists(m, id, file) && 1 n length(m.map[id][file])
anchor_exists(m::AnchorMap, id, file) = anchor_exists(m, id) && haskey(m.map[id], file)
anchor_exists(m::AnchorMap, id) = haskey(m.map, id)

# Anchor uniqueness.
# ------------------
Expand All @@ -93,13 +87,13 @@ $(SIGNATURES)
Is the `id` unique within the given [`AnchorMap`](@ref)? May also specify the `file`.
"""
function isunique(m::AnchorMap, id)
exists(m, id) &&
function anchor_isunique(m::AnchorMap, id)
anchor_exists(m, id) &&
length(m.map[id]) === 1 &&
isunique(m, id, first(first(m.map[id])))
anchor_isunique(m, id, first(first(m.map[id])))
end
function isunique(m::AnchorMap, id, file)
exists(m, id, file) &&
function anchor_isunique(m::AnchorMap, id, file)
anchor_exists(m, id, file) &&
length(m.map[id][file]) === 1
end

Expand All @@ -113,34 +107,31 @@ Returns the [`Anchor`](@ref) object matching `id`. `file` and `n` may also be pr
`Anchor` is returned, or `nothing` in case of no match.
"""
function anchor(m::AnchorMap, id)
isunique(m, id) ?
anchor_isunique(m, id) ?
anchor(m, id, first(first(m.map[id])), 1) :
nothing
end
function anchor(m::AnchorMap, id, file)
isunique(m, id, file) ?
anchor_isunique(m, id, file) ?
anchor(m, id, file, 1) :
nothing
end
function anchor(m::AnchorMap, id, file, n)
exists(m, id, file, n) ?
anchor_exists(m, id, file, n) ?
m.map[id][file][n] :
nothing
end

"""
Create a label from an anchor.
"""
label(a::Anchor) = (a.nth == 1) ? a.id : string(a.id, "-", a.nth)
anchor_label(a::Anchor) = (a.nth == 1) ? a.id : string(a.id, "-", a.nth)

"""
Create an HTML fragment from an anchor.
"""
function fragment(a::Anchor)
frag = string("#", label(a))
function anchor_fragment(a::Anchor)
frag = string("#", anchor_label(a))
# TODO: Sanitize the fragment
return frag
end


end
Loading

0 comments on commit 6486643

Please sign in to comment.