From 4c4d0d95e9b8e10e8df26833826c142f2552e7e5 Mon Sep 17 00:00:00 2001 From: Wojtek Mach Date: Tue, 20 Jul 2021 16:32:30 +0200 Subject: [PATCH] Remove function landing pages --- .../js/handlebars/template-helpers/isLocal.js | 2 +- assets/less/content/footer.less | 2 +- lib/ex_doc/formatter/html.ex | 19 ------------------- lib/ex_doc/formatter/html/templates.ex | 8 -------- .../html/templates/module_entry_template.eex | 14 -------------- test/ex_doc/formatter/html_test.exs | 12 ------------ 6 files changed, 2 insertions(+), 55 deletions(-) delete mode 100644 lib/ex_doc/formatter/html/templates/module_entry_template.eex diff --git a/assets/js/handlebars/template-helpers/isLocal.js b/assets/js/handlebars/template-helpers/isLocal.js index 233081120..105e042f1 100644 --- a/assets/js/handlebars/template-helpers/isLocal.js +++ b/assets/js/handlebars/template-helpers/isLocal.js @@ -1,5 +1,5 @@ export default function (nodeId, options) { - const pathSuffix = window.location.pathname.split('/').pop().replace(/-.*/, '.html') + const pathSuffix = window.location.pathname.split('/').pop() const nodePage = nodeId + '.html' if (nodePage === pathSuffix) { diff --git a/assets/less/content/footer.less b/assets/less/content/footer.less index 2f6f5aad1..9957cc861 100644 --- a/assets/less/content/footer.less +++ b/assets/less/content/footer.less @@ -1,5 +1,5 @@ .footer { - margin: 6em auto 1em; + margin: 4em auto 1em; text-align: center; font-style: italic; font-size: 14px; diff --git a/lib/ex_doc/formatter/html.ex b/lib/ex_doc/formatter/html.ex index fb049e04d..a22ec8f71 100644 --- a/lib/ex_doc/formatter/html.ex +++ b/lib/ex_doc/formatter/html.ex @@ -479,7 +479,6 @@ defmodule ExDoc.Formatter.HTML do end defp generate_module_page(module_node, nodes_map, config) do - generate_module_entry_pages(module_node, nodes_map, config) filename = "#{module_node.id}.html" config = set_canonical_url(config, filename) content = Templates.module_page(module_node, nodes_map, config) @@ -487,24 +486,6 @@ defmodule ExDoc.Formatter.HTML do filename end - defp generate_module_entry_pages(module_node, nodes_map, config) do - module_node.docs - |> Enum.group_by(&{&1.type, &1.name}) - |> Enum.each(fn {{type, name}, nodes} -> - name = - name - |> Atom.to_string() - |> String.replace("?", "-question-mark") - |> String.replace("!", "-exclamation-mark") - - if name =~ ~r/^[a-z0-9_-]+$/i do - content = Templates.module_entry_page(module_node, type, name, nodes, nodes_map, config) - filename = "#{module_node.id}-#{type}-#{name}.html" - File.write!("#{config.output}/#{filename}", content) - end - end) - end - defp set_canonical_url(config, filename) do if config.canonical do canonical_url = diff --git a/lib/ex_doc/formatter/html/templates.ex b/lib/ex_doc/formatter/html/templates.ex index dd08cfc05..f5b493438 100644 --- a/lib/ex_doc/formatter/html/templates.ex +++ b/lib/ex_doc/formatter/html/templates.ex @@ -15,13 +15,6 @@ defmodule ExDoc.Formatter.HTML.Templates do module_template(config, module_node, summary, nodes_map) end - @doc """ - Generate content from the module entry template for a given `node` - """ - def module_entry_page(module_node, type, name, nodes, nodes_map, config) do - module_entry_template(config, module_node, type, name, nodes, nodes_map) - end - @doc """ Get the full specs from a function, already in HTML form. """ @@ -274,7 +267,6 @@ defmodule ExDoc.Formatter.HTML.Templates do footer_template: [:config], head_template: [:config, :page], module_template: [:config, :module, :summary, :nodes_map], - module_entry_template: [:config, :module, :type, :name, :nodes, :nodes_map], not_found_template: [:config, :nodes_map], api_reference_entry_template: [:module_node], api_reference_template: [:config, :nodes_map], diff --git a/lib/ex_doc/formatter/html/templates/module_entry_template.eex b/lib/ex_doc/formatter/html/templates/module_entry_template.eex deleted file mode 100644 index b26a489c0..000000000 --- a/lib/ex_doc/formatter/html/templates/module_entry_template.eex +++ /dev/null @@ -1,14 +0,0 @@ -<%= head_template(config, %{title: module.id <> ".#{name}", type: module.type}) %> -<%= sidebar_template(config, nodes_map) %> - -

<%= module.title <> ".#{name}" %>

- -
- You're seeing just the <%= type %> <%= name %>, go back to <%= module.title %> module for more information. -
- -<%= for node <- nodes do %> - <%= detail_template(node, module) %> -<% end %> - -<%= footer_template(config) %> diff --git a/test/ex_doc/formatter/html_test.exs b/test/ex_doc/formatter/html_test.exs index 447e20a94..1351f8835 100644 --- a/test/ex_doc/formatter/html_test.exs +++ b/test/ex_doc/formatter/html_test.exs @@ -189,18 +189,6 @@ defmodule ExDoc.Formatter.HTMLTest do assert content =~ ~r{} end - test "generates module entry pages" do - generate_docs(doc_config()) - - content = File.read!("#{output_dir()}/CompiledWithDocs-function-example.html") - assert content =~ "You're seeing just the function example" - - content = File.read!("#{output_dir()}/CustomBehaviourOne-callback-greet.html") - assert content =~ "You're seeing just the callback greet" - - assert Path.wildcard("#{output_dir()}/CompiledWithDocs-*slashes.html") == [] - end - test "generates all listing files" do generate_docs(doc_config())