Skip to content

Commit 9e3f51d

Browse files
Restructure documentation to remove API reference level
- Moved API reference content to index page (generated from make.jl) - Removed separate API reference page level from navigation - Reorganized all pages to show summaries before docstrings - Updated pages.jl to have flat navigation structure - All category pages now appear directly in sidebar - Index page contains comprehensive API guidance and navigation Documentation structure now follows: - Home (with API reference) → Category pages directly - Each page: Summary/Notes → Functions → Cache 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5409eb4 commit 9e3f51d

File tree

8 files changed

+117
-127
lines changed

8 files changed

+117
-127
lines changed

docs/make.jl

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,50 @@ open(joinpath(@__DIR__, "src", "index.md"), "w") do io
2323
for line in eachline(joinpath(dirname(@__DIR__), "README.md"))
2424
println(io, line)
2525
end
26+
27+
# Add API reference content
28+
println(io, "")
29+
println(io, "## API Reference")
30+
println(io, "")
31+
println(io, "```@docs")
32+
println(io, "FiniteDiff")
33+
println(io, "```")
34+
println(io, "")
35+
println(io, "FiniteDiff.jl provides fast, non-allocating finite difference calculations with support for sparsity patterns and various array types. The API is organized into several categories:")
36+
println(io, "")
37+
println(io, "### Function Categories")
38+
println(io, "")
39+
println(io, "- **[Derivatives](@ref derivatives)**: Single and multi-point derivatives of scalar functions")
40+
println(io, "- **[Gradients](@ref gradients)**: Gradients of scalar-valued functions with respect to vector inputs")
41+
println(io, "- **[Jacobians](@ref jacobians)**: Jacobian matrices of vector-valued functions, including sparse Jacobian support")
42+
println(io, "- **[Hessians](@ref hessians)**: Hessian matrices of scalar-valued functions")
43+
println(io, "- **[Jacobian-Vector Products](@ref jvp)**: Efficient computation of directional derivatives without forming full Jacobians")
44+
println(io, "- **[Utilities](@ref utilities)**: Internal utilities and helper functions")
45+
println(io, "")
46+
println(io, "### Quick Start")
47+
println(io, "")
48+
println(io, "All functions follow a consistent API pattern:")
49+
println(io, "")
50+
println(io, "- **Cache-less versions**: `finite_difference_*` - convenient but allocate temporary arrays")
51+
println(io, "- **In-place versions**: `finite_difference_*!` - efficient, non-allocating when used with caches")
52+
println(io, "- **Cache constructors**: `*Cache` - pre-allocate work arrays for repeated computations")
53+
println(io, "")
54+
println(io, "### Method Selection")
55+
println(io, "")
56+
println(io, "Choose your finite difference method based on accuracy and performance needs:")
57+
println(io, "")
58+
println(io, "- **Forward differences**: Fast, `O(h)` accuracy, requires `O(n)` function evaluations")
59+
println(io, "- **Central differences**: More accurate `O(h²)`, requires `O(2n)` function evaluations")
60+
println(io, "- **Complex step**: Machine precision accuracy, `O(n)` evaluations, requires complex-analytic functions")
61+
println(io, "")
62+
println(io, "### Performance Tips")
63+
println(io, "")
64+
println(io, "1. **Use caches** for repeated computations to avoid allocations")
65+
println(io, "2. **Consider sparsity** for large Jacobians with known sparsity patterns")
66+
println(io, "3. **Choose appropriate methods** based on your accuracy requirements")
67+
println(io, "4. **Leverage JVPs** when you only need directional derivatives")
68+
println(io, "")
69+
2670
for line in eachline(joinpath(@__DIR__, "src", "reproducibility.md"))
2771
println(io, line)
2872
end

docs/pages.jl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
pages = [
44
"Home" => "index.md",
55
"Tutorials" => "tutorials.md",
6-
"API Reference" => [
7-
"Overview" => "api.md",
8-
"Derivatives" => "derivatives.md",
9-
"Gradients" => "gradients.md",
10-
"Jacobians" => "jacobians.md",
11-
"Hessians" => "hessians.md",
12-
"Jacobian-Vector Products" => "jvp.md",
13-
"Utilities" => "utilities.md"
14-
]
6+
"Derivatives" => "derivatives.md",
7+
"Gradients" => "gradients.md",
8+
"Jacobians" => "jacobians.md",
9+
"Hessians" => "hessians.md",
10+
"Jacobian-Vector Products" => "jvp.md",
11+
"Utilities" => "utilities.md"
1512
]

docs/src/api.md

Lines changed: 0 additions & 51 deletions
This file was deleted.

docs/src/derivatives.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
Functions for computing derivatives of scalar-valued functions.
44

5+
## Overview
6+
7+
Derivatives are computed for scalar→scalar maps `f(x)` where `x` can be a single point or a collection of points. The derivative functions support:
8+
9+
- **Forward differences**: `O(1)` function evaluation per point, `O(h)` accuracy
10+
- **Central differences**: `O(2)` function evaluations per point, `O(h²)` accuracy
11+
- **Complex step**: `O(1)` function evaluation per point, machine precision accuracy
12+
13+
For optimal performance with repeated computations, use the cached versions with `DerivativeCache`.
14+
515
## Functions
616

