Use julia-repl in manual & other edits#21866
Conversation
| LIBM: libopenlibm | ||
| LLVM: libLLVM-3.3 | ||
| ```@repl | ||
| versioninfo() |
There was a problem hiding this comment.
This change would also require a small bugfix in Documenter (JuliaDocs/Documenter.jl#484).
doc/src/devdocs/subarrays.md
Outdated
| happens to be uniform: | ||
|
|
||
| ```julia | ||
| ```julia-repl |
There was a problem hiding this comment.
doctest candidate?
(also the next one in this file)
There was a problem hiding this comment.
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.
| are needed to separate the generator from subsequent arguments: | ||
|
|
||
| ```julia | ||
| ```julia-repl |
There was a problem hiding this comment.
doctest candidate? in case the error message changes I suppose
There was a problem hiding this comment.
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.
Ah my mistake then. Is there a tracking issue?
There was a problem hiding this comment.
There is now: JuliaDocs/Documenter.jl#487 Also, the same applies to the invalid UTF-8 example in manual/strings.md.
| doesn't know how to perform the requested conversion: | ||
|
|
||
| ```julia | ||
| ```julia-repl |
There was a problem hiding this comment.
doctest too for the error message?
|
I'm not sure I understand why both |
doc/src/manual/packages.md
Outdated
|
|
||
| ```julia | ||
| ```julia-repl | ||
| $ echo UTF16 >> ~/.julia/v0.6/REQUIRE |
There was a problem hiding this comment.
we may want to change this example to a non-deprecated package
| More generally, you can use [`open()`](@ref) to read from or write to an external command. | ||
|
|
||
| ```julia | ||
| ```julia-repl |
| a regular string literal, you will get a syntax error: | ||
|
|
||
| ```julia | ||
| ```julia-repl |
| when it would change the semantics is (currently) a syntax error: | ||
|
|
||
| ```julia | ||
| ```julia-repl |
| have a private state, for instance the `state` variable in the following example: | ||
|
|
||
| ```julia | ||
| ```julia-repl |
There was a problem hiding this comment.
this, and the next in this file's diff, should also be testable?
| 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.
could we put the series in this file in a common named doctest set?
There was a problem hiding this comment.
In principle this should be doable, but it's a bit more work. I'd leave this for another day.
|
@KristofferC The |
| of those methods are, use the [`methods()`](@ref) function: | ||
|
|
||
| ```julia | ||
| ```julia-repl |
There was a problem hiding this comment.
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
| For example, this regex has all three flags enabled: | ||
|
|
||
| ```julia | ||
| ```julia-repl |
There was a problem hiding this comment.
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-replto 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