Skip to content

Commit

Permalink
Update JS/CSS dependencies (#1189)
Browse files Browse the repository at this point in the history
* Update HTML deps

* Add CHANGELOG
  • Loading branch information
mortenpi authored and fredrikekre committed Nov 22, 2019
1 parent 01bc1dc commit 0aa0520
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 28 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
* The `highlights` keyword to `HTML` can be used to declare additional languages that should be highlighted in code blocks. ([#1094][github-1094])
* It is now possible to choose between MathJax and KaTeX as the math rendering engine with the `mathengine` keyword to `HTML` and to set their configuration in the `make.jl` script directly. ([#1097][github-1097])

* ![Enhancement][badge-enhancement] The JS and CSS dependencies of the front end have been updated to the latest versions. ([#1189][github-1189])

* ![Enhancement][badge-enhancement] Displaying of the site name at the top of the sidebar can now be disabled by passing `sidebar_sitename = false` to `HTML` in the `format` keyword. ([#1089][github-1089])

* ![Enhancement][badge-enhancement] For deployments that have Google Analytics enabled, the URL fragment (i.e. the in-page `#` target) also stored in analytics. ([#1121][github-1121])
Expand Down Expand Up @@ -481,6 +483,7 @@
[github-1173]: https://github.com/JuliaDocs/Documenter.jl/pull/1173
[github-1180]: https://github.com/JuliaDocs/Documenter.jl/pull/1180
[github-1186]: https://github.com/JuliaDocs/Documenter.jl/pull/1186
[github-1189]: https://github.com/JuliaDocs/Documenter.jl/pull/1189

[documenterlatex]: https://github.com/JuliaDocs/DocumenterLaTeX.jl
[documentermarkdown]: https://github.com/JuliaDocs/DocumenterMarkdown.jl
Expand Down
2 changes: 1 addition & 1 deletion docs/src/lib/internals/writers.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Modules = [
Documenter.Writers,
Documenter.Writers.MarkdownWriter,
Documenter.Writers.HTMLWriter,
Documenter.Writers.HTMLWriter.JS,
Documenter.Writers.HTMLWriter.RD,
Documenter.Writers.LaTeXWriter,
]
```
Expand Down
2 changes: 1 addition & 1 deletion src/Documenter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ include("Deps.jl")

import .Utilities: Selectors
import .Writers.HTMLWriter: HTML, asset
import .Writers.HTMLWriter.JS: KaTeX, MathJax
import .Writers.HTMLWriter.RD: KaTeX, MathJax

# User Interface.
# ---------------
Expand Down
56 changes: 30 additions & 26 deletions src/Writers/HTMLWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -363,31 +363,34 @@ struct HTML <: Documenter.Writer
end
end

const requirejs_cdn = "https://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.min.js"
const google_fonts = "https://fonts.googleapis.com/css?family=Lato|Roboto+Mono"
const fontawesome_css = [
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/fontawesome.min.css",
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/solid.min.css",
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/brands.min.css",
]
const katex_css = "https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.css"

"Provides a namespace for JS dependencies."
module JS
"Provides a namespace for remote dependencies."
module RD
using JSON
using ....Utilities.JSDependencies: RemoteLibrary, Snippet, RequireJS, jsescape, json_jsescape
using ..HTMLWriter: KaTeX, MathJax

const jquery = RemoteLibrary("jquery", "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js")
const jqueryui = RemoteLibrary("jqueryui", "https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.0/jquery-ui.min.js")
const headroom = RemoteLibrary("headroom", "https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/headroom.min.js")
const requirejs_cdn = "https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"
const google_fonts = "https://fonts.googleapis.com/css?family=Lato|Roboto+Mono"
const fontawesome_version = "5.11.2"
const fontawesome_css = [
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/$(fontawesome_version)/css/fontawesome.min.css",
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/$(fontawesome_version)/css/solid.min.css",
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/$(fontawesome_version)/css/brands.min.css",
]

const jquery = RemoteLibrary("jquery", "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js")
const jqueryui = RemoteLibrary("jqueryui", "https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js")
const lunr = RemoteLibrary("lunr", "https://cdnjs.cloudflare.com/ajax/libs/lunr.js/2.3.6/lunr.min.js")
const lodash = RemoteLibrary("lodash", "https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js")

# headroom
const headroom_version = "0.10.3"
const headroom = RemoteLibrary("headroom", "https://cdnjs.cloudflare.com/ajax/libs/headroom/$(headroom_version)/headroom.min.js")
const headroom_jquery = RemoteLibrary(
"headroom-jquery",
"https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/jQuery.headroom.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/headroom/$(headroom_version)/jQuery.headroom.min.js",
deps = ["jquery", "headroom"],
)
const lunr = RemoteLibrary("lunr", "https://cdnjs.cloudflare.com/ajax/libs/lunr.js/2.3.5/lunr.min.js")
const lodash = RemoteLibrary("lodash", "https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.min.js")

# highlight.js
"Add the highlight.js dependencies and snippet to a [`RequireJS`](@ref) declaration."
Expand Down Expand Up @@ -421,8 +424,9 @@ module JS
end

# MathJax & KaTeX
const katex_version = "0.11.1"
const katex_css = "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/$(katex_version)/katex.min.css"
function mathengine!(r::RequireJS, engine::KaTeX)
katex_version = "0.10.2" # FIXME: upgrade KaTeX to v0.11.0
push!(r, RemoteLibrary(
"katex",
"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/$(katex_version)/katex.min.js"
Expand Down Expand Up @@ -551,10 +555,10 @@ function render(doc::Documents.Document, settings::HTML=HTML())
@warn "not creating 'documenter.js', provided by the user."
else
r = JSDependencies.RequireJS([
JS.jquery, JS.jqueryui, JS.headroom, JS.headroom_jquery,
RD.jquery, RD.jqueryui, RD.headroom, RD.headroom_jquery,
])
JS.mathengine!(r, settings.mathengine)
JS.highlightjs!(r, settings.highlights)
RD.mathengine!(r, settings.mathengine)
RD.highlightjs!(r, settings.highlights)
for filename in readdir(joinpath(ASSETS, "js"))
path = joinpath(ASSETS, "js", filename)
endswith(filename, ".js") && isfile(path) || continue
Expand All @@ -569,7 +573,7 @@ function render(doc::Documents.Document, settings::HTML=HTML())
if isfile(joinpath(doc.user.source, "assets", "search.js"))
@warn "not creating 'search.js', provided by the user."
else
r = JSDependencies.RequireJS([JS.jquery, JS.lunr, JS.lodash])
r = JSDependencies.RequireJS([RD.jquery, RD.lunr, RD.lodash])
push!(r, JSDependencies.parse_snippet(joinpath(ASSETS, "search.js")))
JSDependencies.verify(r; verbose=true) || error("RequireJS declaration is invalid")
JSDependencies.writejs(joinpath(doc.user.build, "assets", "search.js"), r)
Expand Down Expand Up @@ -734,9 +738,9 @@ function render_head(ctx, navnode)

page_title = "$(mdflatten(pagetitle(ctx, navnode))) · $(ctx.doc.user.sitename)"
css_links = [
google_fonts,
fontawesome_css...,
katex_css,
RD.google_fonts,
RD.fontawesome_css...,
RD.katex_css,
]
head(
meta[:charset=>"UTF-8"],
Expand All @@ -754,7 +758,7 @@ function render_head(ctx, navnode)

script("documenterBaseURL=\"$(relhref(src, "."))\""),
script[
:src => requirejs_cdn,
:src => RD.requirejs_cdn,
Symbol("data-main") => relhref(src, ctx.documenter_js)
],

Expand Down

2 comments on commit 0aa0520

@fredrikekre
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/5728

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.24.0 -m "<description of version>" 0aa0520e67d0cba2e1664a5cb88dfe5e3d49f0ee
git push origin v0.24.0

Please sign in to comment.