Skip to content

Commit

Permalink
Remove function landing pages
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmach committed Jul 20, 2021
1 parent c308c99 commit 4c4d0d9
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 55 deletions.
2 changes: 1 addition & 1 deletion assets/js/handlebars/template-helpers/isLocal.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion assets/less/content/footer.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.footer {
margin: 6em auto 1em;
margin: 4em auto 1em;
text-align: center;
font-style: italic;
font-size: 14px;
Expand Down
19 changes: 0 additions & 19 deletions lib/ex_doc/formatter/html.ex
Original file line number Diff line number Diff line change
Expand Up @@ -479,32 +479,13 @@ 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)
File.write!("#{config.output}/#{filename}", content)
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 =
Expand Down
8 changes: 0 additions & 8 deletions lib/ex_doc/formatter/html/templates.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down Expand Up @@ -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],
Expand Down
14 changes: 0 additions & 14 deletions lib/ex_doc/formatter/html/templates/module_entry_template.eex

This file was deleted.

12 changes: 0 additions & 12 deletions test/ex_doc/formatter/html_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,6 @@ defmodule ExDoc.Formatter.HTMLTest do
assert content =~ ~r{<meta http-equiv="refresh" content="0; url=api-reference.html">}
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 <code>example</code>"

content = File.read!("#{output_dir()}/CustomBehaviourOne-callback-greet.html")
assert content =~ "You're seeing just the callback <code>greet</code>"

assert Path.wildcard("#{output_dir()}/CompiledWithDocs-*slashes.html") == []
end

test "generates all listing files" do
generate_docs(doc_config())

Expand Down

0 comments on commit 4c4d0d9

Please sign in to comment.