717
```@docs
@@ -13,14 +23,4 @@ FiniteDiff.finite_difference_derivative!
1323

1424
```@docs
1525
FiniteDiff.DerivativeCache
16-
```
17-
18-
## Notes
19-
20-
Derivatives are computed for scalar→scalar maps `f(x)` where `x` can be a single point or a collection of points. The derivative functions support:
21-
22-
- **Forward differences**: `O(1)` function evaluation per point, `O(h)` accuracy
23-
- **Central differences**: `O(2)` function evaluations per point, `O(h²)` accuracy
24-
- **Complex step**: `O(1)` function evaluation per point, machine precision accuracy
25-
26-
For optimal performance with repeated computations, use the cached versions with `DerivativeCache`.
26+
```

docs/src/gradients.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,6 @@
22

33
Functions for computing gradients of scalar-valued functions with respect to vector inputs.
44

5-
## Functions
6-
7-
```@docs
8-
FiniteDiff.finite_difference_gradient
9-
FiniteDiff.finite_difference_gradient!
10-
```
11-
12-
## Cache
13-
14-
```@docs
15-
FiniteDiff.GradientCache
16-
```
17-
185
## Function Types
196

207
Gradients support two types of function mappings:
@@ -35,4 +22,17 @@ When using `GradientCache` with pre-computed function values:
3522
- If you provide `fx`, then `fx` will be used in forward differencing to skip a function call
3623
- You must update `cache.fx` before each call to `finite_difference_gradient!`
3724
- For immutable types (scalars, `StaticArray`), use `@set` from [Setfield.jl](https://github.com/jw3126/Setfield.jl)
38-
- Consider aliasing existing arrays into the cache for memory efficiency
25+
- Consider aliasing existing arrays into the cache for memory efficiency
26+
27+
## Functions
28+
29+
```@docs
30+
FiniteDiff.finite_difference_gradient
31+
FiniteDiff.finite_difference_gradient!
32+
```
33+
34+
## Cache
35+
36+
```@docs
37+
FiniteDiff.GradientCache
38+
```

docs/src/hessians.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,6 @@
22

33
Functions for computing Hessian matrices of scalar-valued functions.
44

5-
## Functions
6-
7-
```@docs
8-
FiniteDiff.finite_difference_hessian
9-
FiniteDiff.finite_difference_hessian!
10-
```
11-
12-
## Cache
13-
14-
```@docs
15-
FiniteDiff.HessianCache
16-
```
17-
185
## Function Requirements
196

207
Hessian functions are designed for scalar-valued functions `f(x)` where:
@@ -42,4 +29,17 @@ where `eᵢ` is the i-th unit vector and `hᵢ` is the step size in dimension i.
4229

4330
## StaticArrays Support
4431

45-
The cache constructor automatically detects `StaticArray` types and adjusts the `inplace` parameter accordingly for optimal performance.
32+
The cache constructor automatically detects `StaticArray` types and adjusts the `inplace` parameter accordingly for optimal performance.
33+
34+
## Functions
35+
36+
```@docs
37+
FiniteDiff.finite_difference_hessian
38+
FiniteDiff.finite_difference_hessian!
39+
```
40+
41+
## Cache
42+
43+
```@docs
44+
FiniteDiff.HessianCache
45+
```

docs/src/jacobians.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,6 @@
22

33
Functions for computing Jacobian matrices of vector-valued functions.
44

5-
## Functions
6-
7-
```@docs
8-
FiniteDiff.finite_difference_jacobian
9-
FiniteDiff.finite_difference_jacobian!
10-
```
11-
12-
## Cache
13-
14-
```@docs
15-
FiniteDiff.JacobianCache
16-
```
17-
185
## Function Types
196

207
Jacobians support the following function signatures:
@@ -38,4 +25,17 @@ FiniteDiff.jl provides efficient sparse Jacobian computation using graph colorin
3825
- **Complex step**: `O(n)` function evaluations, machine precision accuracy
3926
- **Sparse Jacobians**: Use graph coloring to reduce function evaluations significantly
4027

41-
For non-square Jacobians, specify the output vector `fx` when creating the cache to ensure proper sizing.
28+
For non-square Jacobians, specify the output vector `fx` when creating the cache to ensure proper sizing.
29+
30+
## Functions
31+
32+
```@docs
33+
FiniteDiff.finite_difference_jacobian
34+
FiniteDiff.finite_difference_jacobian!
35+
```
36+
37+
## Cache
38+
39+
```@docs
40+
FiniteDiff.JacobianCache
41+
```

docs/src/jvp.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,6 @@
22

33
Functions for computing Jacobian-vector products efficiently without forming the full Jacobian matrix.
44

5-
## Functions
6-
7-
```@docs
8-
FiniteDiff.finite_difference_jvp
9-
FiniteDiff.finite_difference_jvp!
10-
```
11-
12-
## Cache
13-
14-
```@docs
15-
FiniteDiff.JVPCache
16-
```
17-
185
## Mathematical Background
196

207
The JVP computes `J(x) * v` where `J(x)` is the Jacobian of function `f` at point `x` and `v` is a direction vector. This is computed using finite difference approximations:
@@ -45,4 +32,17 @@ JVP is particularly useful for:
4532
## Limitations
4633

4734
- **Complex step**: JVP does not currently support complex step differentiation (`Val(:complex)`)
48-
- **In-place functions**: For in-place function evaluation, ensure proper cache sizing
35+
- **In-place functions**: For in-place function evaluation, ensure proper cache sizing
36+
37+
## Functions
38+
39+
```@docs
40+
FiniteDiff.finite_difference_jvp
41+
FiniteDiff.finite_difference_jvp!
42+
```
43+
44+
## Cache
45+
46+
```@docs
47+
FiniteDiff.JVPCache
48+
```

0 commit comments

Comments
 (0)