Skip to content

Commit

Permalink
Merge pull request #12593 from JuliaLang/yyc/doc-str
Browse files Browse the repository at this point in the history
Accept string interpolation as doc string
  • Loading branch information
yuyichao committed Aug 13, 2015
2 parents d7193a3 + dcc4661 commit f40da0f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -2071,12 +2071,13 @@

(define (doc-string-literal? e)
(or (simple-string-literal? e)
(and (pair? e) (eq? 'string (car e))) ; string interpolation
(and (length= e 3) (eq? (car e) 'macrocall)
(simple-string-literal? (caddr e))
(eq? (cadr e) '@doc_str))))

(define (parse-docstring s production)
(let* ((ex (production s)))
(let* ((ex (production s)))
(if (and (doc-string-literal? ex)
(let loop ((t (peek-token s)))
(cond
Expand Down
12 changes: 12 additions & 0 deletions test/docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,15 @@ end
let fd = meta(I12515)[Base.collect]
@test fd.order[1].sig == Tuple{Type{I12515.EmptyType{TypeVar(:T, Any, true)}}}
end


# PR #12593

"$(1 + 1)"
f12593_1() = 1

"$(1 + 1) 2"
f12593_2() = 1

@test (@doc f12593_1) !== nothing
@test (@doc f12593_2) !== nothing

0 comments on commit f40da0f

Please sign in to comment.