Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add public keyword #50105

Merged
merged 69 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
5b3d8c1
mwe including `export (scoped-true), a, b, c` and `names`
Jun 7, 2023
665855e
add `Base.isinternal` and use it to flag internal methods in their do…
Jun 7, 2023
52f519e
update documentation
Jun 7, 2023
03f9e02
add more verbose clarificaiton of what is and is not public API (TODO…
Jun 26, 2023
7eb64a2
add prelimianry list of scoped-exported symbols for review
Jun 26, 2023
c7192ea
more docs (implement option 1 of https://github.com/JuliaLang/julia/p…
Jun 26, 2023
ec3b2f3
address @jariji's comments
Jun 26, 2023
804f5ef
Merge branch 'master' into scoped-export
LilithHafner Jun 29, 2023
7d404f0
Merge branch 'master' into scoped-export
Jul 8, 2023
4dc10c4
use JuliaSyntax#320 branch
Jul 8, 2023
5fd1f64
bump JuliaSyntax
Jul 8, 2023
b85ae46
more changes for scoped export -> public
Jul 8, 2023
acc928a
try to make public list functional
Jul 10, 2023
a5162c2
bump juliasyntax
Jul 18, 2023
aacc187
bump JuliaSyntax
Jul 19, 2023
145ad7f
fix lowering
Jul 19, 2023
aea3d22
clarify internal symbol warning and add test for it
Jul 19, 2023
f7d57ba
add test for names + public
Jul 19, 2023
34844bb
don't autocomplete internals (ideally we _would_ autocomplete interna…
Jul 19, 2023
8241760
Merge branch 'master' into scoped-export
Jul 19, 2023
920244a
update FAQ (this change introduces comedy and therefore may be contro…
Jul 19, 2023
9e61f96
Rename isinternal to ispublic and make all resolved symbols in Main p…
Jul 19, 2023
f75cb68
fix typo in test/reflection.jl
Jul 21, 2023
db7ba05
change module docstring warning
Jul 28, 2023
7dbdd5e
Make warning an Admonition
Jul 28, 2023
ac11ea4
bump JuliaSyntax
Jul 28, 2023
bd0ee87
fix doc tests
Jul 29, 2023
1dc9652
remove internal warning tests from stdlib/REPL/test/docview.jl becaus…
Jul 29, 2023
17b8834
restore autocomplete for non-public symbols
Jul 29, 2023
6e2ddec
Merge branch 'master' into scoped-export
LilithHafner Jul 29, 2023
1000988
initialize public to false (woops!)
Jul 29, 2023
c5955c0
more fixups for doc tests
Jul 29, 2023
5ed2c7d
remove joke
Jul 29, 2023
5da758e
fix repl tests
Jul 29, 2023
de8be2b
fix precompile tests
Jul 29, 2023
d75725b
bump juliasyntax to merged version
Jul 30, 2023
05352df
Make `compilecache` internal
LilithHafner Aug 3, 2023
4b04f31
Remove `_datatype_*` publics
LilithHafner Aug 3, 2023
051f824
Remove symbols from public list
LilithHafner Aug 3, 2023
8a56ab4
Add some modules to public list (@vtjnash)
LilithHafner Aug 3, 2023
6e2d809
remove newlines between bullet points
Aug 10, 2023
69cf8d4
Apply suggestions from code review
LilithHafner Aug 13, 2023
9d74beb
Apply suggestions from code review
LilithHafner Aug 13, 2023
4b18e1d
Merge branch 'master' into scoped-export
Aug 13, 2023
4ba71ab
add show tests
Aug 13, 2023
ce3a798
group public symbols a little better
Aug 13, 2023
ca8eb44
revert names to the most basic implementation (simply swap export=>pu…
Aug 14, 2023
6d1e2c7
fix typo
Aug 14, 2023
2678523
fix typo
Aug 14, 2023
528469b
revert unnecessary whitespace change
Aug 14, 2023
082fb86
add tests for ispublic and add more tests for isexported
Aug 14, 2023
3d09dae
fix some tests
Aug 14, 2023
12bab72
Do a better job of logging nonpublic access in help mode
Sep 4, 2023
0112e2c
remove obsolete tests
Sep 4, 2023
66427c6
finalize struct
Sep 4, 2023
067d69c
update tests
Sep 4, 2023
b688b60
add tests and fix "public names" header
Sep 4, 2023
6ce6fdb
update documentation throughout to refer to public and export now-cor…
Sep 5, 2023
e57c63f
fix cross refs
Sep 5, 2023
1a6e3dc
update varinfo documentation
Sep 5, 2023
ebcdf24
Merge branch 'master' into scoped-export
LilithHafner Sep 5, 2023
d4418fe
Update checksums
Sep 5, 2023
c4924c9
fix some tests
Sep 5, 2023
5835699
more test fixes
Sep 5, 2023
153b538
try switching to a different JuliaSyntax version
Sep 5, 2023
158d59f
don't accidentally drop the module in testing
Sep 5, 2023
41f3729
fix some doctests
Sep 5, 2023
fd5fb90
Merge branch 'master' into scoped-export
LilithHafner Sep 6, 2023
ea7a141
Docstring fixup for Base.ispublic
LilithHafner Sep 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix doc tests
mostly, this was fixing the test files to either make demo bindings public or expect internal warnings when they are not
additionally, fix internal warning for non-markdown content (give up instead of erroring)
  • Loading branch information
Lilith Hafner authored and Lilith Hafner committed Jul 29, 2023
commit bd0ee874572f5d1750c9a18392340cc3929aeb70
5 changes: 3 additions & 2 deletions stdlib/REPL/src/docview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,11 @@ function doc(binding::Binding, sig::Type = Union{})
# Get parsed docs and concatenate them.
md = catdoc(mapany(parsedoc, results)...)

Base.ispublic(binding.mod, binding.var) || pushfirst!(md.content, INTERNAL_WARNING)

# Save metadata in the generated markdown.
if isa(md, Markdown.MD)
# We don't know how to insert an internal symbol warning into non-markdown
# content, so we don't.
Base.ispublic(binding.mod, binding.var) || pushfirst!(md.content, INTERNAL_WARNING)
md.meta[:results] = results
md.meta[:binding] = binding
md.meta[:typesig] = sig
Expand Down
46 changes: 28 additions & 18 deletions test/docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ using InteractiveUtils: apropos
include("testenv.jl")

# Test helpers.
function docstrings_equal(d1, d2; debug=true)
function docstrings_equal(d1, d2; debug=true, private_warning=false)
io1 = IOBuffer()
io2 = IOBuffer()
show(io1, MIME"text/markdown"(), d1)
show(io2, MIME"text/markdown"(), d2)
s1 = String(take!(io1))
s2 = String(take!(io2))
if private_warning
s2 = "!!! warning\n This symbol may be internal. Behavior documented here might change in future versions.\n\n\n" * s2
end
if debug && s1 != s2
print(s1)
println("--------------------------------------------------------------------------------")
Expand All @@ -27,7 +30,7 @@ function docstrings_equal(d1, d2; debug=true)
end
return s1 == s2
end
docstrings_equal(d1::DocStr, d2) = docstrings_equal(parsedoc(d1), d2)
docstrings_equal(d1::DocStr, d2; kw...) = docstrings_equal(parsedoc(d1), d2; kw...)

function docstring_startswith(d1, d2)
io1 = IOBuffer()
Expand All @@ -38,6 +41,7 @@ function docstring_startswith(d1, d2)
end
docstring_startswith(d1::DocStr, d2) = docstring_startswith(parsedoc(d1), d2)

public C74685
@doc "Doc abstract type"
abstract type C74685{T,N} <: AbstractArray{T,N} end
@test repr("text/plain", Docs.doc(C74685))==" Doc abstract type"
Expand Down Expand Up @@ -72,13 +76,14 @@ function break_me_docs end
# issue #11548

module ModuleMacroDoc
public @m
macro m() end
end

@doc "I am a module" ModuleMacroDoc
@doc "I am a macro" :@ModuleMacroDoc.m

@test docstrings_equal(@doc(ModuleMacroDoc), doc"I am a module")
@test docstrings_equal(@doc(ModuleMacroDoc), doc"I am a module", private_warning=true)
@test docstrings_equal(@doc(ModuleMacroDoc.@m), doc"I am a macro")

# issue #38819
Expand Down Expand Up @@ -312,13 +317,13 @@ let fns = @var(DocsTest.fnospecialize)
@test docstrings_equal(d, doc"`fnospecialize` for arrays")
end

@test docstrings_equal(@doc(DocsTest.TA), doc"TA")
@test docstrings_equal(@doc(DocsTest.TA), doc"TA", private_warning=true)

@test docstrings_equal(@doc(DocsTest.@mac), doc"@mac()")
@test docstrings_equal(@doc(DocsTest.@mac()), doc"@mac()")
@test docstrings_equal(@doc(DocsTest.@mac(x)), doc"@mac(x)")
@test docstrings_equal(@doc(DocsTest.@mac(x::Int, y::Expr)), doc"@mac(x::Int, y::Expr, z = 0)")
@test docstrings_equal(@doc(DocsTest.@mac(x::Int, y::Expr, z)), doc"@mac(x::Int, y::Expr, z = 0)")
@test docstrings_equal(@doc(DocsTest.@mac), doc"@mac()", private_warning=true)
@test docstrings_equal(@doc(DocsTest.@mac()), doc"@mac()", private_warning=true)
@test docstrings_equal(@doc(DocsTest.@mac(x)), doc"@mac(x)", private_warning=true)
@test docstrings_equal(@doc(DocsTest.@mac(x::Int, y::Expr)), doc"@mac(x::Int, y::Expr, z = 0)", private_warning=true)
@test docstrings_equal(@doc(DocsTest.@mac(x::Int, y::Expr, z)), doc"@mac(x::Int, y::Expr, z = 0)", private_warning=true)
let m = doc"""
@mac()

Expand All @@ -328,31 +333,31 @@ let m = doc"""

:@mac
"""
@test docstrings_equal(@doc(:@DocsTest.mac), m)
@test docstrings_equal(@doc(:(DocsTest.@mac)), m)
@test docstrings_equal(@doc(:@DocsTest.mac), m, private_warning=true)
@test docstrings_equal(@doc(:(DocsTest.@mac)), m, private_warning=true)
end

@test docstrings_equal(@doc(DocsTest.G), doc"G")
@test docstrings_equal(@doc(DocsTest.K), doc"K")
@test docstrings_equal(@doc(DocsTest.G), doc"G", private_warning=true)
@test docstrings_equal(@doc(DocsTest.K), doc"K", private_warning=true)

let d1 = @doc(DocsTest.t(::AbstractString)),
d2 = doc"t-1"
@test docstrings_equal(d1,d2)
@test docstrings_equal(d1,d2,private_warning=true)
end

let d1 = @doc(DocsTest.t(::AbstractString)),
d2 = doc"t-1"
@test docstrings_equal(d1,d2)
@test docstrings_equal(d1,d2,private_warning=true)
end

let d1 = @doc(DocsTest.t(::Int, ::Any)),
d2 = doc"t-2"
@test docstrings_equal(d1,d2)
@test docstrings_equal(d1,d2,private_warning=true)
end

let d1 = @doc(DocsTest.t(::S) where {S <: Integer}),
d2 = doc"t-3"
@test docstrings_equal(d1,d2)
@test docstrings_equal(d1,d2,private_warning=true)
end

let fields = meta(DocsTest)[@var(DocsTest.FieldDocs)].docs[Union{}].data[:fields]
Expand All @@ -365,9 +370,13 @@ let a = @doc(DocsTest.multidoc),
@test docstrings_equal(a, b)
end

public BareModule

"BareModule"
baremodule BareModule

public f, g, h, @m, C, A

"f/1"
f(x) = x

Expand Down Expand Up @@ -402,7 +411,7 @@ end
@test docstrings_equal(@doc(BareModule.@m), doc"@m")
@test docstrings_equal(@doc(BareModule.C), doc"C")
@test docstrings_equal(@doc(BareModule.A), doc"A")
@test docstrings_equal(@doc(BareModule.T), doc"T")
@test docstrings_equal(@doc(BareModule.T), doc"T", private_warning=true)

@test_throws ErrorException @doc("...", "error")
@test_throws ErrorException @doc("...", @time 0)
Expand Down Expand Up @@ -623,6 +632,7 @@ end

let d = @doc(I15424.LazyHelp)
@test repr("text/plain", d) == "LazyHelp\nLazyHelp(text)\n"
# (no internal warning is inserted for non-markdown content)
end

# Issue #13385.
Expand Down