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

Doctest output starting with # #1369

Merged
merged 8 commits into from
Aug 2, 2020
Merged

Doctest output starting with # #1369

merged 8 commits into from
Aug 2, 2020

Conversation

mortenpi
Copy link
Member

The following doctest will fail

julia> f(x) = println("# output from f\n$x");

julia> f(42)
# output from f
42

because we consider lines starting # as comments and include in the source part of the doctest, kinda:

# ANON_FUNC_DECLARATION deals with `x->x` -> `#1 (generic function ....)` on 0.7
# TODO: Remove this special case and just disallow lines with comments?
startswith(line, '#') && !occursin(ANON_FUNC_DECLARATION, line) && continue

Arguably, we should only consider the # as part of the doctest source if it is preceded by 7 spaces (our standard heuristic for determining if something is part of the source or output part):

julia> f(x) = println("# output from f\n$x");

julia> f(42)
       # actual comment
# output from f
42

X-ref: JuliaLang/julia#36696

@mortenpi mortenpi added this to the 0.25.2 milestone Aug 1, 2020
Also note that we don't actually have to remove the comments from the
input buffer, because the parser should just handle them.
@mortenpi mortenpi merged commit 292b318 into master Aug 2, 2020
@mortenpi mortenpi deleted the mp/doctest-comments branch August 2, 2020 20:54
@fredrikekre
Copy link
Member

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants