<NME> functions.md
<BEF> 
```@meta
CurrentModule = Main.Mod
```

# Function Index

```@index
Pages = ["lib/functions.md"]
```

# Functions

[`ccall`](@ref), [`func(x)`](@ref), [`T`](@ref), [`for`](@ref), and [`while`](@ref).

```@docs
func(x)
T
ccall
for
while

# Foo

## Foo

### Foo

#### Foo
```

```@example continued-code
A = 1
```
```@example continued-code; continued = true
for i in 1:3
```
```@example
A = 2
```
```@example continued-code; continued = true
    println(A + i)
```
```@example continued-code
end
```
```@example continued-code
A + 1
```

#### Foo

```@example
a = 1
b = ans
@assert a === b
```

```@repl
using Random    # hide
Random.seed!(1) # hide
nothing
rand()
a = 1
println(a)
b = 2
a + b
struct T
    x :: Int
    y :: Vector
end
x = T(1, [1])
x.y
x.x
```

```@repl 1
d = 1
```

```@repl 1
println(d)
```

Test setup function

```@setup testsetup
w = 5
```

```@example testsetup
@assert w === 5
```

```@repl testsetup
@assert w === 5
```

# Autodocs

```@meta
CurrentModule = Main
```

## AutoDocs Module

```@autodocs
Modules = [AutoDocs]
```

## Functions, Modules, and Macros

```@autodocs
Modules = [AutoDocs.A, AutoDocs.B]
Order   = [:function, :module, :macro]
```

## Constants and Types

```@autodocs
Modules = [AutoDocs.A, AutoDocs.B]
Order   = [:constant, :type]
```

## Autodocs by Page

```@autodocs
Modules = [AutoDocs.Pages]
Pages = ["a.jl", "b.jl"]
```

```@autodocs
Modules = [AutoDocs.Pages]
Pages = ["c.jl", "d.jl"]
```

A footnote reference [^footnote].

# Named docstring `@ref`s

  * a normal docstring `@ref` link: [`AutoDocs.Pages.f`](@ref);
  * a named docstring `@ref` link: [`f`](@ref AutoDocs.Pages.f);
  * and a link with custom text: [`@time 1 + 2`](@ref @time);
  * some invalid syntax: [`for i = 1:10; ...`](@ref for).

<MSG> Adds {example} blocks.

Output the contents of the block as well as the result of evaluation,
includes the `STDOUT`/`STDERR` streams.

Named `{example <name>}` blocks share the same sandbox module to allow
for commentary between parts of an example while retaining defined
values.

`{example}` and `{example <name>}` do not share state across pages
since the order of evaluation of pages is purposefully undefined.

(Currently an experimental feature and undocumented.)

<DFF> @@ -22,8 +22,73 @@
 
 # Foo
 
+```julia
+{example}
+@show pwd()
+a = 1
+```
+
+...
+
+```julia
+{example}
+isdefined(:a)
+```
+
+```julia
+{example 1}
+f(x) = 2x
+g(x) = 3x
+nothing # hide
+```
+
+```julia
+{example 2}
+x, y = 1, 2
+println(x, y)
+```
+
+```julia
+{example 3}
+type T end
+t = T()
+```
+
 ## Foo
 
+```julia
+{example 3}
+isdefined(:T)
+@show isdefined(:t) # hide
+@show typeof(T)
+typeof(t) # hide
+```
+
+```julia
+{example 2}
+x + y
+```
+
+```julia
+{example 1}
+f(2), g(2)
+```
+
 ### Foo
 
+```julia
+{example 2}
+x - y
+```
+
+```julia
+{example 1}
+f(1), g(1)
+```
+
+```julia
+{example 3}
+@which T()
+```
+
 #### Foo

Adds {example} blocks.