Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assets/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
sourceType: 'module'
},
rules: {
'no-new': 0,
'no-path-concat': 0,
'no-throw-literal': 0,
'no-useless-escape': 0,
Expand Down
23 changes: 23 additions & 0 deletions assets/js/entry/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import { initialize as initSettings } from '../settings'
import { initialize as initStyling } from '../styling'
import { initialize as initPreview} from '../preview'

import Swup from 'swup'
import SwupA11yPlugin from '@swup/a11y-plugin'

onDocumentReady(() => {
const params = new URLSearchParams(window.location.search)
const isPreview = params.has('preview')
Expand All @@ -37,6 +40,26 @@ onDocumentReady(() => {
if (isPreview) {
initPreview()
} else {
if (window.location.protocol !== 'file:') {
new Swup({
animationSelector: false,
containers: ['#main'],
ignoreVisit: (url) => {
const path = url.split('#')[0]
return path === window.location.pathname ||
path === window.location.pathname + '.html'
},
hooks: {
'page:view': () => {
initSidebarContent()
initSearchPage()
}
},
linkSelector: 'a[href]:not([href^="/"]):not([href^="http"])',
plugins: [new SwupA11yPlugin()]
})
}

initVersions()
initSidebarDrawer()
initSidebarContent()
Expand Down
2 changes: 1 addition & 1 deletion assets/js/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function escapeHtmlEntities (text) {
* @returns {String}
*/
export function getCurrentPageSidebarType () {
return document.body.dataset.type
return document.getElementById('main').dataset.type
}

/**
Expand Down
12 changes: 5 additions & 7 deletions assets/js/search-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import { qs, escapeHtmlEntities, isBlank, getQueryParamByName, getProjectNameAnd
import { setSearchInputValue } from './search-bar'

const EXCERPT_RADIUS = 80

const SEARCH_CONTAINER_SELECTOR = '#search'

lunr.tokenizer.separator = /\s+/
lunr.QueryLexer.termSeparator = /\s+/
lunr.Pipeline.registerFunction(docTokenFunction, 'docTokenSplitter')
lunr.Pipeline.registerFunction(docTrimmerFunction, 'docTrimmer')

/**
* Performs a full-text search within the documentation
* for the query in URL params and renders the result.
Expand Down Expand Up @@ -49,12 +53,6 @@ function renderResults ({ value, results, errorMessage }) {
}

async function getIndex () {
// lunr by default splits on - but we don't want that.
lunr.tokenizer.separator = /\s+/
lunr.QueryLexer.termSeparator = /\s+/
lunr.Pipeline.registerFunction(docTokenFunction, 'docTokenSplitter')
lunr.Pipeline.registerFunction(docTrimmerFunction, 'docTrimmer')

const cachedIndex = await loadIndex()
if (cachedIndex) { return cachedIndex }

Expand Down
134 changes: 134 additions & 0 deletions assets/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"type": "git",
"url": "git+https://github.com/elixir-lang/ex_doc.git"
},
"author": "Plataformatec",
"author": "The Elixir Team",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/elixir-lang/ex_doc/issues"
Expand All @@ -29,6 +29,7 @@
"devDependencies": {
"@fontsource/inconsolata": "^4.5.9",
"@fontsource/lato": "^4.5.10",
"@swup/a11y-plugin": "^5.0.0",
"esbuild": "^0.16.16",
"eslint": "^8.31.0",
"eslint-config-standard": "^17.0.0",
Expand All @@ -46,6 +47,7 @@
"lodash.throttle": "^4.1.1",
"lunr": "^2.3.8",
"mocha": "^10.2.0",
"normalize.css": "^8.0.1"
"normalize.css": "^8.0.1",
"swup": "^4.8.1"
}
}
56 changes: 0 additions & 56 deletions formatters/html/dist/html-FUIEFJA2.js

This file was deleted.

56 changes: 56 additions & 0 deletions formatters/html/dist/html-ZOXW4WH5.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/ex_doc/formatter/epub/templates.ex
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ defmodule ExDoc.Formatter.EPUB.Templates do
:defp,
:head_template,
Path.expand("templates/head_template.eex", __DIR__),
[:config, :page],
[:config, :title],
trim: true
)

Expand Down
2 changes: 1 addition & 1 deletion lib/ex_doc/formatter/epub/templates/extra_template.eex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= head_template(config, %{title: title}) %>
<%= head_template(config, title) %>
<h1 id="content">
<%=h title_content %>
</h1>
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_doc/formatter/epub/templates/head_template.eex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<meta charset="utf-8" />
<title><%= page.title %> - <%= config.project %> v<%= config.version %></title>
<title><%= title %> - <%= config.project %> v<%= config.version %></title>
<meta name="generator" content="ExDoc v<%= ExDoc.version() %>" />
<link type="text/css" rel="stylesheet"
href="<%= H.asset_rev "#{config.output}/OEBPS", "dist/epub-#{config.proglang}-*.css" %>" />
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_doc/formatter/epub/templates/module_template.eex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= head_template(config, %{title: module.title}) %>
<%= head_template(config, module.title) %>
<h1 id="content">
<%= module.title %> <%= H.module_type(module) %>
</h1>
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_doc/formatter/epub/templates/nav_template.eex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= head_template(config, %{title: "Table Of Contents"}) %>
<%= head_template(config, "Table Of Contents") %>
<h1>Table of contents</h1>
<nav epub:type="toc">
<ol>
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_doc/formatter/epub/templates/title_template.eex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= head_template(config, %{title: "Cover"}) %>
<%= head_template(config, "Cover") %>
<div class="title-container">
<%= if cover = config.cover do %>
<div><img src="assets/cover<%= Path.extname(cover) %>"/></div>
Expand Down
4 changes: 2 additions & 2 deletions lib/ex_doc/formatter/html/templates.ex
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,14 @@ defmodule ExDoc.Formatter.HTML.Templates do
templates = [
detail_template: [:node, :module],
footer_template: [:config, :node],
head_template: [:config, :page],
head_template: [:config, :title, :noindex],
module_template: [:config, :module, :summary, :nodes_map],
not_found_template: [:config, :nodes_map],
api_reference_entry_template: [:module_node],
api_reference_template: [:nodes_map],
extra_template: [:config, :node, :type, :nodes_map, :refs],
search_template: [:config, :nodes_map],
sidebar_template: [:config, :nodes_map],
sidebar_template: [:config, :type, :nodes_map],
summary_template: [:name, :nodes],
redirect_template: [:config, :redirect_to]
]
Expand Down
4 changes: 2 additions & 2 deletions lib/ex_doc/formatter/html/templates/extra_template.eex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= head_template(config, %{title: node.title, type: type, noindex: false}) %>
<%= sidebar_template(config, nodes_map) %>
<%= head_template(config, node.title, false) %>
<%= sidebar_template(config, type, nodes_map) %>

<div id="top-content">
<h1>
Expand Down
Loading