Skip to content

Commit 165f728

Browse files
authored
annotate method from @ccallable with @__doc__ (JuliaLang#51587)
This allows you to attach a docstring to a `@ccallable` method definition. Fixes JuliaLang#51586
1 parent f7e8f92 commit 165f728

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

base/c.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ function expand_ccallable(rt, def)
540540
end
541541
end
542542
return quote
543-
$(esc(def))
543+
@__doc__ $(esc(def))
544544
_ccallable($(esc(rt)), $(Expr(:curly, :Tuple, esc(f), map(esc, at)...)))
545545
end
546546
end

test/docs.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,3 +1517,11 @@ struct S41727
15171517
end
15181518
@test S41727(1) isa S41727
15191519
@test string(@repl S41727.x) == "x is 4\n"
1520+
1521+
"ensure we can document ccallable functions"
1522+
Base.@ccallable c51586_short()::Int = 2
1523+
"ensure we can document ccallable functions"
1524+
Base.@ccallable c51586_long()::Int = 3
1525+
1526+
@test docstrings_equal(@doc(c51586_short()), doc"ensure we can document ccallable functions")
1527+
@test docstrings_equal(@doc(c51586_long()), doc"ensure we can document ccallable functions")

test/llvmcall.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ module ObjLoadTest
147147
using Base: llvmcall, @ccallable
148148
using Test
149149
didcall = false
150+
""" jl_the_callback()
151+
152+
Sets the global didcall when it did the call
153+
"""
150154
@ccallable Cvoid function jl_the_callback()
151155
global didcall
152156
didcall = true

0 commit comments

Comments
 (0)