|
1 | 1 | using BitFlags
|
2 | 2 | using Test, Serialization
|
3 | 3 |
|
| 4 | +# workaround for https://github.com/JuliaLang/julia/issues/54664 |
| 5 | +function extractdoc(doc) |
| 6 | + # On v1.11 without REPL loaded, the @doc macro returns a Base.Docs.DocStr object; |
| 7 | + # extract the stored string from the object. |
| 8 | + doc isa Base.Docs.DocStr && return doc.text[1] |
| 9 | + # Otherwise, assume we get something like a Markdown.MD object and just turn it into |
| 10 | + # a string. (Strip trailing newline for consistency with above form.) |
| 11 | + return strip(string(doc)) |
| 12 | +end |
| 13 | + |
4 | 14 | macro macrocall(ex)
|
5 | 15 | @assert Meta.isexpr(ex, :macrocall)
|
6 | 16 | ex.head = :call
|
|
95 | 105 | #@testset "Documentation" begin
|
96 | 106 | # docstring literal
|
97 | 107 | """My Docstring""" @bitflag DocFlag1 docflag1a
|
98 |
| - @test string(@doc(DocFlag1)) == "My Docstring\n" |
| 108 | + @test extractdoc(@doc(DocFlag1)) == "My Docstring" |
99 | 109 | # docstring macro for non-string literals
|
100 | 110 | @doc raw"""Raw Docstring""" @bitflag DocFlag2 docflag2a
|
101 |
| - @test string(@doc(DocFlag2)) == "Raw Docstring\n" |
| 111 | + @test extractdoc(@doc(DocFlag2)) == "Raw Docstring" |
102 | 112 | #end
|
103 | 113 |
|
104 | 114 | #@testset "Type properties" begin
|
|
333 | 343 |
|
334 | 344 | # Documentation
|
335 | 345 | """My Docstring""" @bitflagx SDocFlag1 docflag
|
336 |
| - @test string(@doc(SDocFlag1)) == "My Docstring\n" |
| 346 | + @test extractdoc(@doc(SDocFlag1)) == "My Docstring" |
337 | 347 | @doc raw"""Raw Docstring""" @bitflagx SDocFlag2 docflag
|
338 |
| - @test string(@doc(SDocFlag2)) == "Raw Docstring\n" |
| 348 | + @test extractdoc(@doc(SDocFlag2)) == "Raw Docstring" |
339 | 349 |
|
340 | 350 | # Error conditions
|
341 | 351 | # Too few arguments
|
|
0 commit comments