Skip to content

Commit e9ee3ef

Browse files
authored
Fix docs urls (#45)
1 parent 25d9fcf commit e9ee3ef

File tree

10 files changed

+68
-115
lines changed

10 files changed

+68
-115
lines changed

docs/inc/reproduce.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
# ### Reproducibility
3+
4+
# This page was generated with the following version of Julia:
5+
using InteractiveUtils: versioninfo
6+
io = IOBuffer(); versioninfo(io); split(String(take!(io)), '\n')
7+
8+
# And with the following package versions
9+
import Pkg; Pkg.status()

docs/inc/urls.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
#=
3+
This page comes from a single Julia file:
4+
[`@__NAME__.jl`](xxxrepo/@__NAME__.jl).
5+
6+
You can access the source code
7+
for such Julia documentation
8+
using the 'Edit on GitHub' link in the top right.
9+
You can view the corresponding notebook in
10+
[nbviewer](https://nbviewer.org/) here:
11+
[`@__NAME__.ipynb`](xxxnb/@__NAME__.ipynb),
12+
or open it in [binder](https://mybinder.org/) here:
13+
[`@__NAME__.ipynb`](xxxbinder/@__NAME__.ipynb).
14+
=#

docs/lit/examples/1-overview.jl

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,11 @@
33
44
This page gives an overview of the Julia package
55
[`SPECTrecon`](https://github.com/JuliaImageRecon/SPECTrecon.jl).
6-
7-
This page was generated from a single Julia file:
8-
[1-overview.jl](@__REPO_ROOT_URL__/1-overview.jl).
96
=#
107

11-
#md # In any such Julia documentation,
12-
#md # you can access the source code
13-
#md # using the "Edit on GitHub" link in the top right.
14-
15-
#md # The corresponding notebook can be viewed in
16-
#md # [nbviewer](https://nbviewer.org/) here:
17-
#md # [`1-overview.ipynb`](@__NBVIEWER_ROOT_URL__/1-overview.ipynb),
18-
#md # and opened in [binder](https://mybinder.org/) here:
19-
#md # [`1-overview.ipynb`](@__BINDER_ROOT_URL__/1-overview.ipynb).
8+
#srcURL
209

21-
# ## Setup
10+
# ### Setup
2211

2312
# Packages needed here.
2413

@@ -247,13 +236,4 @@ end
247236
gif(anim, "views.gif", fps = 8)
248237

249238

250-
# ## Reproducibility
251-
252-
# This page was generated with the following version of Julia:
253-
254-
io = IOBuffer(); versioninfo(io); split(String(take!(io)), '\n')
255-
256-
257-
# And with the following package versions
258-
259-
import Pkg; Pkg.status()
239+
include("../../../inc/reproduce.jl")

docs/lit/examples/2-rotate.jl

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,9 @@
33
44
This page explains the image rotation portion of the Julia package
55
[`SPECTrecon.jl`](https://github.com/JuliaImageRecon/SPECTrecon.jl).
6-
7-
This page was generated from a single Julia file:
8-
[2-rotate.jl](@__REPO_ROOT_URL__/2-rotate.jl).
96
=#
107

11-
#md # In any such Julia documentation,
12-
#md # you can access the source code
13-
#md # using the "Edit on GitHub" link in the top right.
14-
15-
#md # The corresponding notebook can be viewed in
16-
#md # [nbviewer](https://nbviewer.org/) here:
17-
#md # [`2-rotate.ipynb`](@__NBVIEWER_ROOT_URL__/2-rotate.ipynb),
18-
#md # and opened in [binder](https://mybinder.org/) here:
19-
#md # [`2-rotate.ipynb`](@__BINDER_ROOT_URL__/2-rotate.ipynb).
8+
#srcURL
209

2110
# ## Setup
2211

docs/lit/examples/3-psf.jl

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,9 @@
33
44
This page explains the PSF portion of the Julia package
55
[`SPECTrecon.jl`](https://github.com/JuliaImageRecon/SPECTrecon.jl).
6-
7-
This page was generated from a single Julia file:
8-
[3-psf.jl](@__REPO_ROOT_URL__/3-psf.jl).
96
=#
107

11-
#md # In any such Julia documentation,
12-
#md # you can access the source code
13-
#md # using the "Edit on GitHub" link in the top right.
14-
15-
#md # The corresponding notebook can be viewed in
16-
#md # [nbviewer](https://nbviewer.org/) here:
17-
#md # [`3-psf.ipynb`](@__NBVIEWER_ROOT_URL__/3-psf.ipynb),
18-
#md # and opened in [binder](https://mybinder.org/) here:
19-
#md # [`3-psf.ipynb`](@__BINDER_ROOT_URL__/3-psf.ipynb).
8+
#srcURL
209

2110
# ## Setup
2211

docs/lit/examples/4-mlem.jl

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,9 @@
33
44
This page illustrates ML-EM reconstruction with the Julia package
55
[`SPECTrecon`](https://github.com/JuliaImageRecon/SPECTrecon.jl).
6-
7-
This page was generated from a single Julia file:
8-
[4-mlem.jl](@__REPO_ROOT_URL__/4-mlem.jl).
96
=#
107

11-
#md # In any such Julia documentation,
12-
#md # you can access the source code
13-
#md # using the "Edit on GitHub" link in the top right.
14-
15-
#md # The corresponding notebook can be viewed in
16-
#md # [nbviewer](https://nbviewer.org/) here:
17-
#md # [`4-mlem.ipynb`](@__NBVIEWER_ROOT_URL__/4-mlem.ipynb),
18-
#md # and opened in [binder](https://mybinder.org/) here:
19-
#md # [`4-mlem.ipynb`](@__BINDER_ROOT_URL__/4-mlem.ipynb).
8+
#srcURL
209

2110
# ## Setup
2211

docs/lit/examples/5-2d.jl

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,9 @@
44
This page describes how to perform 2D SPECT forward and back-projection
55
using the Julia package
66
[`SPECTrecon`](https://github.com/JuliaImageRecon/SPECTrecon.jl).
7-
8-
This page was generated from a single Julia file:
9-
[5-2d.jl](@__REPO_ROOT_URL__/5-2d.jl).
107
=#
118

12-
#md # In any such Julia documentation,
13-
#md # you can access the source code
14-
#md # using the "Edit on GitHub" link in the top right.
15-
16-
#md # The corresponding notebook can be viewed in
17-
#md # [nbviewer](https://nbviewer.org/) here:
18-
#md # [`5-2d.ipynb`](@__NBVIEWER_ROOT_URL__/5-2d.ipynb),
19-
#md # and opened in [binder](https://mybinder.org/) here:
20-
#md # [`5-2d.ipynb`](@__BINDER_ROOT_URL__/5-2d.ipynb).
21-
9+
#srcURL
2210

2311
# ### Setup
2412

docs/lit/examples/6-dl.jl

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,9 @@
44
This page describes how to end-to-end train unrolled deep learning algorithms
55
using the Julia package
66
[`SPECTrecon`](https://github.com/JuliaImageRecon/SPECTrecon.jl).
7-
8-
This page was generated from a single Julia file:
9-
[6-dl.jl](@__REPO_ROOT_URL__/6-dl.jl).
107
=#
118

12-
#md # In any such Julia documentation,
13-
#md # you can access the source code
14-
#md # using the "Edit on GitHub" link in the top right.
15-
16-
#md # The corresponding notebook can be viewed in
17-
#md # [nbviewer](https://nbviewer.org/) here:
18-
#md # [`6-dl.ipynb`](@__NBVIEWER_ROOT_URL__/6-dl.ipynb),
19-
#md # and opened in [binder](https://mybinder.org/) here:
20-
#md # [`6-dl.ipynb`](@__BINDER_ROOT_URL__/6-dl.ipynb).
9+
#srcURL
2110

2211

2312
# ### Setup
@@ -295,13 +284,4 @@ see [https://doi.org/10.1109/EMBC46164.2021.9630985](https://doi.org/10.1109/EMB
295284
=#
296285

297286

298-
# ### Reproducibility
299-
300-
# This page was generated with the following version of Julia:
301-
302-
io = IOBuffer(); versioninfo(io); split(String(take!(io)), '\n')
303-
304-
305-
# And with the following package versions
306-
307-
import Pkg; Pkg.status()
287+
include("../../../inc/reproduce.jl")

docs/lit/examples/7-osem.jl

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,9 @@ This page illustrates
55
Ordered-subset expectation-maximization (OS-EM)
66
image reconstruction with the Julia package
77
[`SPECTrecon`](https://github.com/JuliaImageRecon/SPECTrecon.jl).
8-
9-
This page was generated from a single Julia file:
10-
[7-osem.jl](@__REPO_ROOT_URL__/7-osem.jl).
118
=#
129

13-
#md # In any such Julia documentation,
14-
#md # you can access the source code
15-
#md # using the "Edit on GitHub" link in the top right.
16-
17-
#md # The corresponding notebook can be viewed in
18-
#md # [nbviewer](https://nbviewer.org/) here:
19-
#md # [`7-osem.ipynb`](@__NBVIEWER_ROOT_URL__/7-osem.ipynb),
20-
#md # and opened in [binder](https://mybinder.org/) here:
21-
#md # [`7-osem.ipynb`](@__BINDER_ROOT_URL__/7-osem.ipynb).
10+
#srcURL
2211

2312
# ### Setup
2413

docs/make.jl

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,53 @@ src = joinpath(@__DIR__, "src")
1515
gen = joinpath(@__DIR__, "src/generated")
1616

1717
base = "$org/$reps.jl"
18-
repo_root_url =
19-
"https://github.com/$base/blob/main/docs/lit/examples"
18+
repo_root_url = "https://github.com/$base/blob/main"
2019
nbviewer_root_url =
21-
"https://nbviewer.org/github/$base/tree/gh-pages/dev/generated/examples"
20+
"https://nbviewer.org/github/$base/tree/gh-pages/dev/generated"
2221
binder_root_url =
23-
"https://mybinder.org/v2/gh/$base/gh-pages?filepath=dev/generated/examples"
22+
"https://mybinder.org/v2/gh/$base/gh-pages?filepath=dev/generated"
2423

2524

2625
repo = eval(:($reps))
2726
DocMeta.setdocmeta!(repo, :DocTestSetup, :(using $reps); recursive=true)
2827

2928
#ENV["JULIA_DEBUG"] = "Literate"
3029

30+
# preprocessing
31+
inc1 = "include(\"../../../inc/reproduce.jl\")"
32+
33+
function prep_markdown(str, root, file)
34+
inc_read(file) = read(joinpath("docs/inc", file), String)
35+
repro = inc_read("reproduce.jl")
36+
str = replace(str, inc1 => repro)
37+
urls = inc_read("urls.jl")
38+
file = joinpath(splitpath(root)[end], splitext(file)[1])
39+
tmp = splitpath(root)[end-2:end] # docs lit examples
40+
urls = replace(urls,
41+
"xxxrepo" => joinpath(repo_root_url, tmp...),
42+
"xxxnb" => joinpath(nbviewer_root_url, tmp[end]),
43+
"xxxbinder" => joinpath(binder_root_url, tmp[end]),
44+
)
45+
str = replace(str, "#srcURL" => urls)
46+
end
47+
48+
function prep_notebook(str)
49+
str = replace(str, inc1 => "", "#srcURL" => "")
50+
end
51+
3152
for (root, _, files) in walkdir(lit), file in files
3253
splitext(file)[2] == ".jl" || continue # process .jl files only
3354
ipath = joinpath(root, file)
3455
opath = splitdir(replace(ipath, lit => gen))[1]
35-
Literate.markdown(ipath, opath, documenter = execute; # run examples
36-
repo_root_url, nbviewer_root_url, binder_root_url)
37-
Literate.notebook(ipath, opath; execute = false, # no-run notebooks
38-
repo_root_url, nbviewer_root_url, binder_root_url)
56+
Literate.markdown(ipath, opath;
57+
repo_root_url,
58+
preprocess = str -> prep_markdown(str, root, file),
59+
documenter = execute, # run examples
60+
)
61+
Literate.notebook(ipath, opath;
62+
preprocess = prep_notebook,
63+
execute = false, # no-run notebooks
64+
)
3965
end
4066

4167

@@ -73,7 +99,7 @@ if isci
7399
devurl = "dev",
74100
versions = ["stable" => "v^", "dev" => "dev"],
75101
forcepush = true,
76-
# push_preview = true,
102+
push_preview = true,
77103
# see https://$org.github.io/$repo.jl/previews/PR##
78104
)
79105
end

0 commit comments

Comments
 (0)