Skip to content

rustdoc: Tweak the main template and CSS for semantic mark-up. #28297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/librustdoc/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ r##"<!DOCTYPE html>

{before_content}

<section class="sidebar">
<nav class="sidebar">
{logo}
{sidebar}
</section>
</nav>

<nav class="sub">
<form class="search-form js-only">
Expand All @@ -83,10 +83,12 @@ r##"<!DOCTYPE html>

<section class="footer"></section>

<div id="help" class="hidden">
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>

<div class="shortcuts">
<h1>Keyboard Shortcuts</h1>
<h2>Keyboard Shortcuts</h2>

<dl>
<dt>?</dt>
Expand All @@ -103,7 +105,7 @@ r##"<!DOCTYPE html>
</div>

<div class="infos">
<h1>Search Tricks</h1>
<h2>Search Tricks</h2>

<p>
Prefix searches with a type followed by a colon (e.g.
Expand All @@ -123,7 +125,7 @@ r##"<!DOCTYPE html>
</p>
</div>
</div>
</div>
</aside>

{after_content}

Expand Down
14 changes: 10 additions & 4 deletions src/librustdoc/html/static/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ h3.impl, h3.method, h4.method, h3.type, h4.type {
h3.impl, h3.method, h3.type {
margin-top: 15px;
}
h1, h2, h3, h4, section.sidebar, a.source, .search-input, .content table :not(code)>a, .collapse-toggle {
h1, h2, h3, h4, .sidebar, a.source, .search-input, .content table :not(code)>a, .collapse-toggle {
font-family: "Fira Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

Expand Down Expand Up @@ -189,11 +189,16 @@ nav.sub {
padding: 0 10px;
margin-bottom: 14px;
}
.block h2 {
.block h2, .block h3 {
margin-top: 0;
margin-bottom: 8px;
text-align: center;
}
.block ul, .block li {
margin: 0;
padding: 0;
list-style: none;
}

.block a {
display: block;
Expand Down Expand Up @@ -381,7 +386,7 @@ nav.main .separator {
nav.sum { text-align: right; }
nav.sub form { display: inline; }

nav, .content {
nav.sub, .content {
margin-left: 230px;
}

Expand All @@ -407,6 +412,7 @@ a {
.content span.method, .content a.method, .block a.current.method { color: #8c6067; }
.content span.tymethod, .content a.tymethod, .block a.current.tymethod { color: #8c6067; }
.content .fnname { color: #8c6067; }
.block a.current.crate { font-weight: 500; }

.search-input {
width: 100%;
Expand Down Expand Up @@ -489,7 +495,7 @@ body.blur > :not(#help) {
}
#help dd { margin: 5px 33px; }
#help .infos { padding-left: 0; }
#help h1 { margin-top: 0; }
#help h1, #help h2 { margin-top: 0; }
#help > div div {
width: 50%;
float: left;
Expand Down
16 changes: 10 additions & 6 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,8 @@
if (rootPath === '../') {
var sidebar = $('.sidebar');
var div = $('<div>').attr('class', 'block crate');
div.append($('<h2>').text('Crates'));
div.append($('<h3>').text('Crates'));
var ul = $('<ul>').appendTo(div);

var crates = [];
for (var crate in rawSearchIndex) {
Expand All @@ -788,9 +789,10 @@
}
if (rawSearchIndex[crates[i]].items[0]) {
var desc = rawSearchIndex[crates[i]].items[0][3];
div.append($('<a>', {'href': '../' + crates[i] + '/index.html',
var link = $('<a>', {'href': '../' + crates[i] + '/index.html',
'title': plainSummaryLine(desc),
'class': klass}).text(crates[i]));
'class': klass}).text(crates[i]);
ul.append($('<li>').append(link));
}
}
sidebar.append(div);
Expand All @@ -809,7 +811,8 @@
if (!filtered) { return; }

var div = $('<div>').attr('class', 'block ' + shortty);
div.append($('<h2>').text(longty));
div.append($('<h3>').text(longty));
var ul = $('<ul>').appendTo(div);

for (var i = 0; i < filtered.length; ++i) {
var item = filtered[i];
Expand All @@ -826,9 +829,10 @@
} else {
path = shortty + '.' + name + '.html';
}
div.append($('<a>', {'href': current.relpath + path,
var link = $('<a>', {'href': current.relpath + path,
'title': desc,
'class': klass}).text(name));
'class': klass}).text(name);
ul.append($('<li>').append(link));
}
sidebar.append(div);
}
Expand Down