Skip to content

Commit

Permalink
Fix docs urls (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffFessler authored Feb 18, 2023
1 parent 9910471 commit 49ca5c8
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 61 deletions.
9 changes: 9 additions & 0 deletions docs/inc/reproduce.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

# ### Reproducibility

# This page was generated with the following version of Julia:
using InteractiveUtils: versioninfo
io = IOBuffer(); versioninfo(io); split(String(take!(io)), '\n')

# And with the following package versions
import Pkg; Pkg.status()
14 changes: 14 additions & 0 deletions docs/inc/urls.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

#=
This page comes from a single Julia file:
[`@__NAME__.jl`](xxxrepo/@__NAME__.jl).
You can access the source code
for such Julia documentation
using the 'Edit on GitHub' link in the top right.
You can view the corresponding notebook in
[nbviewer](https://nbviewer.org/) here:
[`@__NAME__.ipynb`](xxxnb/@__NAME__.ipynb),
or open it in [binder](https://mybinder.org/) here:
[`@__NAME__.ipynb`](xxxbinder/@__NAME__.ipynb).
=#
6 changes: 3 additions & 3 deletions docs/lit/examples/1-mirt.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#---------------------------------------------------------
# # [MIRT overview](@id 1-mirt)
#---------------------------------------------------------
#=
# [MIRT overview](@id 1-mirt)
=#

#=
The Julia package
Expand Down
31 changes: 4 additions & 27 deletions docs/lit/examples/2-nufft.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#---------------------------------------------------------
# # [NUFFT](@id 2-nufft)
#---------------------------------------------------------

#=
# [NUFFT](@id 2-nufft)
Examples illustrating the `nufft` methods
in the Julia package
[`MIRT`](https://github.com/JeffFessler/MIRT.jl).
Expand All @@ -17,21 +15,9 @@ about of the approximation error
for that package
and they help verify the correctness
of the wrapper.
This page was generated from a single Julia file:
[2-nufft.jl](@__REPO_ROOT_URL__/2-nufft.jl).
=#

#md # In any such Julia documentation,
#md # you can access the source code
#md # using the "Edit on GitHub" link in the top right.

#md # The corresponding notebook can be viewed in
#md # [nbviewer](http://nbviewer.jupyter.org/) here:
#md # [`2-nufft.ipynb`](@__NBVIEWER_ROOT_URL__/2-nufft.ipynb),
#md # and opened in [binder](https://mybinder.org/) here:
#md # [`2-nufft.ipynb`](@__BINDER_ROOT_URL__/2-nufft.ipynb).

#srcURL

# ### Setup

Expand Down Expand Up @@ -130,13 +116,4 @@ ps = scatter(slist, worst_s,
prompt()


# ### Reproducibility

# This page was generated with the following version of Julia:

io = IOBuffer(); versioninfo(io); split(String(take!(io)), '\n')


# And with the following package versions

import Pkg; Pkg.status()
include("../../../inc/reproduce.jl")
24 changes: 2 additions & 22 deletions docs/lit/examples/3-ls-mm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,9 @@ in the Julia package
[`MIRT`](https://github.com/JeffFessler/MIRT.jl).
This method is probably most useful
for algorithm developers.
This page was generated from a single Julia file:
[3-ls-mm.jl](@__REPO_ROOT_URL__/3-ls-mm.jl).
=#

#md # In any such Julia documentation,
#md # you can access the source code
#md # using the "Edit on GitHub" link in the top right.

#md # The corresponding notebook can be viewed in
#md # [nbviewer](http://nbviewer.jupyter.org/) here:
#md # [`3-ls-mm.ipynb`](@__NBVIEWER_ROOT_URL__/3-ls-mm.ipynb),
#md # and opened in [binder](https://mybinder.org/) here:
#md # [`3-ls-mm.ipynb`](@__BINDER_ROOT_URL__/3-ls-mm.ipynb).
#srcURL


# ### Setup
Expand Down Expand Up @@ -469,13 +458,4 @@ of `line_search_mm`.
prompt()


# ### Reproducibility

# This page was generated with the following version of Julia:

io = IOBuffer(); versioninfo(io); split(String(take!(io)), '\n')


# And with the following package versions

import Pkg; Pkg.status()
include("../../../inc/reproduce.jl")
44 changes: 35 additions & 9 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,51 @@ src = joinpath(@__DIR__, "src")
gen = joinpath(@__DIR__, "src/generated")

base = "$org/$reps.jl"
repo_root_url =
"https://github.com/$base/blob/main/docs/lit/examples"
repo_root_url = "https://github.com/$base/blob/main"
nbviewer_root_url =
"https://nbviewer.org/github/$base/tree/gh-pages/dev/generated/examples"
"https://nbviewer.org/github/$base/tree/gh-pages/dev/generated"
binder_root_url =
"https://mybinder.org/v2/gh/$base/gh-pages?filepath=dev/generated/examples"
"https://mybinder.org/v2/gh/$base/gh-pages?filepath=dev/generated"


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

# preprocessing
inc1 = "include(\"../../../inc/reproduce.jl\")"

function prep_markdown(str, root, file)
inc_read(file) = read(joinpath("docs/inc", file), String)
repro = inc_read("reproduce.jl")
str = replace(str, inc1 => repro)
urls = inc_read("urls.jl")
file = joinpath(splitpath(root)[end], splitext(file)[1])
tmp = splitpath(root)[end-2:end] # docs lit examples
urls = replace(urls,
"xxxrepo" => joinpath(repo_root_url, tmp...),
"xxxnb" => joinpath(nbviewer_root_url, tmp[end]),
"xxxbinder" => joinpath(binder_root_url, tmp[end]),
)
str = replace(str, "#srcURL" => urls)
end

function prep_notebook(str)
str = replace(str, inc1 => "", "#srcURL" => "")
end

for (root, _, files) in walkdir(lit), file in files
splitext(file)[2] == ".jl" || continue # process .jl files only
ipath = joinpath(root, file)
opath = splitdir(replace(ipath, lit => gen))[1]
Literate.markdown(ipath, opath; documenter = execute, # run examples
repo_root_url, nbviewer_root_url, binder_root_url)
Literate.notebook(ipath, opath; execute = false, # no-run notebooks
repo_root_url, nbviewer_root_url, binder_root_url)
Literate.markdown(ipath, opath;
repo_root_url,
preprocess = str -> prep_markdown(str, root, file),
documenter = execute, # run examples
)
Literate.notebook(ipath, opath;
preprocess = prep_notebook,
execute = false, # no-run notebooks
)
end


Expand Down Expand Up @@ -76,7 +102,7 @@ if isci
devurl = "dev",
versions = ["stable" => "v^", "dev" => "dev"],
forcepush = true,
# push_preview = true,
push_preview = true,
# see https://$org.github.io/$repo.jl/previews/PR##
)
end

0 comments on commit 49ca5c8

Please sign in to comment.