Skip to content

Commit 3210e76

Browse files
authored
Fix doctests (#2265)
* Fix doctests The filter already attempted to address the issue, but the syntax was incorrect with the result that no substitution was applied. Also, remove messing with `LOAD_PATH` and use `sources` section in docs project. * Add some color to life
1 parent 70a2940 commit 3210e76

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

.github/workflows/CI.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,16 @@ jobs:
9595
continue-on-error: ${{ matrix.version == 'nightly' }}
9696
id: build_libenzyme
9797
run: |
98-
julia --project=deps -e 'using Pkg; Pkg.instantiate()'
99-
julia --project=deps deps/build_local.jl
98+
julia --color=yes --project=deps -e 'using Pkg; Pkg.instantiate()'
99+
julia --color=yes --project=deps deps/build_local.jl
100100
cp LocalPreferences.toml test/
101101
- name: Build libEnzyme MacOS
102102
if: ${{ matrix.libEnzyme == 'local' && matrix.os == 'macOS-latest'}}
103103
continue-on-error: ${{ matrix.version == 'nightly' }}
104104
id: build_libenzyme_mac
105105
run: |
106-
julia --project=deps -e 'using Pkg; Pkg.instantiate()'
107-
SDKROOT=`xcrun --show-sdk-path` julia --project=deps deps/build_local.jl
106+
julia --color=yes --project=deps -e 'using Pkg; Pkg.instantiate()'
107+
SDKROOT=`xcrun --show-sdk-path` julia --color=yes --project=deps deps/build_local.jl
108108
cp LocalPreferences.toml test/
109109
- uses: julia-actions/julia-buildpkg@v1
110110
if: matrix.version != 'nightly' || steps.build_libenzyme.outcome == 'success' || steps.build_libenzyme_mac.outcome == 'success'
@@ -287,19 +287,18 @@ jobs:
287287
version: '1'
288288
- uses: julia-actions/cache@v2
289289
- run: |
290-
julia --project=docs -e '
290+
julia --color=yes --project=docs -e '
291291
using Pkg
292-
Pkg.develop([PackageSpec(path="lib/EnzymeCore"), PackageSpec(path="lib/EnzymeTestUtils"), PackageSpec(path=pwd())])
293292
Pkg.instantiate()'
294293
env:
295294
JULIA_PKG_SERVER_REGISTRY_PREFERENCE: eager
296295
- run: |
297-
julia --project=docs -e '
296+
julia --color=yes --project=docs -e '
298297
using Documenter: DocMeta, doctest
299298
using Enzyme
300299
DocMeta.setdocmeta!(Enzyme, :DocTestSetup, :(using Enzyme); recursive=true)
301300
doctest(Enzyme)'
302-
- run: julia --project=docs docs/make.jl
301+
- run: julia --color=yes --project=docs docs/make.jl
303302
env:
304303
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
305304
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ lib/EnzymeCore/Manifest.toml
77
/test/Manifest.toml
88
/docs/Manifest.toml
99
/docs/build/
10+
/docs/src/generated/
1011

1112
.vscode

docs/Project.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
33
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
4+
EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869"
5+
EnzymeTestUtils = "12d8515a-0907-448a-8884-5fe00fdf1c5a"
46
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
57
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
68

79
[compat]
810
Documenter = "1"
911
Literate = "2"
12+
13+
[sources]
14+
Enzyme = {path = ".."}
15+
EnzymeCore = {path = "../lib/EnzymeCore"}
16+
EnzymeTestUtils = {path = "../lib/EnzymeTestUtils"}

docs/make.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
pushfirst!(LOAD_PATH, joinpath(@__DIR__, "..")) # add Enzyme to environment stack
2-
pushfirst!(LOAD_PATH, joinpath(@__DIR__, "..", "lib")) # add EnzymeCore to environment stack
3-
41
using Enzyme
52
using EnzymeCore
63
using EnzymeTestUtils

docs/src/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ Enzyme provides convenience functions for second-order derivative computations,
227227

228228
Unlike [`autodiff`](@ref) and [`gradient`](@ref), a mode is not specified. Here, Enzyme will choose to perform forward over reverse mode (generally the fastest for this type of operation).
229229

230-
```jldoctest hvp; filter = r"([0-9]+\\.[0-9]{8})[0-9]+" => s"\\1***"
230+
```jldoctest hvp; filter = r"([0-9]+\.[0-9]{8})[0-9]+" => s"\1***"
231231
julia> f(x) = sin(x[1] * x[2]);
232232
233233
julia> hvp(f, [2.0, 3.0], [5.0, 2.7])
@@ -238,7 +238,7 @@ julia> hvp(f, [2.0, 3.0], [5.0, 2.7])
238238

239239
Enzyme also provides an in-place variant which will store the hessian vector product in a pre-allocated array (this will, however, still allocate another array for storing an intermediate gradient).
240240

241-
```jldoctest hvp2; filter = r"([0-9]+\\.[0-9]{8})[0-9]+" => s"\\1***"
241+
```jldoctest hvp2; filter = r"([0-9]+\.[0-9]{8})[0-9]+" => s"\1***"
242242
julia> f(x) = sin(x[1] * x[2])
243243
f (generic function with 1 method)
244244
@@ -254,7 +254,7 @@ julia> res
254254

255255
Finally. Enzyme provides a second in-place variant which simultaneously computes both the hessian vector product, and the gradient. This function uses no additional allocation, and is much more efficient than separately computing the hvp and the gradient.
256256

257-
```jldoctest hvp3; filter = r"([0-9]+\\.[0-9]{8})[0-9]+" => s"\\1***"
257+
```jldoctest hvp3; filter = r"([0-9]+\.[0-9]{8})[0-9]+" => s"\1***"
258258
julia> f(x) = sin(x[1] * x[2]);
259259
260260
julia> res = Vector{Float64}(undef, 2);

0 commit comments

Comments
 (0)