Julia code examples
Fonts
This package uses the JuliaMono font by default, but you can override this in CSS.
This is what some common symbols look like:
] [ = $ ; ( @ { " ) ? . } ⊽ ⊼ ⊻ ⊋ ⊊ ⊉ ⊈ ⊇ ⊆ ≥ ≤ ≢ ≡ ≠ ≉ ≈ ∪ ∩ ∜ ∛ √ ∘ ∌
|> /> ^ % ` ∈
@example
The Julia
code used here is done using the following packages versions:
Input
```@example version
using Pkg
Pkg.status()
```
Output
using Pkg
Pkg.status()
Status `~/work/DocumenterVitepress.jl/DocumenterVitepress.jl/docs/Project.toml`
[e30172f5] Documenter v1.8.0
[daee34ce] DocumenterCitations v1.3.5
[4710194d] DocumenterVitepress v0.1.3 `~/work/DocumenterVitepress.jl/DocumenterVitepress.jl`
And a simple sum:
Input
```@example simple_sum
2 + 2
```
Output
2 + 2
4
@ansi
Input
```@ansi
printstyled("this is my color"; color = :red)
```
Output
julia> printstyled("this is my color"; color = :red)
this is my color
A more colorful example from documenter:
Input
```@ansi
for color in 0:15
print("\e[38;5;$color;48;5;$(color)m ")
print("\e[49m", lpad(color, 3), " ")
color % 8 == 7 && println() # [!code highlight]
end
```
Output
julia> for color in 0:15
print("\e[38;5;$color;48;5;$(color)m ")
print("\e[49m", lpad(color, 3), " ")
color % 8 == 7 && println()
end
0 1 2 3 4 5 6 7
8 9 10 11 12 13 14 15
@eval
From Julia's documentation landing page.
Input
```@eval
io = IOBuffer()
release = isempty(VERSION.prerelease)
v = "$(VERSION.major).$(VERSION.minor)"
!release && (v = v*"-$(first(VERSION.prerelease))")
print(io, """
# Julia $(v) Documentation
Welcome to the documentation for Julia $(v).
""")
if true # !release
print(io,"""
!!! warning "Work in progress!"
This documentation is for an unreleased, in-development, version of Julia.
""")
end
import Markdown
Markdown.parse(String(take!(io)))
```
```@eval
file = "julia-1.10.2.pdf"
url = "https://raw.githubusercontent.com/JuliaLang/docs.julialang.org/assets/$(file)"
import Markdown
Markdown.parse("""
!!! note
The documentation is also available in PDF format: [$file]($url).
""")
```
Output
Julia 1.11 Documentation
Welcome to the documentation for Julia 1.11.
Work in progress!
This documentation is for an unreleased, in-development, version of Julia.
Note
The documentation is also available in PDF format: julia-1.10.2.pdf.
@repl
Input
```@repl
a = 1;
b = 2;
a + b
```
Output
julia> a = 1;
julia> b = 2;
julia> a + b
3
Input
```@repl
a = 1;
b = 2; # [!code focus] # hide
a + b
```
Output
julia> a = 1;
julia> a + b
3
@doctest
Input
```@doctest
julia> 1 + 1
2
```
Output
julia> 1 + 1
2
@meta
Supported meta tags:
CollapsedDocStrings
: works similar to Documenter.jl. If provided, the docstrings in that page will be collapsed by default. Defaults tofalse
. See the Internal API page for how the docstrings are displayed when this is set totrue
. Example usage:
Input
```@meta
CollapsedDocStrings = true
```