Browse Source

fix links for tag builds (#1)

pull/2/head
Fredrik Ekre 8 years ago committed by GitHub
parent
commit
3e47aac530
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      examples/example.jl
  2. 29
      src/Examples.jl

2
examples/example.jl

@ -4,7 +4,7 @@
#' The source file can be found [here](@__REPO_ROOT_URL__examples/example.jl). #' The source file can be found [here](@__REPO_ROOT_URL__examples/example.jl).
#' The generated markdown can be found here: [`example.md`](./example.md), the #' The generated markdown can be found here: [`example.md`](./example.md), the
#' generated notebook can be found here: #' generated notebook can be found here:
#' [`example.ipynb`](@__NBVIEWER__ROOT_URL__generated/example.ipynb), and the #' [`example.ipynb`](@__NBVIEWER_ROOT_URL__generated/example.ipynb), and the
#' plain script output can be found here: [`example.jl`](./example.jl). #' plain script output can be found here: [`example.jl`](./example.jl).
#' ### Rational numbers in Julia #' ### Rational numbers in Julia

29
src/Examples.jl

@ -461,16 +461,27 @@ function execute_notebook(nb)
nb nb
end end
function fixlinks(content; commit = "master") function fixlinks(content; branch = "gh-pages", commit = "master")
# replace @__REPO__ to master/commit if get(ENV, "HAS_JOSH_K_SEAL_OF_APPROVAL", "") == "true"
repo = get(ENV, "TRAVIS_REPO_SLUG", "") travis_repo_slug = get(ENV, "TRAVIS_REPO_SLUG", "")
root_url = "https://github.com/$(repo)/blob/$(commit)/" # use same logic as Documenter to figure out the deploy folder
content = replace(content, "@__REPO_ROOT_URL__" => root_url) travis_tag = get(ENV, "TRAVIS_TAG", "")
# replace @__NBVIEWER__ to latest or version directory if isempty(travis_tag)
folder = "latest" folder = "latest"
branch = "gh-pages" else
nbviewer_root_url = "https://nbviewer.jupyter.org/github/$(repo)/blob/$(branch)/$(folder)/" # use the versioned directory for links, even for the stable and release-
content = replace(content, "@__NBVIEWER__ROOT_URL__" => nbviewer_root_url) # folders since this will never change
folder = travis_tag
end
# replace @__REPO_ROOT_URL__ to master/commit
repo_root_url = "https://github.com/$(travis_repo_slug)/blob/$(commit)/"
content = replace(content, "@__REPO_ROOT_URL__" => repo_root_url)
# replace @__NBVIEWER_ROOT_URL__ to latest or version directory
nbviewer_root_url = "https://nbviewer.jupyter.org/github/$(travis_repo_slug)/blob/$(branch)/$(folder)/"
content = replace(content, "@__NBVIEWER_ROOT_URL__" => nbviewer_root_url)
else
@info "not running on Travis, skipping link-fix."
end
return content return content
end end

Loading…
Cancel
Save