-
-
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
fix doctests, and make them less prone to errors #26275
Conversation
base/errorshow.jl
Outdated
@@ -24,7 +24,7 @@ julia> sprint(showerror, err) | |||
"MyException: test exception" | |||
|
|||
julia> throw(MyException("test exception")) | |||
ERROR: MyException: test exception | |||
ERROR: MyException("test exception") |
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.
@@ -170,7 +170,7 @@ julia> ceil(Dates.Minute(44), Dates.Minute(15)) | |||
45 minutes | |||
|
|||
julia> ceil(Dates.Hour(36), Dates.Day) | |||
3 days |
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.
Heh...
6f594a3
to
6e6066c
Compare
@@ -113,7 +113,7 @@ julia> isvalid(str, 2) | |||
false | |||
|
|||
julia> str[2] | |||
ERROR: StringIndexError: invalid character index | |||
ERROR: StringIndexError("αβγdef", 2) |
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 could use a custom showerror
method with an explanation.
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.
@@ -312,7 +311,7 @@ since each character in a string must have its own index. The following is an in | |||
verbose way to iterate through the characters of `s`: | |||
|
|||
```jldoctest unicodestring | |||
julia> for i = begindex(s):lastindex(s) |
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.
Was begindex ever a thing?
@@ -39,11 +39,11 @@ element type of `A`, e.g. for integer types. | |||
```jldoctest | |||
julia> A = [4. 3.; 6. 3.] | |||
2×2 Array{Float64,2}: | |||
6.0 3.0 | |||
4.0 3.0 |
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.
When was this ever true?
Okay, this is no longer WIP, would be great if someone could give a quick review. |
base/dict.jl
Outdated
|
||
julia> getkey(a,'a',1) | ||
julia> getkey(D,'a',1) |
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.
Could use spaces here to be consistent with the above.
@@ -250,6 +255,7 @@ pipeline? Instead of using `'|'` inside of backticks, one uses [`pipeline`](@ref | |||
```jldoctest | |||
julia> run(pipeline(`echo hello`, `sort`)) | |||
hello | |||
Base.ProcessChain(Base.Process[Process(`echo hello`, ProcessExited(0)), Process(`sort`, ProcessExited(0))], RawFD(0x00000000), RawFD(0x00000001), RawFD(0x00000002), #undef) |
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.
Perhaps semicolon these?
@@ -273,8 +273,8 @@ that shells cannot. | |||
|
|||
Julia can run multiple commands in parallel: | |||
|
|||
```julia-repl | |||
julia> run(`echo hello` & `echo world`) | |||
```jldoctest; filter = r"(world\nhello|hello\nworld) |
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 is pretty nice that we can test examples like this now even though the order is undefined.
…luenonscalarindexedassignment * origin/master: (28 commits) fix an optimizer bug in `invoke` with non-constant functions (#26301) lower top-level statements in such a way that the front-end knows (#26304) Make sure Sockets page has h1 header (#26315) fix doctests, and make them less prone to errors (#26275) FIx intro to manual chapter on types (#26312) Add a missing "that" (#26313) fix docstring for code_llvm (#26266) Remove the examples/ folder (#26153) download cert.pem from deps-getall, fixes #24903 (#25344) Slight update to doc string for at-enum to refer to instances (#26208) performance tweak in reverse(::String) (#26300) remove references to `TCPSocket` in Base docstrings (#26298) Deprecate adding integers to CartesianIndex (#26284) Deprecate conj(::Any), add real(::Missing) and imag(::Missing) (#26288) fix #26267, regression in `names` with `imported=false` (#26293) fix #25857, `typeinfo` problem in showing arrays with abstract tuple types (#26289) Add adjoint(::Missing) method (#25502) Use lowered form in logging macro (#26291) deprecate bin, oct, dec, hex, and base in favor of `string` and keyword args (#25804) deprecate `spawn(cmd)` to `run(cmd, wait=false)` (#26130) ...
This is a step towards #19528:
Later we should add functionality to fix all doctests (WIP here https://github.com/JuliaDocs/Documenter.jl/tree/fe/doctest-fix), which can then be run to update e.g. the line numbers before a release.
This is WIP because we need JuliaDocs/Documenter.jl#650 and a new Documenter release.
Note that there are a handful of doc updates here that we could have caught if doctests were enabled on CI.