Skip to content

Commit b289976

Browse files
ocotsgithub-actions[bot]
authored andcommitted
🤖 Format .jl files
1 parent 796a448 commit b289976

File tree

5 files changed

+130
-70
lines changed

5 files changed

+130
-70
lines changed

ext/DocumenterReference.jl

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ returns a `Vector` which can be used in the `pages` argument of
222222
Each time you call this function, a new object is added to the global variable
223223
`DocumenterReference.CONFIG`. Use `reset_config!()` to clear it between builds.
224224
"""
225-
function CTBase.automatic_reference_documentation(::CTBase.DocumenterReferenceTag;
225+
function CTBase.automatic_reference_documentation(
226+
::CTBase.DocumenterReferenceTag;
226227
subdirectory::String,
227228
modules::Vector,
228229
sort_by::Function=identity,
@@ -244,7 +245,9 @@ function CTBase.automatic_reference_documentation(::CTBase.DocumenterReferenceTa
244245
isempty(source_files) ? String[] : [abspath(path) for path in source_files]
245246

246247
if !public && !private
247-
error("automatic_reference_documentation: both `public` and `private` cannot be false.")
248+
error(
249+
"automatic_reference_documentation: both `public` and `private` cannot be false.",
250+
)
248251
end
249252

250253
# Effective title_in_menu defaults to title if not provided
@@ -257,7 +260,21 @@ function CTBase.automatic_reference_documentation(::CTBase.DocumenterReferenceTa
257260
effective_filename = _default_basename(filename, public, private)
258261
push!(
259262
CONFIG,
260-
_Config(current_module, subdirectory, _modules, sort_by, exclude_set, public, private, title, effective_title_in_menu, normalized_source_files, effective_filename, include_without_source, doc_modules),
263+
_Config(
264+
current_module,
265+
subdirectory,
266+
_modules,
267+
sort_by,
268+
exclude_set,
269+
public,
270+
private,
271+
title,
272+
effective_title_in_menu,
273+
normalized_source_files,
274+
effective_filename,
275+
include_without_source,
276+
doc_modules,
277+
),
261278
)
262279
if public && private
263280
# Both pages: use subdirectory with public.md and private.md
@@ -266,9 +283,11 @@ function CTBase.automatic_reference_documentation(::CTBase.DocumenterReferenceTa
266283
"Private" => _build_page_path(subdirectory, "private.md"),
267284
]
268285
elseif public
269-
return effective_title_in_menu => _build_page_path(subdirectory, "$effective_filename.md")
286+
return effective_title_in_menu =>
287+
_build_page_path(subdirectory, "$effective_filename.md")
270288
else
271-
return effective_title_in_menu => _build_page_path(subdirectory, "$effective_filename.md")
289+
return effective_title_in_menu =>
290+
_build_page_path(subdirectory, "$effective_filename.md")
272291
end
273292
end
274293

@@ -328,10 +347,28 @@ function _automatic_reference_documentation(
328347
)
329348
effective_filename = _default_basename("", public, private)
330349
# For multi-module case, use default titles
331-
default_title = public && !private ? "Public API" : (!public && private ? "Private API" : "API Reference")
350+
default_title = if public && !private
351+
"Public API"
352+
else
353+
(!public && private ? "Private API" : "API Reference")
354+
end
332355
push!(
333356
CONFIG,
334-
_Config(current_module, subdirectory, modules, sort_by, exclude, public, private, default_title, default_title, source_files, effective_filename, include_without_source, doc_modules),
357+
_Config(
358+
current_module,
359+
subdirectory,
360+
modules,
361+
sort_by,
362+
exclude,
363+
public,
364+
private,
365+
default_title,
366+
default_title,
367+
source_files,
368+
effective_filename,
369+
include_without_source,
370+
doc_modules,
371+
),
335372
)
336373
if public && private
337374
return [
@@ -670,7 +707,9 @@ function _build_api_page(document::Documenter.Document, config::_Config)
670707
if type == DOCTYPE_MODULE
671708
return nothing
672709
end
673-
push!(public_docstrings, "## `$key`\n\n```@docs\n$(current_module).$key\n```\n\n")
710+
push!(
711+
public_docstrings, "## `$key`\n\n```@docs\n$(current_module).$key\n```\n\n"
712+
)
674713
return nothing
675714
end
676715
public_md = Markdown.parse(public_overview * join(public_docstrings, "\n"))
@@ -712,7 +751,9 @@ function _build_api_page(document::Documenter.Document, config::_Config)
712751
if type == DOCTYPE_MODULE
713752
return nothing
714753
end
715-
push!(private_docstrings, "## `$key`\n\n```@docs\n$(current_module).$key\n```\n\n")
754+
push!(
755+
private_docstrings, "## `$key`\n\n```@docs\n$(current_module).$key\n```\n\n"
756+
)
716757
return nothing
717758
end
718759
# Add docstrings from additional modules (e.g., Base.showerror)
@@ -731,7 +772,10 @@ function _build_api_page(document::Documenter.Document, config::_Config)
731772
abs_file = abspath(file)
732773
if abs_file in config.source_files
733774
push!(found_symbols, key)
734-
push!(private_docstrings, "## `$(extra_mod).$key`\n\n```@docs\n$(extra_mod).$key\n```\n\n")
775+
push!(
776+
private_docstrings,
777+
"## `$(extra_mod).$key`\n\n```@docs\n$(extra_mod).$key\n```\n\n",
778+
)
735779
break
736780
end
737781
end
@@ -776,4 +820,4 @@ function Documenter.Selectors.runner(::Type{APIBuilder}, document::Documenter.Do
776820
return nothing
777821
end
778822

779-
end # module
823+
end # module

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ end
2424
# Main test set running multiple test suites with verbose output and timing information
2525
@testset verbose = true showtiming = true "Base" begin
2626
for name in (
27-
:code_quality,
27+
:code_quality,
2828
:default,
2929
:description,
3030
:exceptions,

test/test_description.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ function test_description()
121121

122122
@testset "Complete with Empty Descriptions" begin
123123
algorithms = ()
124-
@test_throws CTBase.AmbiguousDescription CTBase.complete(:a; descriptions=algorithms)
124+
@test_throws CTBase.AmbiguousDescription CTBase.complete(
125+
:a; descriptions=algorithms
126+
)
125127
end
126128

127129
return nothing

test/test_documenter_reference.jl

Lines changed: 65 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
11
module DocumenterReferenceTestMod
22

3-
"""
4-
Simple documented function used to test source file detection and inclusion.
5-
"""
6-
myfun(x) = x
7-
8-
"""
9-
Function that should be kept by _iterate_over_symbols.
10-
"""
11-
keep(x) = x
12-
13-
"""
14-
Function that will be excluded via the `exclude` configuration.
15-
"""
16-
skip(x) = x
17-
18-
# No docstring: this function should be skipped by _iterate_over_symbols.
19-
no_doc(x) = x
20-
21-
"""
22-
Test submodule with a docstring but no associated source file information.
23-
Used to exercise include_without_source behaviour for modules.
24-
"""
25-
module SubModule
26-
end
27-
28-
abstract type AbstractFoo end
29-
30-
struct Foo <: AbstractFoo
31-
x::Int
32-
end
3+
"""
4+
Simple documented function used to test source file detection and inclusion.
5+
"""
6+
myfun(x) = x
7+
8+
"""
9+
Function that should be kept by _iterate_over_symbols.
10+
"""
11+
keep(x) = x
12+
13+
"""
14+
Function that will be excluded via the `exclude` configuration.
15+
"""
16+
skip(x) = x
17+
18+
# No docstring: this function should be skipped by _iterate_over_symbols.
19+
no_doc(x) = x
20+
21+
"""
22+
Test submodule with a docstring but no associated source file information.
23+
Used to exercise include_without_source behaviour for modules.
24+
"""
25+
module SubModule end
26+
27+
abstract type AbstractFoo end
28+
29+
struct Foo <: AbstractFoo
30+
x::Int
31+
end
3332

34-
const MYCONST = 42
33+
const MYCONST = 42
3534

3635
end
3736

@@ -57,13 +56,17 @@ function test_documenter_reference()
5756
end
5857

5958
@testset "_classify_symbol and _to_string" begin
60-
6159
@test DR._classify_symbol(nothing, "@mymacro") == DR.DOCTYPE_MACRO
62-
@test DR._classify_symbol(DocumenterReferenceTestMod.SubModule, "SubModule") == DR.DOCTYPE_MODULE
63-
@test DR._classify_symbol(DocumenterReferenceTestMod.AbstractFoo, "AbstractFoo") == DR.DOCTYPE_ABSTRACT_TYPE
64-
@test DR._classify_symbol(DocumenterReferenceTestMod.Foo, "Foo") == DR.DOCTYPE_STRUCT
65-
@test DR._classify_symbol(DocumenterReferenceTestMod.myfun, "myfun") == DR.DOCTYPE_FUNCTION
66-
@test DR._classify_symbol(DocumenterReferenceTestMod.MYCONST, "MYCONST") == DR.DOCTYPE_CONSTANT
60+
@test DR._classify_symbol(DocumenterReferenceTestMod.SubModule, "SubModule") ==
61+
DR.DOCTYPE_MODULE
62+
@test DR._classify_symbol(DocumenterReferenceTestMod.AbstractFoo, "AbstractFoo") ==
63+
DR.DOCTYPE_ABSTRACT_TYPE
64+
@test DR._classify_symbol(DocumenterReferenceTestMod.Foo, "Foo") ==
65+
DR.DOCTYPE_STRUCT
66+
@test DR._classify_symbol(DocumenterReferenceTestMod.myfun, "myfun") ==
67+
DR.DOCTYPE_FUNCTION
68+
@test DR._classify_symbol(DocumenterReferenceTestMod.MYCONST, "MYCONST") ==
69+
DR.DOCTYPE_CONSTANT
6770

6871
@test DR._to_string(DR.DOCTYPE_ABSTRACT_TYPE) == "abstract type"
6972
@test DR._to_string(DR.DOCTYPE_CONSTANT) == "constant"
@@ -77,7 +80,9 @@ function test_documenter_reference()
7780
path = DR._get_source_file(DocumenterReferenceTestMod, :myfun, DR.DOCTYPE_FUNCTION)
7881
@test path === abspath(@__FILE__)
7982

80-
const_path = DR._get_source_file(DocumenterReferenceTestMod, :MYCONST, DR.DOCTYPE_CONSTANT)
83+
const_path = DR._get_source_file(
84+
DocumenterReferenceTestMod, :MYCONST, DR.DOCTYPE_CONSTANT
85+
)
8186
@test const_path === nothing
8287
end
8388

@@ -143,9 +148,7 @@ function test_documenter_reference()
143148
Module[],
144149
)
145150

146-
symbols1 = [
147-
:myfun => DR.DOCTYPE_FUNCTION,
148-
]
151+
symbols1 = [:myfun => DR.DOCTYPE_FUNCTION]
149152

150153
seen1 = Symbol[]
151154
DR._iterate_over_symbols(config1, symbols1) do key, type
@@ -186,9 +189,7 @@ function test_documenter_reference()
186189
Module[],
187190
)
188191

189-
symbols_module = [
190-
:SubModule => DR.DOCTYPE_MODULE,
191-
]
192+
symbols_module = [:SubModule => DR.DOCTYPE_MODULE]
192193

193194
seen2 = Symbol[]
194195
DR._iterate_over_symbols(config2, symbols_module) do key, type
@@ -242,10 +243,8 @@ function test_documenter_reference()
242243
@test cfg2.public == true
243244
@test cfg2.private == true
244245
@test cfg2.title == "All API"
245-
@test pages2 == ("All API" => [
246-
"Public" => "ref/public.md",
247-
"Private" => "ref/private.md",
248-
])
246+
@test pages2 ==
247+
("All API" => ["Public" => "ref/public.md", "Private" => "ref/private.md"])
249248

250249
# public=false, private=false should error
251250
@test_throws ErrorException CTBase.automatic_reference_documentation(
@@ -328,25 +327,36 @@ function test_documenter_reference()
328327

329328
@testset "_get_source_file expanded cases" begin
330329
# Function case (already tested, but verify)
331-
func_path = DR._get_source_file(DocumenterReferenceTestMod, :myfun, DR.DOCTYPE_FUNCTION)
330+
func_path = DR._get_source_file(
331+
DocumenterReferenceTestMod, :myfun, DR.DOCTYPE_FUNCTION
332+
)
332333
@test func_path !== nothing
333334
@test endswith(func_path, "test_documenter_reference.jl")
334335

335336
# Struct case - should find source via constructor methods
336-
struct_path = DR._get_source_file(DocumenterReferenceTestMod, :Foo, DR.DOCTYPE_STRUCT)
337+
struct_path = DR._get_source_file(
338+
DocumenterReferenceTestMod, :Foo, DR.DOCTYPE_STRUCT
339+
)
337340
# Structs defined in test file should be found
338-
@test struct_path === nothing || endswith(struct_path, "test_documenter_reference.jl")
341+
@test struct_path === nothing ||
342+
endswith(struct_path, "test_documenter_reference.jl")
339343

340344
# Abstract type case - typically returns nothing (no constructor)
341-
abstract_path = DR._get_source_file(DocumenterReferenceTestMod, :AbstractFoo, DR.DOCTYPE_ABSTRACT_TYPE)
345+
abstract_path = DR._get_source_file(
346+
DocumenterReferenceTestMod, :AbstractFoo, DR.DOCTYPE_ABSTRACT_TYPE
347+
)
342348
@test abstract_path === nothing
343349

344350
# Module case - modules cannot reliably determine source
345-
mod_path = DR._get_source_file(DocumenterReferenceTestMod, :SubModule, DR.DOCTYPE_MODULE)
351+
mod_path = DR._get_source_file(
352+
DocumenterReferenceTestMod, :SubModule, DR.DOCTYPE_MODULE
353+
)
346354
@test mod_path === nothing
347355

348356
# Constant case (already tested)
349-
const_path = DR._get_source_file(DocumenterReferenceTestMod, :MYCONST, DR.DOCTYPE_CONSTANT)
357+
const_path = DR._get_source_file(
358+
DocumenterReferenceTestMod, :MYCONST, DR.DOCTYPE_CONSTANT
359+
)
350360
@test const_path === nothing
351361
end
352362

@@ -403,4 +413,4 @@ function test_documenter_reference()
403413
DR.reset_config!()
404414
@test isempty(DR.CONFIG)
405415
end
406-
end
416+
end

test/test_integration.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ function test_integration()
2020
@test diff == (:bisection,)
2121

2222
# Ambiguous / invalid descriptions should raise AmbiguousDescription
23-
@test_throws CTBase.AmbiguousDescription CTBase.complete((:unknown,); descriptions=algorithms)
24-
@test_throws CTBase.AmbiguousDescription CTBase.complete((:descent, :unknown); descriptions=algorithms)
23+
@test_throws CTBase.AmbiguousDescription CTBase.complete(
24+
(:unknown,); descriptions=algorithms
25+
)
26+
@test_throws CTBase.AmbiguousDescription CTBase.complete(
27+
(:descent, :unknown); descriptions=algorithms
28+
)
2529
end
2630

2731
# Integration test: formatting labels using utils (subscripts/superscripts) with descriptions

0 commit comments

Comments
 (0)