Skip to content

Commit 25c4166

Browse files
add tests for undocumented symbols (#52723)
Following #52413 by @jariji and the discussion in #51174, this adds tests to ensure that there are no undocumented *(= lacking docstrings)* public symbols in any documented module. Many of the tests are broken — we have a lot of undocumented exports. In such cases I added both a `@test_broken` and a `@test` to ensure that there are no additional regressions added in the future. ~~(This PR may have to be updated when #52413 (comment) is fixed, i.e. when ~~#52727~~ #52743 is merged.)~~ Has been updated. --------- Co-authored-by: Lilith Orion Hafner <[email protected]>
1 parent 681816c commit 25c4166

File tree

41 files changed

+233
-23
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+233
-23
lines changed

base/docs/Docs.jl

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,11 +650,37 @@ function loaddocs(docs::Vector{Core.SimpleVector})
650650
nothing
651651
end
652652

653+
# FIXME: formatdoc, parsedoc, apropos, and doc are defined here (but only doc is exported)
654+
# for historical reasons (#25738), but are *implemented* in REPL/src/docview.jl, while
655+
# apropos is *exported* by InteractiveUtils and doc is exported by Docs. Seems
656+
# like a more sensible refactoring should be possible.
657+
653658
function formatdoc end
654659
function parsedoc end
660+
661+
"""
662+
apropos([io::IO=stdout], pattern::Union{AbstractString,Regex})
663+
664+
Search available docstrings for entries containing `pattern`.
665+
666+
When `pattern` is a string, case is ignored. Results are printed to `io`.
667+
668+
`apropos` can be called from the help mode in the REPL by wrapping the query in double quotes:
669+
```
670+
help?> "pattern"
671+
```
672+
"""
655673
function apropos end
656-
function doc end
657674

675+
"""
676+
Docs.doc(binding, sig)
677+
678+
Return all documentation that matches both `binding` and `sig`.
679+
680+
If `getdoc` returns a non-`nothing` result on the value of the binding, then a
681+
dynamic docstring is returned instead of one based on the binding itself.
682+
"""
683+
function doc end
658684

659685
"""
660686
Docs.hasdoc(mod::Module, sym::Symbol)::Bool

base/libc.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ show(io::IO, fd::RawFD) = print(io, "RawFD(", bitcast(UInt32, fd), ')') # avoid
4545

4646
# Wrapper for an OS file descriptor (for Windows)
4747
if Sys.iswindows()
48+
@doc """
49+
WindowsRawSocket
50+
51+
Primitive type which wraps the native Windows file `HANDLE`.
52+
"""
4853
primitive type WindowsRawSocket sizeof(Ptr) * 8 end # On Windows file descriptors are HANDLE's and 64-bit on 64-bit Windows
4954
WindowsRawSocket(handle::Ptr{Cvoid}) = bitcast(WindowsRawSocket, handle)
5055
WindowsRawSocket(handle::WindowsRawSocket) = handle

stdlib/Artifacts/test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,9 @@ end
261261
@test length(Base.manifest_names) == 2n # there are two manifest names per project name
262262
@test length(Base.preferences_names) == n
263263
end
264+
265+
@testset "Docstrings" begin
266+
undoc = Docs.undocumented_names(Artifacts)
267+
@test_broken isempty(undoc)
268+
@test undoc == [:Artifacts]
269+
end

stdlib/Base64/test/runtests.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

33
using Test, Random
4-
import Base64:
4+
using Base64:
5+
Base64,
56
Base64EncodePipe,
67
base64encode,
78
Base64DecodePipe,
@@ -142,3 +143,7 @@ end
142143
@test String(base64decode(splace(longEncodedText))) == longDecodedText
143144
end
144145
end
146+
147+
@testset "Docstrings" begin
148+
@test isempty(Docs.undocumented_names(Base64))
149+
end

stdlib/CRC32c/test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,7 @@ end
7777
crc32c_sw(io::IO, crc::UInt32=0x00000000) = crc32c_sw(io, typemax(Int64), crc)
7878
test_crc32c(crc32c)
7979
test_crc32c(crc32c_sw)
80+
81+
@testset "Docstrings" begin
82+
@test isempty(Docs.undocumented_names(CRC32c))
83+
end

stdlib/Dates/test/runtests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@
22

33
module DateTests
44

5+
using Test, Dates
6+
57
for file in readlines(joinpath(@__DIR__, "testgroups"))
68
include(file * ".jl")
79
end
810

11+
@testset "Docstrings" begin
12+
undoc = Docs.undocumented_names(Dates)
13+
@test_broken isempty(undoc)
14+
@test undoc == [:adjust]
15+
end
16+
917
end

stdlib/FileWatching/test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,4 +447,10 @@ rm(dir)
447447
include("pidfile.jl")
448448
end
449449

450+
@testset "Docstrings" begin
451+
undoc = Docs.undocumented_names(FileWatching)
452+
@test_broken isempty(undoc)
453+
@test undoc == [:FDWatcher, :FileMonitor, :FolderMonitor, :PollingFileWatcher]
454+
end
455+
450456
end # testset

stdlib/Future/test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22

33
using Test
44
using Future
5+
6+
@testset "Docstrings" begin
7+
@test isempty(Docs.undocumented_names(Future))
8+
end

stdlib/InteractiveUtils/test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,3 +724,9 @@ end
724724
end
725725

726726
@test Base.infer_effects(sin, (Int,)) == InteractiveUtils.@infer_effects sin(42)
727+
728+
@testset "Docstrings" begin
729+
undoc = Docs.undocumented_names(InteractiveUtils)
730+
@test_broken isempty(undoc)
731+
@test undoc == [:InteractiveUtils]
732+
end

stdlib/LibGit2/test/runtests.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3-
using Test
3+
using Test, LibGit2
4+
45
@testset verbose=true "LibGit2 $test" for test in eachline(joinpath(@__DIR__, "testgroups"))
56
include("$test.jl")
67
end
8+
9+
@testset "Docstrings" begin
10+
@test isempty(Docs.undocumented_names(LibGit2))
11+
end

0 commit comments

Comments
 (0)