Skip to content

Commit 7e273b8

Browse files
committed
Generate ePUB format
1 parent 379f38e commit 7e273b8

File tree

3 files changed

+32
-27
lines changed

3 files changed

+32
-27
lines changed

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ SHARE_PREFIX ?= $(PREFIX)/share
44
MAN_PREFIX ?= $(SHARE_PREFIX)/man
55
#CANONICAL := MAJOR.MINOR/
66
CANONICAL ?= main/
7-
DOCS_FORMAT ?= html
87
ELIXIRC := bin/elixirc --ignore-module-conflict $(ELIXIRC_OPTS)
98
ERLC := erlc -I lib/elixir/include
109
ERL_MAKE := if [ -n "$(ERLC_OPTS)" ]; then ERL_COMPILER_OPTIONS=$(ERLC_OPTS) erl -make; else erl -make; fi
@@ -181,7 +180,7 @@ clean_residual_files:
181180

182181
LOGO_PATH = $(shell test -f ../docs/logo.png && echo "--logo ../docs/logo.png")
183182
SOURCE_REF = $(shell tag="$(call GIT_TAG)" revision="$(call GIT_REVISION)"; echo "$${tag:-$$revision}")
184-
DOCS_COMPILE = CANONICAL=$(CANONICAL) bin/elixir ../ex_doc/bin/ex_doc "$(1)" "$(VERSION)" "lib/$(2)/ebin" --main "$(3)" --source-url "https://github.com/elixir-lang/elixir" --source-ref "$(call SOURCE_REF)" $(call LOGO_PATH) --output doc/$(2) --canonical "https://hexdocs.pm/$(2)/$(CANONICAL)" --homepage-url "https://elixir-lang.org/docs.html" --formatter "$(DOCS_FORMAT)" $(4)
183+
DOCS_COMPILE = CANONICAL=$(CANONICAL) bin/elixir ../ex_doc/bin/ex_doc "$(1)" "$(VERSION)" "lib/$(2)/ebin" --main "$(3)" --source-url "https://github.com/elixir-lang/elixir" --source-ref "$(call SOURCE_REF)" $(call LOGO_PATH) --output doc/$(2) --canonical "https://hexdocs.pm/$(2)/$(CANONICAL)" --homepage-url "https://elixir-lang.org/docs.html" $(4)
185184
DOCS_CONFIG = bin/elixir lib/elixir/scripts/docs_config.exs "$(1)"
186185

187186
docs: compile ../ex_doc/bin/ex_doc docs_elixir docs_eex docs_mix docs_iex docs_ex_unit docs_logger

lib/elixir/scripts/elixir_docs.exs

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ canonical = System.fetch_env!("CANONICAL")
7878
skip_undefined_reference_warnings_on: [
7979
"lib/elixir/pages/references/compatibility-and-deprecations.md"
8080
],
81+
formatters: ["html", "epub"],
8182
groups_for_modules: [
8283
# [Kernel, Kernel.SpecialForms],
8384

@@ -178,30 +179,34 @@ canonical = System.fetch_env!("CANONICAL")
178179
# Supervisor.Spec
179180
# ]
180181
],
181-
before_closing_body_tag: fn _ ->
182-
"""
183-
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js"></script>
184-
<script>
185-
document.addEventListener("DOMContentLoaded", function () {
186-
mermaid.initialize({
187-
startOnLoad: false,
188-
theme: document.body.className.includes("dark") ? "dark" : "default"
189-
});
190-
let id = 0;
191-
for (const codeEl of document.querySelectorAll("pre code.mermaid")) {
192-
const preEl = codeEl.parentElement;
193-
const graphDefinition = codeEl.textContent;
194-
const graphEl = document.createElement("div");
195-
const graphId = "mermaid-graph-" + id++;
196-
mermaid.render(graphId, graphDefinition).then(({svg, bindFunctions}) => {
197-
graphEl.innerHTML = svg;
198-
bindFunctions?.(graphEl);
199-
preEl.insertAdjacentElement("afterend", graphEl);
200-
preEl.remove();
182+
before_closing_body_tag: fn
183+
:html ->
184+
"""
185+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js"></script>
186+
<script>
187+
document.addEventListener("DOMContentLoaded", function () {
188+
mermaid.initialize({
189+
startOnLoad: false,
190+
theme: document.body.className.includes("dark") ? "dark" : "default"
201191
});
202-
}
203-
});
204-
</script>
205-
"""
192+
let id = 0;
193+
for (const codeEl of document.querySelectorAll("pre code.mermaid")) {
194+
const preEl = codeEl.parentElement;
195+
const graphDefinition = codeEl.textContent;
196+
const graphEl = document.createElement("div");
197+
const graphId = "mermaid-graph-" + id++;
198+
mermaid.render(graphId, graphDefinition).then(({svg, bindFunctions}) => {
199+
graphEl.innerHTML = svg;
200+
bindFunctions?.(graphEl);
201+
preEl.insertAdjacentElement("afterend", graphEl);
202+
preEl.remove();
203+
});
204+
}
205+
});
206+
</script>
207+
"""
208+
209+
_ ->
210+
""
206211
end
207212
]

lib/elixir/scripts/mix_docs.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ canonical = System.fetch_env!("CANONICAL")
99
iex: "https://hexdocs.pm/iex/#{canonical}",
1010
logger: "https://hexdocs.pm/logger/#{canonical}",
1111
mix: "https://hexdocs.pm/mix/#{canonical}"
12-
]
12+
],
13+
formatters: ["html", "epub"]
1314
]

0 commit comments

Comments
 (0)