Skip to content

Commit

Permalink
Pure Runic formatting (no manual changes).
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Oct 28, 2024
1 parent a0257f9 commit 0f78579
Show file tree
Hide file tree
Showing 68 changed files with 3,208 additions and 2,643 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/Runic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Runic
on:
push:
branches:
- 'master'
- 'release-'
tags:
- '*'
pull_request:
jobs:
runic:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: '1.11'
- uses: julia-actions/cache@v2
- uses: fredrikekre/runic-action@v1
with:
version: '35d6dd44ca8704f329319c83a2209875db2ede06'
28 changes: 15 additions & 13 deletions docs/DocumenterShowcase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,30 +85,32 @@ See also [`bar`](@ref).
baz(x::Integer, f, k::Integer) = nothing

function hello(who)
println("Hello, $(who)!")
return println("Hello, $(who)!")
end

struct SVGCircle
stroke :: String
fill :: String
stroke::String
fill::String
end
function Base.show(io, ::MIME"image/svg+xml", c::SVGCircle)
write(io, """
<svg width="50" height="50">
<g style="stroke-width: 3">
<circle cx="25" cy="25" r="24" stroke-width="2" style="stroke: #$(c.stroke); fill: #$(c.fill)" />
</g>
</svg>
""")
return write(
io, """
<svg width="50" height="50">
<g style="stroke-width: 3">
<circle cx="25" cy="25" r="24" stroke-width="2" style="stroke: #$(c.stroke); fill: #$(c.fill)" />
</g>
</svg>
"""
)
end

"The type definition."
struct Foo{T,S} end
struct Foo{T, S} end

"Constructor `Foo()` with no arguments."
Foo() = Foo{Nothing,Nothing}()
Foo() = Foo{Nothing, Nothing}()

"Constructor `Foo{T}()` with one parametric argument."
Foo{T}() where T = Foo{T,Nothing}()
Foo{T}() where {T} = Foo{T, Nothing}()

