Skip to content

Commit 94134e0

Browse files
committed
Add the option to trim down the footer
1 parent 08482c0 commit 94134e0

File tree

5 files changed

+55
-38
lines changed

5 files changed

+55
-38
lines changed

lib/ex_doc/cli.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ defmodule ExDoc.CLI do
2323
canonical: :string,
2424
config: :string,
2525
favicon: :string,
26+
footer: :boolean,
2627
formatter: [:keep, :string],
2728
homepage_url: :string,
2829
language: :string,
@@ -200,6 +201,7 @@ defmodule ExDoc.CLI do
200201
--favicon Path to a favicon image for the project. Must be PNG, JPEG or SVG. The image
201202
will be placed in the output "assets" directory.
202203
-f, --formatter Docs formatter to use (html or epub), default: html and epub
204+
--no-footer Do not render the footer (except for the required "Built with ExDoc" note)
203205
--homepage-url URL to link to for the site name
204206
--language Identify the primary language of the documents, its value must be
205207
a valid [BCP 47](https://tools.ietf.org/html/bcp47) language tag, default: "en"

lib/ex_doc/config.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ defmodule ExDoc.Config do
2929
extras: [],
3030
favicon: nil,
3131
filter_modules: &__MODULE__.filter_modules/2,
32+
footer: true,
3233
formatter: "html",
3334
formatters: [],
3435
group_for_doc: &__MODULE__.default_group_for_doc/1,

lib/ex_doc/formatter/html/templates/footer_template.eex

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,47 @@
11
<footer class="footer">
2-
<p>
3-
<%= if config.package do %>
4-
<span class="line">
5-
<a href="https://hex.pm/packages/<%= config.package %>/<%= config.version %>" class="footer-hex-package">Hex Package</a>
2+
<%= if config.footer do %>
3+
<p>
4+
<%= if config.package do %>
5+
<span class="line">
6+
<a href="https://hex.pm/packages/<%= config.package %>/<%= config.version %>" class="footer-hex-package">Hex Package</a>
7+
8+
<a href="https://preview.hex.pm/preview/<%= config.package %>/<%= config.version %>">Hex Preview</a>
9+
10+
<%= if source_path do %>
11+
(<a href="https://preview.hex.pm/preview/<%= config.package %>/<%= config.version %>/show/<%= source_path %>">current file</a>)
12+
<% end %>
13+
</span>
14+
<% end %>
615

7-
<a href="https://preview.hex.pm/preview/<%= config.package %>/<%= config.version %>">Hex Preview</a>
16+
<span class="line">
17+
<button class="a-main footer-button display-quick-switch" title="Go to package docs">
18+
Go to package docs
19+
</button>
820

9-
<%= if source_path do %>
10-
(<a href="https://preview.hex.pm/preview/<%= config.package %>/<%= config.version %>/show/<%= source_path %>">current file</a>)
21+
<%= if "epub" in config.formatters do %>
22+
<a href="<%= config.project %>.epub" title="ePub version">
23+
Download ePub version
24+
</a>
1125
<% end %>
1226
</span>
13-
<% end %>
14-
15-
<span class="line">
16-
<button class="a-main footer-button display-quick-switch" title="Go to package docs">
17-
Go to package docs
18-
</button>
27+
</p>
1928

20-
<%= if "epub" in config.formatters do %>
21-
<a href="<%= config.project %>.epub" title="ePub version">
22-
Download ePub version
23-
</a>
29+
<p class="built-using">
30+
Built using
31+
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" target="_blank" rel="help noopener" translate="no">ExDoc</a> (v<%= ExDoc.version() %>) for the
32+
<%= if config.proglang == :erlang do %>
33+
<a href="https://erlang.org" title="Erlang" target="_blank" translate="no">Erlang programming language</a>
34+
<% else %>
35+
<a href="https://elixir-lang.org" title="Elixir" target="_blank" translate="no">Elixir programming language</a>
2436
<% end %>
25-
</span>
26-
</p>
37+
</p>
38+
<% else %>
39+
<p class="built-using">
40+
Built using
41+
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" target="_blank" rel="help noopener" translate="no">ExDoc</a> (v<%= ExDoc.version() %>)
42+
</p>
43+
<% end %>
2744

28-
<p class="built-using">
29-
Built using
30-
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" target="_blank" rel="help noopener" translate="no">ExDoc</a> (v<%= ExDoc.version() %>) for the
31-
<%= if config.proglang == :erlang do %>
32-
<a href="https://erlang.org" title="Erlang" target="_blank" translate="no">Erlang programming language</a>
33-
<% else %>
34-
<a href="https://elixir-lang.org" title="Elixir" target="_blank" translate="no">Elixir programming language</a>
35-
<% end %>
36-
</p>
3745
<%= before_closing_footer_tag(config, :html) %>
3846
</footer>
3947
</div>

lib/mix/tasks/docs.ex

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,17 @@ defmodule Mix.Tasks.Docs do
132132
133133
* `:formatters` - Formatter to use; default: ["html", "epub"], options: "html", "epub".
134134
135+
* `:footer` - When false, does not render the footer on all pages, except for
136+
the required "Built with ExDoc" note.
137+
135138
* `:groups_for_extras`, `:groups_for_modules`, `:groups_for_docs`, and `:default_group_for_doc` -
136-
See the "Groups" section
139+
See the "Groups" section.
137140
138141
* `:ignore_apps` - Apps to be ignored when generating documentation in an umbrella project.
139142
Receives a list of atoms. Example: `[:first_app, :second_app]`.
140143
141144
* `:language` - Identify the primary language of the documents, its value must be
142-
a valid [BCP 47](https://tools.ietf.org/html/bcp47) language tag; default: "en"
145+
a valid [BCP 47](https://tools.ietf.org/html/bcp47) language tag. Default: "en".
143146
144147
* `:logo` - Path to a logo image file for the project. Must be PNG, JPEG or SVG. When
145148
specified, the image file will be placed in the output "assets" directory, named
@@ -148,23 +151,23 @@ defmodule Mix.Tasks.Docs do
148151
predictable sizing and cropping.
149152
150153
* `:main` - Main page of the documentation. It may be a module or a
151-
generated page, like "Plug" or "api-reference"; default: "api-reference".
154+
generated page, like "Plug" or "api-reference". Default: "api-reference".
152155
153156
* `:markdown_processor` - The markdown processor to use,
154-
either `module()` or `{module(), keyword()}` to provide configuration options;
157+
either `module()` or `{module(), keyword()}` to provide configuration options.
155158
156-
* `:meta` - A keyword list or a map to specify meta tag attributes
159+
* `:meta` - A keyword list or a map to specify meta tag attributes.
157160
158-
* `:nest_modules_by_prefix` - See the "Nesting" section
161+
* `:nest_modules_by_prefix` - See the "Nesting" section.
159162
160-
* `:output` - Output directory for the generated docs; default: "doc".
163+
* `:output` - Output directory for the generated docs. Default: "doc".
161164
May be overridden by command line argument.
162165
163166
* `:redirects` - A map or list of tuples, where the key is the path to redirect from and the
164167
value is the path to redirect to. The extension is omitted in both cases, i.e `%{"old-readme" => "readme"}`.
165168
See the "Changing documentation over time" section below for more.
166169
167-
* `:search` - A list of search engine configurations. See the "Search engines" section
170+
* `:search` - A list of search engine configurations. See the "Search engines" section.
168171
169172
* `:skip_undefined_reference_warnings_on` - ExDoc warns when it can't create a `Mod.fun/arity`
170173
reference in the current project docs (for example, because of a typo). This option controls when to
@@ -190,8 +193,8 @@ defmodule Mix.Tasks.Docs do
190193
* `:source_url` - The source URL fallback if `:source_url` is not given at the project
191194
configuration. See the following sections.
192195
193-
* `:source_ref` - The branch/commit/tag used for source link inference;
194-
default: "main".
196+
* `:source_ref` - The branch/commit/tag used for source link inference.
197+
Default: "main".
195198
196199
* `:source_url_pattern` - Public URL of the project for source links. This is derived
197200
automatically from the project's `:source_url` and `:source_ref` when using one of

test/ex_doc/formatter/html/templates_test.exs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
157157

158158
assert Templates.footer_template(doc_config(context, proglang: :elixir), nil) ==
159159
Templates.footer_template(doc_config(context), nil)
160+
161+
refute Templates.footer_template(doc_config(context, footer: false), nil) =~
162+
"Elixir programming language"
160163
end
161164

162165
test "includes api reference", context do

0 commit comments

Comments
 (0)