-
-
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
Use julia-repl in manual & other edits #21866
Conversation
LIBM: libopenlibm | ||
LLVM: libLLVM-3.3 | ||
```@repl | ||
versioninfo() |
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 change would also require a small bugfix in Documenter (JuliaDocs/Documenter.jl#484).
doc/src/devdocs/subarrays.md
Outdated
@@ -152,7 +152,7 @@ we can define dispatch directly on `SubArray{T,N,A,I,true}` without any intermed | |||
Since this computation doesn't depend on runtime values, it can miss some cases in which the stride | |||
happens to be uniform: | |||
|
|||
```julia | |||
```julia-repl |
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.
doctest candidate?
(also the next one in this file)
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.
Ideally we'd doctest a lot more in this file, but we'd need a way to run ordinary code within doctests. A named @example
block sharing scope with doctests could be a way maybe, but Documenter doesn't support that at the moment afaict.
@@ -182,7 +182,7 @@ julia> sum(1/n^2 for n=1:1000) | |||
When writing a generator expression with multiple dimensions inside an argument list, parentheses | |||
are needed to separate the generator from subsequent arguments: | |||
|
|||
```julia | |||
```julia-repl |
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.
doctest candidate? in case the error message changes I suppose
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.
Documenter can't handle syntax errors as far as I can tell (at the moment, should probably be fixed).
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.
Ah my mistake then. Is there a tracking issue?
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 is now: JuliaDocs/Documenter.jl#487 Also, the same applies to the invalid UTF-8 example in manual/strings.md
.
1.0 2.0 3.0 | ||
4.0 5.0 6.0 | ||
``` | ||
|
||
Conversion isn't always possible, in which case a no method error is thrown indicating that `convert` | ||
doesn't know how to perform the requested conversion: | ||
|
||
```julia | ||
```julia-repl |
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.
doctest too for the error message?
I'm not sure I understand why both |
doc/src/manual/packages.md
Outdated
@@ -106,7 +106,7 @@ that the `Distributions` package should be installed since it is required but no | |||
stated before, you can accomplish the same thing by editing your `~/.julia/v0.6/REQUIRE` file | |||
by hand and then running [`Pkg.resolve()`](@ref) yourself: | |||
|
|||
```julia | |||
```julia-repl | |||
$ echo UTF16 >> ~/.julia/v0.6/REQUIRE |
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.
we may want to change this example to a non-deprecated package
@@ -49,7 +49,7 @@ true | |||
|
|||
More generally, you can use [`open()`](@ref) to read from or write to an external command. | |||
|
|||
```julia | |||
```julia-repl |
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.
doctestable?
@@ -808,7 +808,7 @@ The Unicode escape `\u2200` is encoded in UTF-8 as the three bytes 226, 136, 128 | |||
resulting byte array does not correspond to a valid UTF-8 string -- if you try to use this as | |||
a regular string literal, you will get a syntax error: | |||
|
|||
```julia | |||
```julia-repl |
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 doctest the error
@@ -174,7 +174,7 @@ julia> x | |||
Within soft scopes, the *global* keyword is never necessary, although allowed. The only case | |||
when it would change the semantics is (currently) a syntax error: | |||
|
|||
```julia | |||
```julia-repl |
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.
doctest for the error?
@@ -332,7 +332,7 @@ The reason to allow *modifying local* variables of parent scopes in nested funct | |||
constructing [closures](https://en.wikipedia.org/wiki/Closure_%28computer_programming%29) which | |||
have a private state, for instance the `state` variable in the following example: | |||
|
|||
```julia | |||
```julia-repl |
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, and the next in this file's diff, should also be testable?
@@ -26,7 +26,7 @@ Base.Test.@test_throws | |||
|
|||
For example, suppose we want to check our new function `foo(x)` works as expected: | |||
|
|||
```julia | |||
```julia-repl |
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 we put the series in this file in a common named doctest set?
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.
In principle this should be doable, but it's a bit more work. I'd leave this for another day.
@KristofferC The |
@@ -163,7 +163,7 @@ f (generic function with 2 methods) | |||
This output tells us that `f` is a function object with two methods. To find out what the signatures | |||
of those methods are, use the [`methods()`](@ref) function: | |||
|
|||
```julia | |||
```julia-repl |
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 can't be a doctest at the moment since Documenter thinks that the first line of output is a comment that should be ignored (JuliaDocs/Documenter.jl#483).
Rebased and all the doctests seem to be passing now. I can squash some of the commits (e.g. all the "Enable doctests in ..." ones) if need be, but I was trying to keep distinct changes in separate commits. |
Great with so many more doctests! |
base/regex.jl
Outdated
@@ -75,7 +75,7 @@ after the ending quote, to change its behaviour: | |||
|
|||
For example, this regex has all three flags enabled: | |||
|
|||
```julia | |||
```julia-repl |
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.
did I comment on this one or miss it, seems doctestable?
We could probably add some smarts to a single |
Someone has to implement that in highlight.js though. As you point out, there are pros and cons to both approaches, so I'm actually neutral on the matter. For some data: other languages in highlight.js seem to have separate However, in any case, switching back to a single |
Barring objections I plan to merge this later today. |
It would be good to squash some of the commits first; 23 is a lot of separate commits for this. |
With the highlighting updates in Documenter v0.10.1 it is now possible to have specialized highlighting for REPL blocks via the julia-repl attribute on code blocks. Doctests already use this, so this makes the highlighting for non-doctest REPL blocks consistent.
A couple of code examples were not highlighted for some reason.
These blocks are not Julia code, but special REQUIRE file syntax instead.
Also add a newline to the end of the file.
UTF16.jl has been deprecated for a while. Use SHA.jl instead as the example.
Done, down to 11 now. I squashed the similar ones. I left the doctest ones under |
The REPL example is basically exactly as above, and does not add anything to the latter bit about the actual convert methods.
Switching to julia-repl revealed several code blocks that could trivially be turned into doctests.
Perfect. Thanks, @mortenpi! |
With the highlighting updates in Documenter v0.10.1 it is now possible to have specialized highlighting for REPL blocks via the julia-repl attribute on code blocks. Doctests already use this, so this makes the highlighting for non-doctest REPL blocks consistent. (cherry picked from commit 014c5d5) ref #21866 Use at-repl for versioninfo() output (cherry picked from commit f67d4fd) Enable highlighting in the manual A couple of code examples were not highlighted for some reason. (cherry picked from commit b710de9) Remove highlighting from REQUIRE code These blocks are not Julia code, but special REQUIRE file syntax instead. (cherry picked from commit c90c17f) Enable bash highlighting Also add a newline to the end of the file. (cherry picked from commit 6e08c18) Use a non-deprecated package in an example UTF16.jl has been deprecated for a while. Use SHA.jl instead as the example. (cherry picked from commit 6e5c55d) Edit manual/conversion-and-promotion.md The REPL example is basically exactly as above, and does not add anything to the latter bit about the actual convert methods. (cherry picked from commit 96b65f1) Fix line numbers in doctests (cherry picked from commit 814a8a1) Enable a doctest in base/regex.jl (cherry picked from commit d9063cb) Enable doctests the the manual Switching to julia-repl revealed several code blocks that could trivially be turned into doctests. (cherry picked from commit 1d20519)
Use
julia-repl
to highlight REPL blocks in the manual, which makes them consistent with doctest blocks. Requires Documenter v0.10.1, which is why it's currently based on #21846.I also came across a number of REPL blocks that seemed like they could be turned into doctests as well, and a few other small things. However, I guess there might have been a good reason why some of them were not enabled, so I'd be happy to drop some or all of those commits if need be.
I think it would be good to get this backported to 0.6 as well, at least the first commit. It seems that there's only one tiny conflict, so it shouldn't be a big problem.
Example build: http://mortenpi.eu/julia/julia-repl/index.html