Skip to content

Commit

Permalink
Revert "Accessibility: Restructure headings (#1265)"
Browse files Browse the repository at this point in the history
This reverts commit 8232103.
  • Loading branch information
josevalim committed Sep 13, 2020
1 parent 8d64cd7 commit 6bfc916
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 135 deletions.
34 changes: 13 additions & 21 deletions assets/less/content/general.less
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,38 @@ h6 {
font-weight: 700;
line-height: 1.5em;
word-wrap: break-word;
margin: 1em 0 .5em;
}

h1 {
font-size: 2em;
margin: 1em 0 .5em;

&.signature {
margin: 0;
}

&.section-heading {
margin: 1.5em 0 .5em;
}

& small {
font-weight: 300;
}

a.view-source {
font-size: 1.2rem;
}
}

h2 {
font-size: 1.6em;
margin: 1em 0 .5em;
font-weight: 700;
}

h3 {
font-size: 1.375em;
margin: 1em 0 .5em;
font-weight: 700;
}

Expand All @@ -42,7 +52,6 @@ a.no-underline {
}

a.view-source {
display: inline-block;
float: right;
color: #727272;
text-decoration: none;
Expand All @@ -58,7 +67,7 @@ a.view-source {
.note {
color: #727272;
margin-right: 5px;
font-size: 0.875em;
font-size: 14px;
font-weight: normal;
}

Expand Down Expand Up @@ -105,8 +114,6 @@ td, th {
}

.section-heading {
margin-bottom: inherit;

&:hover a.hover-link {
opacity: 1;
text-decoration: none;
Expand All @@ -124,24 +131,9 @@ td, th {
font-size: 16px;
vertical-align: middle;
}

h1, h2, h3,
h4, h5, h6 {
display: inline-block;
}

h1 {
display: inline-block;

~ a.view-source {
font-size: 1.2rem;
margin-top: 3rem;
}
}
}


.detail .section-heading h2 {
.detail h2.section-heading {
margin-left: 0.3em;
}

Expand Down
16 changes: 5 additions & 11 deletions assets/test/tooltips/hints-extraction.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,21 @@ import $ from 'jquery'
describe('hints extraction', () => {
describe('extractModuleHint', () => {
var modulePageObject = $($.parseHTML(`
<div id="content" class="content-inner">
<div class="section-headeing">
<h1>
Some module <small class="app-vsn">(ExDoc v0.0.1)</small>
</h1>
<div>
<h1>
Some module <small class="app-vsn">(ExDoc v0.0.1)</small>
<a href="https://github.com/" title="View Source" class="view-source" rel="help">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
</h1>
<section id="moduledoc">
<p>
Module <strong>description</strong> here
</p>
</section>
<section id="summary" class="details-list">
List of functions with summaries
</section>
<section id="summary">List of functions with summaries</section>
</div>
`))

Expand Down
14 changes: 6 additions & 8 deletions lib/ex_doc/formatter/epub/templates/module_template.eex
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,26 @@

<%= if Enum.any?(summary, fn {_, v} -> v != [] end) do %>
<section id="summary" class="details-list">
<div class="section-heading">
<h1 class="section-heading">
<a class="hover-link" href="#summary">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Anchor for this section</span>
</a>

<h1>Summary</h1>
</div>
Summary
</h1>
<%= for {name, nodes} <- summary, do: H.summary_template(name, nodes) %>
</section>
<% end %>

<%= for {name, nodes} <- summary, nodes != [], key = HTML.text_to_id(name) do %>
<section id="<%= key %>" class="details-list">
<div class="section-heading">
<h1 class="section-heading">
<a class="hover-link" href="#<%= key %>">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Anchor for this section</span>
</a>

<h1><%= name %></h1>
</div>
<%= name %>
</h1>
<div class="<%= key %>-list">
<%= for node <- nodes, do: H.detail_template(node, module) %>
</div>
Expand Down
8 changes: 3 additions & 5 deletions lib/ex_doc/formatter/html/templates.ex
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,10 @@ defmodule ExDoc.Formatter.HTML.Templates do

defp link_heading(_match, tag, title, id, prefix) do
"""
<div class="section-heading">
<#{tag} id="#{prefix}#{id}" class="section-heading">
<a href="##{prefix}#{id}" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
<#{tag} id="#{prefix}#{id}">
#{title}
</#{tag}>
</div>
#{title}
</#{tag}>
"""
end

Expand Down
16 changes: 5 additions & 11 deletions lib/ex_doc/formatter/html/templates/api_reference_template.eex
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<div class="section-heading">
<h1>
API Reference <small class="app-vsn"><%= config.project %> v<%= config.version %></small>
</h1>
</div>
<h1>
API Reference <small class="app-vsn"><%= config.project %> v<%= config.version %></small>
</h1>

<%= if nodes_map.modules != [] do %>
<section class="details-list">
<div class="section-heading">
<h2 id="modules">Modules</h2>
</div>
<h2 id="modules" class="section-heading">Modules</h2>
<div class="summary">
<%= for module_node <- Enum.sort_by(nodes_map.modules, & &1.id) do
api_reference_entry_template(module_node)
Expand All @@ -19,9 +15,7 @@

<%= if nodes_map.tasks != [] do %>
<section class="details-list">
<div class="section-heading">
<h2 id="tasks">Mix Tasks</h2>
</div>
<h2 id="tasks" class="section-heading">Mix Tasks</h2>
<div class="summary">
<%= for task_node <- nodes_map.tasks do
api_reference_entry_template(task_node)
Expand Down
28 changes: 10 additions & 18 deletions lib/ex_doc/formatter/html/templates/module_template.eex
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
<%= head_template(config, %{title: module.title, type: module.type}) %>
<%= sidebar_template(config, nodes_map) %>

<div class="section-heading">
<h1>
<%= module_title(module) %> <small class="app-vsn">(<%= config.project %> v<%= config.version %>)</small>
</h1>
<h1>
<%= module_title(module) %> <small class="app-vsn">(<%= config.project %> v<%= config.version %>)</small>
<%= if module.source_url do %>
<a href="<%= module.source_url %>" title="View Source" class="view-source" rel="help">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
<% end %>
</div>
</h1>

<%= if deprecated = module.deprecated do %>
<div class="deprecated">
Expand All @@ -27,32 +25,26 @@

<%= if Enum.any?(summary, fn {_, v} -> v != [] end) do %>
<section id="summary" class="details-list">
<div class="section-heading">
<h1 class="section-heading">
<a class="hover-link" href="#summary">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this section</span>
</a>
<h1>
Summary
</h1>
<%= for {name, nodes} <- summary, do: summary_template(name, nodes) %>
</div>
Summary
</h1>
<%= for {name, nodes} <- summary, do: summary_template(name, nodes) %>
</section>
<% end %>

<%= for {name, nodes} <- summary, nodes != [], key = HTML.text_to_id(name) do %>
<section id="<%= key %>" class="details-list">
<div class="section-heading">
<h1 class="section-heading">
<a class="hover-link" href="#<%= key %>">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this section</span>
</a>

<h1>
<%= name %>
</h1>
</div>

<%= name %>
</h1>
<div class="<%= key %>-list">
<%= for node <- nodes, do: detail_template(node, module) %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_doc/formatter/html/templates/search_template.eex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%= head_template(config, %{title: "Search", type: :search}) %>
<%= sidebar_template(config, nodes_map) %>
<div id="search" class="section-heading">
<div id="search">
<h1>Search</h1>
<div class="loading"><div></div><div></div><div></div><div></div></div>
</div>
Expand Down

0 comments on commit 6bfc916

Please sign in to comment.