end # module
10 changes: 6 additions & 4 deletions docs/instantiate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ cd(project_directory) do
end
run(`git -C dev/DocumenterTools checkout documenter-v0.1.17+1.0.0`)
=#
Pkg.develop([
PackageSpec(path = documenter_directory),
#=PackageSpec(path = "dev/DocumenterTools"),=#
])
Pkg.develop(
[
PackageSpec(path = documenter_directory),
#=PackageSpec(path = "dev/DocumenterTools"),=#
]
)
Pkg.instantiate()
end
28 changes: 17 additions & 11 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ makedocs(
# a release, the release link does not exist yet, and this will cause the linkcheck
# CI job to fail on the PR that tags a new release.
r"https://github.com/JuliaDocs/Documenter.jl/releases/tag/v1.\d+.\d+",
] (get(ENV, "GITHUB_ACTIONS", nothing) == "true" ? [
# Extra ones we ignore only on CI.
#
# It seems that CTAN blocks GitHub Actions?
"https://ctan.org/pkg/minted",
] : []),
] (
get(ENV, "GITHUB_ACTIONS", nothing) == "true" ? [
# Extra ones we ignore only on CI.
#
# It seems that CTAN blocks GitHub Actions?
"https://ctan.org/pkg/minted",
] : []
),
pages = [
"Home" => "index.md",
"Manual" => Any[
Expand All @@ -63,9 +65,11 @@ makedocs(
"man/syntax.md",
"man/doctests.md",
"man/latex.md",
hide("man/hosting.md", [
"man/hosting/walkthrough.md"
]),
hide(
"man/hosting.md", [
"man/hosting/walkthrough.md",
]
),
"man/other-formats.md",
],
"showcase.md",
Expand Down Expand Up @@ -94,8 +98,10 @@ if "pdf" in ARGS
let files = readdir(joinpath(@__DIR__, "build-pdf"))
for f in files
if startswith(f, "Documenter.jl") && endswith(f, ".pdf")
mv(joinpath(@__DIR__, "build-pdf", f),
joinpath(@__DIR__, "build-pdf", "commit", f))
mv(
joinpath(@__DIR__, "build-pdf", f),
joinpath(@__DIR__, "build-pdf", "commit", f)
)
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions src/DocMeta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const META = gensym(:docmeta)
const METAMODULES = Module[]

"Type of the metadata dictionary."
const METATYPE = Dict{Symbol,Any}
const METATYPE = Dict{Symbol, Any}

"Dictionary of all valid metadata keys and their types."
const VALIDMETA = Dict{Symbol,Type}(:DocTestSetup => Union{Expr,Symbol})
const VALIDMETA = Dict{Symbol, Type}(:DocTestSetup => Union{Expr, Symbol})

"""
"""
Expand Down Expand Up @@ -56,7 +56,7 @@ getdocmeta(m::Module) = isdefined(m, META) ? getfield(m, META) : METATYPE()
Return the `key` entry from the documentation metadata for module `m`, or `default` if the
value is unset.
"""
getdocmeta(m::Module, key::Symbol, default=nothing) = get(getdocmeta(m), key, default)
getdocmeta(m::Module, key::Symbol, default = nothing) = get(getdocmeta(m), key, default)

Check warning on line 59 in src/DocMeta.jl

View check run for this annotation

Codecov / codecov/patch

src/DocMeta.jl#L59

Added line #L59 was not covered by tests

"""
setdocmeta!(m::Module, key::Symbol, value; recursive=false, warn=true)
Expand All @@ -66,12 +66,12 @@ Set the documentation metadata value `key` for module `m` to `value`.
If `recursive` is set to `true`, it sets the same metadata value for all the submodules too.
If `warn` is `true`, it prints a warning when `key` already exists and it gets rewritten.
"""
function setdocmeta!(m::Module, key::Symbol, value; warn=true, recursive=false)
function setdocmeta!(m::Module, key::Symbol, value; warn = true, recursive = false)

Check warning on line 69 in src/DocMeta.jl

View check run for this annotation

Codecov / codecov/patch

src/DocMeta.jl#L69

Added line #L69 was not covered by tests
key in keys(VALIDMETA) || throw(ArgumentError("Invalid metadata key\nValid keys are: $(join(keys(VALIDMETA), ", "))"))
isa(value, VALIDMETA[key]) || throw(ArgumentError("Bad value type ($(typeof(value))) for metadata key $(key). Must be <: $(VALIDMETA[key])"))
if recursive
for mod in Documenter.submodules(m)
setdocmeta!(mod, key, value; warn=warn, recursive=false)
setdocmeta!(mod, key, value; warn = warn, recursive = false)

Check warning on line 74 in src/DocMeta.jl

View check run for this annotation

Codecov / codecov/patch

src/DocMeta.jl#L74

Added line #L74 was not covered by tests
end
else
isdefined(m, META) || initdocmeta!(m)
Expand Down
45 changes: 21 additions & 24 deletions src/DocSystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ binding(any::Any) = throw(ArgumentError("cannot convert `$(repr(any))` to a `Bin
# The simple definitions.
#
binding(b::Docs.Binding) = binding(b.mod, b.var)
binding(d::DataType) = binding(parentmodule(d), nameof(d))
binding(m::Module) = binding(m, nameof(m))
binding(s::Symbol) = binding(Main, s)
binding(f::Function) = binding(parentmodule(f), nameof(f))
binding(d::DataType) = binding(parentmodule(d), nameof(d))
binding(m::Module) = binding(m, nameof(m))
binding(s::Symbol) = binding(Main, s)
binding(f::Function) = binding(parentmodule(f), nameof(f))

Check warning on line 37 in src/DocSystem.jl

View check run for this annotation

Codecov / codecov/patch

src/DocSystem.jl#L34-L37

Added lines #L34 - L37 were not covered by tests

#
# We need a lookup table for `IntrinsicFunction`s since they do not track their
# own name and defining module.
#
# Note that `IntrinsicFunction` is exported from `Base` in `0.4`, but not in `0.5`.
#
let INTRINSICS = Dict(map(s -> getfield(Core.Intrinsics, s) => s, names(Core.Intrinsics, all=true)))
let INTRINSICS = Dict(map(s -> getfield(Core.Intrinsics, s) => s, names(Core.Intrinsics, all = true)))

Check warning on line 45 in src/DocSystem.jl

View check run for this annotation

Codecov / codecov/patch

src/DocSystem.jl#L45

Added line #L45 was not covered by tests
global binding(i::Core.IntrinsicFunction) = binding(Core.Intrinsics, INTRINSICS[i]::Symbol)
end

Expand All @@ -53,7 +53,7 @@ end
#
function binding(m::Module, v::Symbol)
m = nameof(m) === v ? parentmodule(m) : m
Docs.Binding(m, v)
return Docs.Binding(m, v)
end

#
Expand All @@ -63,7 +63,7 @@ binding(m::Module, x::Expr) =
Meta.isexpr(x, :.) ? binding(getmod(m, x.args[1]), x.args[2].value) :
Meta.isexpr(x, [:call, :macrocall, :curly]) ? binding(m, x.args[1]) :
Meta.isexpr(x, :where) ? binding(m, x.args[1].args[1]) :
error("`binding` cannot understand expression `$x`.")
error("`binding` cannot understand expression `$x`.")

# Helper methods for the above `binding` method.
getmod(m::Module, x::Expr) = getfield(getmod(m, x.args[1]), x.args[2].value)
Expand All @@ -77,7 +77,7 @@ binding(m::Module, λ::Any) = binding(λ)

function signature(x, str::AbstractString)
ts = Base.Docs.signature(x)
(Meta.isexpr(x, :macrocall, 2) && !endswith(strip(str), "()")) ? :(Union{}) : ts
return (Meta.isexpr(x, :macrocall, 2) && !endswith(strip(str), "()")) ? :(Union{}) : ts
end

## Docstring containers. ##
Expand All @@ -100,11 +100,10 @@ function multidoc(markdown::Markdown.MD)
sig = Union{}
push!(md.order, sig)
md.docs[sig] = docstr(markdown)
md
return md

Check warning on line 103 in src/DocSystem.jl

View check run for this annotation

Codecov / codecov/patch

src/DocSystem.jl#L103

Added line #L103 was not covered by tests
end



"""
$(SIGNATURES)
Expand All @@ -123,16 +122,14 @@ function docstr(md::Markdown.MD; kws...)
for (key, value) in kws
doc.data[key] = value
end
doc
return doc

Check warning on line 125 in src/DocSystem.jl

View check run for this annotation

Codecov / codecov/patch

src/DocSystem.jl#L125

Added line #L125 was not covered by tests
end
docstr(other) = other


## Formatting `DocStr`s. ##




## Converting docstring caches. ##

"""
Expand All @@ -142,19 +139,19 @@ Converts a `0.4`-style docstring cache into a `0.5` one.
The original docstring cache is not modified.
"""
function convertmeta(meta::IdDict{Any,Any})
function convertmeta(meta::IdDict{Any, Any})

Check warning on line 142 in src/DocSystem.jl

View check run for this annotation

Codecov / codecov/patch

src/DocSystem.jl#L142

Added line #L142 was not covered by tests
if !haskey(CACHED, meta)
docs = IdDict{Any,Any}()
docs = IdDict{Any, Any}()

Check warning on line 144 in src/DocSystem.jl

View check run for this annotation

Codecov / codecov/patch

src/DocSystem.jl#L144

Added line #L144 was not covered by tests
for (k, v) in meta
if !isa(k, Union{Number, AbstractString, IdDict{Any,Any}})
if !isa(k, Union{Number, AbstractString, IdDict{Any, Any}})

Check warning on line 146 in src/DocSystem.jl

View check run for this annotation

Codecov / codecov/patch

src/DocSystem.jl#L146

Added line #L146 was not covered by tests
docs[binding(k)] = multidoc(v)
end
end
CACHED[meta] = docs
end
CACHED[meta]::IdDict{Any,Any}
return CACHED[meta]::IdDict{Any, Any}

Check warning on line 152 in src/DocSystem.jl

View check run for this annotation

Codecov / codecov/patch

src/DocSystem.jl#L152

Added line #L152 was not covered by tests
end
const CACHED = IdDict{Any,Any}()
const CACHED = IdDict{Any, Any}()


## Get docs from modules.
Expand Down Expand Up @@ -196,7 +193,7 @@ function getspecificdocs(
end
end
end
results
return results
end

"""
Expand Down Expand Up @@ -233,7 +230,7 @@ function getdocs(
results = getspecificdocs(b, typesig, (<:), modules)
end
end
results
return results
end

"""
Expand All @@ -246,7 +243,7 @@ Note that when conversion fails this method returns an empty `Vector{DocStr}`.
"""
function getdocs(object::Any, typesig::Type = Union{}; kws...)
binding = aliasof(object, object)
binding === object ? DocStr[] : getdocs(binding, typesig; kws...)
return binding === object ? DocStr[] : getdocs(binding, typesig; kws...)

Check warning on line 246 in src/DocSystem.jl

View check run for this annotation

Codecov / codecov/patch

src/DocSystem.jl#L246

Added line #L246 was not covered by tests
end

#
Expand All @@ -255,7 +252,7 @@ end

getmeta(m::Module) = Docs.meta(m)

import Base.Docs: aliasof, resolve, defined
import Base.Docs: aliasof, resolve, defined


aliasof(s::Symbol, b) = binding(s)
Expand All @@ -265,7 +262,7 @@ ismacro(b::Docs.Binding) = startswith(string(b.var), '@')


function category(b::Docs.Binding)
if iskeyword(b)
return if iskeyword(b)
:keyword
elseif ismacro(b)
:macro
Expand All @@ -287,7 +284,7 @@ in case `Base.Docs.parsedoc` fails with an exception.
"""
function parsedoc(docstr::DocStr)
md = try
Base.Docs.parsedoc(docstr) :: Markdown.MD
Base.Docs.parsedoc(docstr)::Markdown.MD
catch exception
@error """
parsedoc failed to parse a docstring into Markdown. This indicates a problem with the docstring.
Expand Down
10 changes: 6 additions & 4 deletions src/Documenter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ const NO_KEY_ENV = Dict(
)

# Names of possible internal errors
const ERROR_NAMES = [:autodocs_block, :cross_references, :docs_block, :doctest,
:eval_block, :example_block, :footnote, :linkcheck_remotes, :linkcheck,
:meta_block, :missing_docs, :parse_error, :setup_block]
const ERROR_NAMES = [
:autodocs_block, :cross_references, :docs_block, :doctest,
:eval_block, :example_block, :footnote, :linkcheck_remotes, :linkcheck,
:meta_block, :missing_docs, :parse_error, :setup_block,
]

"""
abstract type Plugin end
Expand Down Expand Up @@ -88,7 +90,7 @@ include("latex/LaTeXWriter.jl")

# This is to keep DocumenterTools working:
module Writers
import ..HTMLWriter
import ..HTMLWriter
end

import .HTMLWriter: HTML, asset
Expand Down
Loading

0 comments on commit 0f78579

Please sign in to comment.