-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
doctests for the manual, part 3 #20202
doctests for the manual, part 3 #20202
Conversation
@@ -152,27 +150,18 @@ julia> z | |||
10 | |||
``` | |||
|
|||
Multiple global or local definitions can be on one line and can also be paired with assignments: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was deprecated in #19905
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the replacement syntax demo'ed in the docs anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I know of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that it is only when paired with assignment that is deprecated:
julia> global a, b
julia> global x = 1; d
WARNING: deprecated syntax "global c=1, d" at REPL[2]:1.
Use "global c=1; global d" instead.
It seems a bit overkill to say that if you wanna pair it with assignment the keyword needs to be in front of each variable?
On another note: There is an empty line before the warning which is not the case for other warnings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The extra newline should probably be fixed... syntax deprecations get thrown from inside the parser I think. In 1.0 I guess this syntax would be an error, in which case hopefully the error message will indicate the correct syntax in a clear way?
julia> sqrt(-1) | ||
ERROR: DomainError: | ||
sqrt will only return a complex result if called with a complex argument. Try sqrt(complex(x)). | ||
in sqrt(::Int64) at ./math.jl:278 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are you removing backtrace lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of the example is just to show that it throws a DomainError
? And if the backtrace is removed like this the doctest doesn't need to be updated every time something change in math.jl
Should I include backtraces for all examples then? I have omitted it for some other blocks too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find at least the first line or two of the backtrace to be pretty useful, it tells you where to go find how the code is implemented if you want to look, and it's representative of what happens when you run this code yourself. The line numbers thing we should address in terms of how we run the doctests and how picky we are about everything matching. I think we should detect line numbers in the output and be permissive of them changing, everywhere except on release-branch builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a counter point I typically find all the backtraces in the docs annoying and noisy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do other people have to say?
I've got no particular preference for either, largely depends on the purpose of each doctest I think.
x = 2 # assignment introduces a new local | ||
return x + y # y refers to the global | ||
x = 2 # assignment introduces a new local | ||
return x +y # y refers to the global |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the space between the +
and y
should be kept
``` | ||
|
||
Boolean operations *without* short-circuit evaluation can be done with the bitwise boolean operators | ||
introduced in [Mathematical Operations and Elementary Functions](@ref): `&` and `|`. These are | ||
normal functions, which happen to support infix operator syntax, but always evaluate their arguments: | ||
|
||
```julia | ||
```@meta |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same remark, again, as in https://github.com/JuliaLang/julia/pull/20183/files#r97537182 can apply here as well I think.
a8801c8
to
fa9e404
Compare
I guess no one else seem to be bothered by the stacktraces in the manual, so I will add them back. I will update, and add them back. |
fa9e404
to
788827c
Compare
Re-added stacktraces, added doctests and |
nothing exciting here, just plain conversion to doctests and some whitespace fixes
(
make check-whitespace
and the doctests pass locally, remove[ci skip]
from commit message if/when this is merged)