Skip to content

Commit f40da0f

Browse files
committed
Merge pull request #12593 from JuliaLang/yyc/doc-str
Accept string interpolation as doc string
2 parents d7193a3 + dcc4661 commit f40da0f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/julia-parser.scm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2071,12 +2071,13 @@
20712071

20722072
(define (doc-string-literal? e)
20732073
(or (simple-string-literal? e)
2074+
(and (pair? e) (eq? 'string (car e))) ; string interpolation
20742075
(and (length= e 3) (eq? (car e) 'macrocall)
20752076
(simple-string-literal? (caddr e))
20762077
(eq? (cadr e) '@doc_str))))
20772078

20782079
(define (parse-docstring s production)
2079-
(let* ((ex (production s)))
2080+
(let* ((ex (production s)))
20802081
(if (and (doc-string-literal? ex)
20812082
(let loop ((t (peek-token s)))
20822083
(cond

test/docs.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,15 @@ end
196196
let fd = meta(I12515)[Base.collect]
197197
@test fd.order[1].sig == Tuple{Type{I12515.EmptyType{TypeVar(:T, Any, true)}}}
198198
end
199+
200+
201+
# PR #12593
202+
203+
"$(1 + 1)"
204+
f12593_1() = 1
205+
206+
"$(1 + 1) 2"
207+
f12593_2() = 1
208+
209+
@test (@doc f12593_1) !== nothing
210+
@test (@doc f12593_2) !== nothing

0 commit comments

Comments
 (0)