Skip to content

Commit 04450b8

Browse files
committed
WIP: Frameless docs + New Menu
This is a Work in Process, there are a lot of things to fix at this point: - [ ] Fix tests - [x] Review the changes made to the CSS styles - [x] Review the breadcrumbs - [x] Fix the possible conflict after #212 gets merged - [x] Fix the index.html to avoid the frameset. - [x] Improve the section below the `#sidebar` section in `module_template` - [x] Generate valid JSON for `sidebar_items.js` - [x] Improve CSS integration - [x] Remove frames - [x] Add an initial media query for `print` media - [x] Improve the JS style code and documentation - [x] Add meta tags `x-ua-compatible`, `viewport` and `generator` - [x] Delete `target` parameter from a element - [x] Add normalize.css - [x] Merge old full_list.css with style.css - [x] Add sidebar template - [x] Merge full_list.js into app.js - [x] Update jQuery v2.1.4 This effort will try to fix the issue #175
1 parent 64b65e3 commit 04450b8

19 files changed

+1235
-586
lines changed

lib/ex_doc/formatter/html.ex

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ defmodule ExDoc.Formatter.HTML do
1414
File.rm_rf! output
1515
:ok = File.mkdir_p output
1616

17-
generate_index(output, config)
1817
generate_assets(output, config)
1918
has_readme = config.readme && generate_readme(output, modules, config)
2019

@@ -23,22 +22,28 @@ defmodule ExDoc.Formatter.HTML do
2322
exceptions = filter_list(:exceptions, all)
2423
protocols = filter_list(:protocols, all)
2524

26-
generate_overview(modules, exceptions, protocols, output, config)
27-
generate_list(:modules, modules, all, output, config, has_readme)
28-
generate_list(:exceptions, exceptions, all, output, config, has_readme)
29-
generate_list(:protocols, protocols, all, output, config, has_readme)
25+
generate_overview(modules, exceptions, protocols, output, config, has_readme)
26+
generate_sidebar_items(modules, exceptions, protocols, output)
27+
generate_list(modules, all, output, config, has_readme)
28+
generate_list(exceptions, all, output, config, has_readme)
29+
generate_list(protocols, all, output, config, has_readme)
3030

3131
Path.join(config.output, "index.html")
3232
end
3333

34-
defp generate_index(output, config) do
35-
content = Templates.index_template(config)
36-
:ok = File.write("#{output}/index.html", content)
34+
defp generate_overview(modules, exceptions, protocols, output, config, has_readme) do
35+
content = Templates.overview_template(config, modules, exceptions, protocols, has_readme)
36+
37+
if has_readme do
38+
:ok = File.write("#{output}/overview.html", content)
39+
else
40+
:ok = File.write("#{output}/index.html", content)
41+
end
3742
end
3843

39-
defp generate_overview(modules, exceptions, protocols, output, config) do
40-
content = Templates.overview_template(config, modules, exceptions, protocols)
41-
:ok = File.write("#{output}/overview.html", content)
44+
defp generate_sidebar_items(modules, exceptions, protocols, output) do
45+
content = Templates.sidebar_items_template(modules, exceptions, protocols)
46+
:ok = File.write("#{output}/sidebar_items.js", content)
4247
end
4348

4449
defp assets do
@@ -66,7 +71,7 @@ defmodule ExDoc.Formatter.HTML do
6671
defp write_readme(output, {:ok, content}, modules, config) do
6772
content = Autolink.project_doc(content, modules)
6873
readme_html = Templates.readme_template(config, content) |> pretty_codeblocks
69-
File.write("#{output}/README.html", readme_html)
74+
File.write("#{output}/index.html", readme_html)
7075
true
7176
end
7277

@@ -110,14 +115,12 @@ defmodule ExDoc.Formatter.HTML do
110115
Enum.filter nodes, &match?(%ExDoc.ModuleNode{type: x} when x in [:protocol], &1)
111116
end
112117

113-
defp generate_list(scope, nodes, all, output, config, has_readme) do
114-
Enum.each nodes, &generate_module_page(&1, all, output, config)
115-
content = Templates.list_page(scope, nodes, config, has_readme)
116-
File.write("#{output}/#{scope}_list.html", content)
118+
defp generate_list(nodes, all, output, config, has_readme) do
119+
Enum.each nodes, &generate_module_page(&1, all, output, config, has_readme)
117120
end
118121

119-
defp generate_module_page(node, modules, output, config) do
120-
content = Templates.module_page(node, config, modules)
122+
defp generate_module_page(node, modules, output, config, has_readme) do
123+
content = Templates.module_page(node, config, modules, has_readme)
121124
File.write("#{output}/#{node.id}.html", content)
122125
end
123126

lib/ex_doc/formatter/html/templates.ex

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,12 @@ defmodule ExDoc.Formatter.HTML.Templates do
88
@doc """
99
Generate content from the module template for a given `node`
1010
"""
11-
def module_page(node, config, all) do
11+
def module_page(node, config, all, has_readme) do
1212
types = node.typespecs
1313
functions = Enum.filter node.docs, &match?(%ExDoc.FunctionNode{type: :def}, &1)
1414
macros = Enum.filter node.docs, &match?(%ExDoc.FunctionNode{type: :defmacro}, &1)
1515
callbacks = Enum.filter node.docs, &match?(%ExDoc.FunctionNode{type: :defcallback}, &1)
16-
module_template(config, node, types, functions, macros, callbacks, all)
17-
end
18-
19-
@doc """
20-
Generates the listing.
21-
"""
22-
def list_page(scope, nodes, config, has_readme) do
23-
list_template(scope, nodes, config, has_readme)
16+
module_template(config, node, types, functions, macros, callbacks, all, has_readme)
2417
end
2518

2619
# Get the full specs from a function, already in HTML form.
@@ -109,12 +102,13 @@ defmodule ExDoc.Formatter.HTML.Templates do
109102
end
110103

111104
templates = [
112-
index_template: [:config],
113-
list_template: [:scope, :nodes, :config, :has_readme],
114-
overview_template: [:config, :modules, :exceptions, :protocols],
115-
module_template: [:config, :module, :types, :functions, :macros, :callbacks, :all],
105+
overview_template: [:config, :modules, :exceptions, :protocols, :has_readme],
106+
sidebar_template: [:config, :has_readme],
107+
sidebar_items_template: [:modules, :exceptions, :protocols],
108+
sidebar_items_keys_template: [:node],
109+
sidebar_items_entry_template: [:node],
110+
module_template: [:config, :module, :types, :functions, :macros, :callbacks, :all, :has_readme],
116111
readme_template: [:config, :content],
117-
list_item_template: [:node],
118112
overview_entry_template: [:node],
119113
summary_template: [:node],
120114
detail_template: [:node, :_module],

lib/ex_doc/formatter/html/templates/css/full_list.css

Lines changed: 0 additions & 215 deletions
This file was deleted.

0 commit comments

Comments
 (0)