Rollup merge of #93005 - GuillaumeGomez:templates-in-html, r=notriddle
Move back templates into html folder Follow-up of https://github.com/rust-lang/rust/pull/92526. r? `@notriddle`
This commit is contained in:
commit
623791df24
6 changed files with 5 additions and 1 deletions
37
src/librustdoc/html/templates/STYLE.md
Normal file
37
src/librustdoc/html/templates/STYLE.md
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# Style for Templates
|
||||
|
||||
This directory has templates in the [Tera templating language](teradoc), which is very
|
||||
similar to [Jinja2](jinjadoc) and [Django](djangodoc) templates, and also to [Askama](askamadoc).
|
||||
|
||||
[teradoc]: https://tera.netlify.app/docs/#templates
|
||||
[jinjadoc]: https://jinja.palletsprojects.com/en/3.0.x/templates/
|
||||
[djangodoc]: https://docs.djangoproject.com/en/3.2/topics/templates/
|
||||
[askamadoc]: https://docs.rs/askama/0.10.5/askama/
|
||||
|
||||
We want our rendered output to have as little unnecessary whitespace as
|
||||
possible, so that pages load quickly. To achieve that we use Tera's
|
||||
[whitespace control] features. At the end of most lines, we put an empty comment
|
||||
tag with the whitespace control characters: `{#- -#}`. This causes all
|
||||
whitespace between the end of the line and the beginning of the next, including
|
||||
indentation, to be omitted on render. Sometimes we want to preserve a single
|
||||
space. In those cases we put the space at the end of the line, followed by
|
||||
`{# -#}`, which is a directive to remove following whitespace but not preceding.
|
||||
We also use the whitespace control characters in most instances of tags with
|
||||
control flow, for example `{%- if foo -%}`.
|
||||
|
||||
[whitespace control]: https://tera.netlify.app/docs/#whitespace-control
|
||||
|
||||
We want our templates to be readable, so we use indentation and newlines
|
||||
liberally. We indent by four spaces after opening an HTML tag _or_ a Tera
|
||||
tag. In most cases an HTML tag should be followed by a newline, but if the
|
||||
tag has simple contents and fits with its close tag on a single line, the
|
||||
contents don't necessarily need a new line.
|
||||
|
||||
Tera templates support quite sophisticated control flow. To keep our templates
|
||||
simple and understandable, we use only a subset: `if` and `for`. In particular
|
||||
we avoid [assignments in the template logic](assignments) and [Tera
|
||||
macros](macros). This also may make things easier if we switch to a different
|
||||
Jinja-style template system, like Askama, in the future.
|
||||
|
||||
[assignments]: https://tera.netlify.app/docs/#assignments
|
||||
[macros]: https://tera.netlify.app/docs/#macros
|
||||
152
src/librustdoc/html/templates/page.html
Normal file
152
src/librustdoc/html/templates/page.html
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
<!DOCTYPE html> {#- -#}
|
||||
<html lang="en"> {#- -#}
|
||||
<head> {#- -#}
|
||||
<meta charset="utf-8"> {#- -#}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> {#- -#}
|
||||
<meta name="generator" content="rustdoc"> {#- -#}
|
||||
<meta name="description" content="{{page.description}}"> {#- -#}
|
||||
<meta name="keywords" content="{{page.keywords}}"> {#- -#}
|
||||
<title>{{page.title}}</title> {#- -#}
|
||||
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}SourceSerif4-Regular.ttf.woff2"> {#- -#}
|
||||
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}FiraSans-Regular.woff2"> {#- -#}
|
||||
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}FiraSans-Medium.woff2"> {#- -#}
|
||||
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}SourceCodePro-Regular.ttf.woff2"> {#- -#}
|
||||
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}SourceSerif4-Bold.ttf.woff2"> {#- -#}
|
||||
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}SourceCodePro-Semibold.ttf.woff2"> {#- -#}
|
||||
<link rel="stylesheet" type="text/css" {# -#}
|
||||
href="{{static_root_path|safe}}normalize{{page.resource_suffix}}.css"> {#- -#}
|
||||
<link rel="stylesheet" type="text/css" {# -#}
|
||||
href="{{static_root_path|safe}}rustdoc{{page.resource_suffix}}.css" {# -#}
|
||||
id="mainThemeStyle"> {#- -#}
|
||||
{%- for theme in themes -%}
|
||||
<link rel="stylesheet" type="text/css" {# -#}
|
||||
href="{{static_root_path|safe}}{{theme}}{{page.resource_suffix}}.css" {# -#}
|
||||
{%- if theme == "light" -%}
|
||||
id="themeStyle"
|
||||
{%- else -%}
|
||||
disabled
|
||||
{%- endif -%}
|
||||
>
|
||||
{%- endfor -%}
|
||||
<script id="default-settings" {# -#}
|
||||
{% for (k, v) in layout.default_settings %}
|
||||
data-{{k}}="{{v}}"
|
||||
{%- endfor -%}
|
||||
></script> {#- -#}
|
||||
<script src="{{static_root_path|safe}}storage{{page.resource_suffix}}.js"></script> {#- -#}
|
||||
<script src="{{page.root_path|safe}}crates{{page.resource_suffix}}.js"></script> {#- -#}
|
||||
<script defer src="{{static_root_path|safe}}main{{page.resource_suffix}}.js"></script> {#- -#}
|
||||
{%- for script in page.static_extra_scripts -%}
|
||||
<script defer src="{{static_root_path|safe}}{{script}}.js"></script> {#- -#}
|
||||
{% endfor %}
|
||||
{%- if layout.scrape_examples_extension -%}
|
||||
<script defer src="{{page.root_path|safe}}scrape-examples{{page.resource_suffix}}.js"></script> {#- -#}
|
||||
{%- endif -%}
|
||||
{%- for script in page.extra_scripts -%}
|
||||
<script defer src="{{page.root_path|safe}}{{script}}.js"></script> {#- -#}
|
||||
{% endfor %}
|
||||
<noscript> {#- -#}
|
||||
<link rel="stylesheet" {# -#}
|
||||
href="{{static_root_path|safe}}noscript{{page.resource_suffix}}.css"> {#- -#}
|
||||
</noscript> {#- -#}
|
||||
{%- if layout.css_file_extension.is_some() -%}
|
||||
<link rel="stylesheet" type="text/css" {# -#}
|
||||
href="{{static_root_path|safe}}theme{{page.resource_suffix}}.css"> {#- -#}
|
||||
{%- endif -%}
|
||||
{%- if !layout.favicon.is_empty() -%}
|
||||
<link rel="shortcut icon" href="{{layout.favicon}}"> {#- -#}
|
||||
{%- else -%}
|
||||
<link rel="alternate icon" type="image/png" {# -#}
|
||||
href="{{static_root_path|safe}}favicon-16x16{{page.resource_suffix}}.png"> {#- -#}
|
||||
<link rel="alternate icon" type="image/png" {# -#}
|
||||
href="{{static_root_path|safe}}favicon-32x32{{page.resource_suffix}}.png"> {#- -#}
|
||||
<link rel="icon" type="image/svg+xml" {# -#}
|
||||
href="{{static_root_path|safe}}favicon{{page.resource_suffix}}.svg"> {#- -#}
|
||||
{%- endif -%}
|
||||
{{- layout.external_html.in_header|safe -}}
|
||||
</head> {#- -#}
|
||||
<body class="rustdoc {{page.css_class}}"> {#- -#}
|
||||
<!--[if lte IE 11]> {#- -#}
|
||||
<div class="warning"> {#- -#}
|
||||
This old browser is unsupported and will most likely display funky things. {#- -#}
|
||||
</div> {#- -#}
|
||||
<![endif]--> {#- -#}
|
||||
{{- layout.external_html.before_content|safe -}}
|
||||
<nav class="mobile-topbar"> {#- -#}
|
||||
<button class="sidebar-menu-toggle">☰</button> {#- -#}
|
||||
<a class="sidebar-logo" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {#- -#}
|
||||
<div class="logo-container"> {#- -#}
|
||||
{%- if !layout.logo.is_empty() -%}
|
||||
<img src="{{layout.logo}}" alt="logo"> {#- -#}
|
||||
{%- else -%}
|
||||
<img class="rust-logo" src="{{static_root_path|safe}}rust-logo{{page.resource_suffix}}.svg" alt="logo"> {#- -#}
|
||||
{%- endif -%}
|
||||
</div>
|
||||
</a> {#- -#}
|
||||
<h2 class="location"></h2>
|
||||
</nav>
|
||||
<nav class="sidebar"> {#- -#}
|
||||
<a class="sidebar-logo" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {#- -#}
|
||||
<div class="logo-container"> {#- -#}
|
||||
{%- if !layout.logo.is_empty() %}
|
||||
<img src="{{layout.logo}}" alt="logo"> {#- -#}
|
||||
{%- else -%}
|
||||
<img class="rust-logo" src="{{static_root_path|safe}}rust-logo{{page.resource_suffix}}.svg" alt="logo"> {#- -#}
|
||||
{%- endif -%}
|
||||
</div>
|
||||
</a> {#- -#}
|
||||
{{- sidebar|safe -}}
|
||||
</nav> {#- -#}
|
||||
<main> {#- -#}
|
||||
<div class="width-limiter"> {#- -#}
|
||||
<div class="sub-container"> {#- -#}
|
||||
<a class="sub-logo-container" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {#- -#}
|
||||
{%- if !layout.logo.is_empty() %}
|
||||
<img src="{{layout.logo}}" alt="logo"> {#- -#}
|
||||
{%- else -%}
|
||||
<img class="rust-logo" src="{{static_root_path|safe}}rust-logo{{page.resource_suffix}}.svg" alt="logo"> {#- -#}
|
||||
{%- endif -%}
|
||||
</a> {#- -#}
|
||||
<nav class="sub"> {#- -#}
|
||||
<div class="theme-picker hidden"> {#- -#}
|
||||
<button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"> {#- -#}
|
||||
<img width="18" height="18" alt="Pick another theme!" {# -#}
|
||||
src="{{static_root_path|safe}}brush{{page.resource_suffix}}.svg"> {#- -#}
|
||||
</button> {#- -#}
|
||||
<div id="theme-choices" role="menu"></div> {#- -#}
|
||||
</div> {#- -#}
|
||||
<form class="search-form"> {#- -#}
|
||||
<div class="search-container"> {#- -#}
|
||||
<div>
|
||||
<input {# -#}
|
||||
class="search-input" {# -#}
|
||||
name="search" {# -#}
|
||||
autocomplete="off" {# -#}
|
||||
spellcheck="false" {# -#}
|
||||
placeholder="Click or press ‘S’ to search, ‘?’ for more options…" {# -#}
|
||||
type="search"> {#- -#}
|
||||
</div> {#- -#}
|
||||
<button type="button" id="help-button" title="help">?</button> {#- -#}
|
||||
<a id="settings-menu" href="{{page.root_path|safe}}settings.html" title="settings"> {#- -#}
|
||||
<img width="18" height="18" alt="Change settings" {# -#}
|
||||
src="{{static_root_path|safe}}wheel{{page.resource_suffix}}.svg"> {#- -#}
|
||||
</a> {#- -#}
|
||||
</div> {#- -#}
|
||||
</form> {#- -#}
|
||||
</nav> {#- -#}
|
||||
</div> {#- -#}
|
||||
<section id="main-content" class="content">{{- content|safe -}}</section> {#- -#}
|
||||
<section id="search" class="content hidden"></section> {#- -#}
|
||||
</div> {#- -#}
|
||||
</main> {#- -#}
|
||||
{{- layout.external_html.after_content|safe -}}
|
||||
<div id="rustdoc-vars" {# -#}
|
||||
data-root-path="{{page.root_path|safe}}" {# -#}
|
||||
data-current-crate="{{layout.krate}}" {# -#}
|
||||
data-themes="{{themes|join(",") }}" {# -#}
|
||||
data-resource-suffix="{{page.resource_suffix}}" {# -#}
|
||||
data-rustdoc-version="{{rustdoc_version}}" {# -#}
|
||||
> {#- -#}
|
||||
</div>
|
||||
</body> {#- -#}
|
||||
</html> {#- -#}
|
||||
30
src/librustdoc/html/templates/print_item.html
Normal file
30
src/librustdoc/html/templates/print_item.html
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<div class="main-heading">
|
||||
<h1 class="fqn"> {#- -#}
|
||||
<span class="in-band"> {#- -#}
|
||||
{{-typ-}}
|
||||
{#- The breadcrumbs of the item path, like std::string -#}
|
||||
{%- for component in path_components -%}
|
||||
<a href="{{component.path|safe}}index.html">{{component.name}}</a>::<wbr>
|
||||
{%- endfor -%}
|
||||
<a class="{{item_type}}" href="#">{{name}}</a> {#- -#}
|
||||
<button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"> {#- -#}
|
||||
<img src="{{static_root_path|safe}}clipboard{{page.resource_suffix}}.svg" {# -#}
|
||||
width="19" height="18" {# -#}
|
||||
alt="Copy item path"> {#- -#}
|
||||
</button> {#- -#}
|
||||
</span> {#- -#}
|
||||
</h1> {#- -#}
|
||||
<span class="out-of-band"> {#- -#}
|
||||
{% if !stability_since_raw.is_empty() %}
|
||||
{{- stability_since_raw|safe -}} · {# -#}
|
||||
{% endif %}
|
||||
{%- match src_href -%}
|
||||
{%- when Some with (href) -%}
|
||||
<a class="srclink" href="{{href|safe}}" title="goto source code">source</a> · {# -#}
|
||||
{%- else -%}
|
||||
{%- endmatch -%}
|
||||
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs"> {#- -#}
|
||||
[<span class="inner">−</span>] {#- -#}
|
||||
</a> {#- -#}
|
||||
</span> {#- -#}
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue