diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
commit | 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch) | |
tree | 3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /src/librustdoc/html/templates | |
parent | Releasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/librustdoc/html/templates')
-rw-r--r-- | src/librustdoc/html/templates/STYLE.md | 39 | ||||
-rw-r--r-- | src/librustdoc/html/templates/item_info.html | 7 | ||||
-rw-r--r-- | src/librustdoc/html/templates/item_union.html | 23 | ||||
-rw-r--r-- | src/librustdoc/html/templates/page.html | 297 | ||||
-rw-r--r-- | src/librustdoc/html/templates/print_item.html | 52 | ||||
-rw-r--r-- | src/librustdoc/html/templates/short_item_info.html | 23 | ||||
-rw-r--r-- | src/librustdoc/html/templates/sidebar.html | 37 | ||||
-rw-r--r-- | src/librustdoc/html/templates/source.html | 21 |
8 files changed, 307 insertions, 192 deletions
diff --git a/src/librustdoc/html/templates/STYLE.md b/src/librustdoc/html/templates/STYLE.md index fff65e3b5..0281b1c47 100644 --- a/src/librustdoc/html/templates/STYLE.md +++ b/src/librustdoc/html/templates/STYLE.md @@ -1,37 +1,38 @@ # 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). +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/ +[jinjadoc]: https://jinja.palletsprojects.com/en/3.1.x/templates/ +[djangodoc]: https://docs.djangoproject.com/en/4.1/topics/templates/ +[askamadoc]: https://docs.rs/askama/latest/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] features. By default, whitespace characters are removed +around jinja tags (`{% %}` for example). At the end of most lines, we put an +empty comment tag: `{# #}`. 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 +liberally. We indent by four spaces after opening an HTML tag _or_ a Jinja 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 +Askama 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 +we avoid [assignments in the template logic][assignments] and [Askama +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 +[assignments]: https://djc.github.io/askama/template_syntax.html#assignments +[macros]: https://djc.github.io/askama/template_syntax.html#macros diff --git a/src/librustdoc/html/templates/item_info.html b/src/librustdoc/html/templates/item_info.html new file mode 100644 index 000000000..d2ea9bdae --- /dev/null +++ b/src/librustdoc/html/templates/item_info.html @@ -0,0 +1,7 @@ +{% if !items.is_empty() %} + <span class="item-info"> {# #} + {% for item in items %} + {{item|safe}} {# #} + {% endfor %} + </span> +{% endif %} diff --git a/src/librustdoc/html/templates/item_union.html b/src/librustdoc/html/templates/item_union.html new file mode 100644 index 000000000..a01457971 --- /dev/null +++ b/src/librustdoc/html/templates/item_union.html @@ -0,0 +1,23 @@ +<pre class="rust item-decl"><code> + {{ self.render_attributes_in_pre() | safe }} + {{ self.render_union() | safe }} +</code></pre> +{{ self.document() | safe }} +{% if self.fields_iter().peek().is_some() %} + <h2 id="fields" class="fields small-section-header"> + Fields<a href="#fields" class="anchor">§</a> + </h2> + {% for (field, ty) in self.fields_iter() %} + {% let name = field.name.expect("union field name") %} + <span id="structfield.{{ name }}" class="{{ ItemType::StructField }} small-section-header"> + <a href="#structfield.{{ name }}" class="anchor field">§</a> + <code>{{ name }}: {{ self.print_ty(ty) | safe }}</code> + </span> + {% if let Some(stability_class) = self.stability_field(field) %} + <span class="stab {{ stability_class }}"></span> + {% endif %} + {{ self.document_field(field) | safe }} + {% endfor %} +{% endif %} +{{ self.render_assoc_items() | safe }} +{{ self.document_type_layout() | safe }} diff --git a/src/librustdoc/html/templates/page.html b/src/librustdoc/html/templates/page.html index 7690d8f25..9133f899a 100644 --- a/src/librustdoc/html/templates/page.html +++ b/src/librustdoc/html/templates/page.html @@ -1,148 +1,151 @@ -<!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}}"> {#- -#} - <title>{{page.title}}</title> {#- -#} - <link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.source_serif_4_regular}}"> {#- -#} - <link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.fira_sans_regular}}"> {#- -#} - <link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.fira_sans_medium}}"> {#- -#} - <link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.source_code_pro_regular}}"> {#- -#} - <link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.source_serif_4_bold}}"> {#- -#} - <link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.source_code_pro_semibold}}"> {#- -#} - <link rel="stylesheet" {# -#} - href="{{static_root_path|safe}}{{files.normalize_css}}"> {#- -#} - <link rel="stylesheet" {# -#} - href="{{static_root_path|safe}}{{files.rustdoc_css}}" {# -#} - id="mainThemeStyle"> {#- -#} - <link rel="stylesheet" id="themeStyle" href="{{static_root_path|safe}}{{files.theme_light_css}}"> {#- -#} - <link rel="stylesheet" disabled href="{{static_root_path|safe}}{{files.theme_dark_css}}"> {#- -#} - <link rel="stylesheet" disabled href="{{static_root_path|safe}}{{files.theme_ayu_css}}"> {#- -#} - {%- for theme in themes -%} - <link rel="stylesheet" disabled href="{{page.root_path|safe}}{{theme}}{{page.resource_suffix}}.css"> {#- -#} - {%- endfor -%} - {%- if !layout.default_settings.is_empty() -%} - <script id="default-settings" {# -#} - {% for (k, v) in layout.default_settings %} +<!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}}"> {# #} + <title>{{page.title}}</title> {# #} + <link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.source_serif_4_regular}}"> {# #} + <link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.fira_sans_regular}}"> {# #} + <link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.fira_sans_medium}}"> {# #} + <link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.source_code_pro_regular}}"> {# #} + <link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.source_serif_4_bold}}"> {# #} + <link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.source_code_pro_semibold}}"> {# #} + <link rel="stylesheet" {#+ #} + href="{{static_root_path|safe}}{{files.normalize_css}}"> {# #} + <link rel="stylesheet" {#+ #} + href="{{static_root_path|safe}}{{files.rustdoc_css}}" {#+ #} + id="mainThemeStyle"> {# #} + {% if !layout.default_settings.is_empty() %} + <script id="default-settings" {#+ #} + {%~ for (k, v) in layout.default_settings ~%} data-{{k}}="{{v}}" - {%- endfor -%} - ></script> {#- -#} - {%- endif -%} - <script src="{{static_root_path|safe}}{{files.storage_js}}"></script> {#- -#} - {%- if page.css_class.contains("crate") -%} - <script defer src="{{page.root_path|safe}}crates{{page.resource_suffix}}.js"></script> {#- -#} - {%- else if page.css_class == "source" -%} - <script defer src="{{static_root_path|safe}}{{files.source_script_js}}"></script> {#- -#} - <script defer src="{{page.root_path|safe}}source-files{{page.resource_suffix}}.js"></script> {#- -#} - {%- else if !page.css_class.contains("mod") -%} - <script defer src="sidebar-items{{page.resource_suffix}}.js"></script> {#- -#} - {%- endif -%} - <script defer src="{{static_root_path|safe}}{{files.main_js}}"></script> {#- -#} - {%- if layout.scrape_examples_extension -%} - <script defer src="{{static_root_path|safe}}{{files.scrape_examples_js}}"></script> {#- -#} - {%- endif -%} - <noscript> {#- -#} - <link rel="stylesheet" {# -#} - href="{{static_root_path|safe}}{{files.noscript_css}}"> {#- -#} - </noscript> {#- -#} - {%- if layout.css_file_extension.is_some() -%} - <link rel="stylesheet" {# -#} - href="{{static_root_path|safe}}theme{{page.resource_suffix}}.css"> {#- -#} - {%- endif -%} - {%- if !layout.favicon.is_empty() -%} - <link rel="icon" href="{{layout.favicon}}"> {#- -#} - {%- else -%} - <link rel="alternate icon" type="image/png" {# -#} - href="{{static_root_path|safe}}{{files.rust_favicon_png_16}}"> {#- -#} - <link rel="alternate icon" type="image/png" {# -#} - href="{{static_root_path|safe}}{{files.rust_favicon_png_32}}"> {#- -#} - <link rel="icon" type="image/svg+xml" {# -#} - href="{{static_root_path|safe}}{{files.rust_favicon_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 -}} - {%- if page.css_class != "source" -%} - <nav class="mobile-topbar"> {#- -#} - <button class="sidebar-menu-toggle">☰</button> {#- -#} - <a class="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}}{{files.rust_logo_svg}}" alt="logo"> {#- -#} - {%- endif -%} - </a> {#- -#} - <h2></h2> {#- -#} - </nav> {#- -#} - {%- endif -%} - <nav class="sidebar"> {#- -#} - {%- if page.css_class != "source" -%} - <a class="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}}{{files.rust_logo_svg}}" alt="logo"> {#- -#} - {%- endif -%} - </a> {#- -#} - {%- endif -%} - {{- sidebar|safe -}} - </nav> {#- -#} - <main> {#- -#} - {%- if page.css_class != "source" -%}<div class="width-limiter">{%- endif -%} - <nav class="sub"> {#- -#} - {%- if page.css_class == "source" -%} - <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}}{{files.rust_logo_svg}}" alt="logo"> {#- -#} - {%- endif -%} - </a> {#- -#} - {%- endif -%} - <form class="search-form"> {#- -#} - <span></span> {#- This empty span is a hacky fix for Safari - See #93184 -#} - <input {# -#} - class="search-input" {# -#} - name="search" {# -#} - aria-label="Run search in the documentation" {# -#} - autocomplete="off" {# -#} - spellcheck="false" {# -#} - placeholder="Click or press ‘S’ to search, ‘?’ for more options…" {# -#} - type="search"> {#- -#} - <div id="help-button" title="help" tabindex="-1"> {#- -#} - <a href="{{page.root_path|safe}}help.html">?</a> {#- -#} - </div> {#- -#} - <div id="settings-menu" tabindex="-1"> {#- -#} - <a href="{{page.root_path|safe}}settings.html" title="settings"> {#- -#} - <img width="22" height="22" alt="Change settings" {# -#} - src="{{static_root_path|safe}}{{files.wheel_svg}}"> {#- -#} - </a> {#- -#} - </div> {#- -#} - </form> {#- -#} - </nav> {#- -#} - <section id="main-content" class="content">{{- content|safe -}}</section> {#- -#} - {%- if page.css_class != "source" -%}</div>{%- endif -%} - </main> {#- -#} - {{- layout.external_html.after_content|safe -}} - <div id="rustdoc-vars" {# -#} - data-root-path="{{page.root_path|safe}}" {# -#} - data-static-root-path="{{static_root_path|safe}}" {# -#} - data-current-crate="{{layout.krate}}" {# -#} - data-themes="{{themes|join(",") }}" {# -#} - data-resource-suffix="{{page.resource_suffix}}" {# -#} - data-rustdoc-version="{{rustdoc_version}}" {# -#} - data-search-js="{{files.search_js}}" {# -#} - data-settings-js="{{files.settings_js}}" {# -#} - data-settings-css="{{files.settings_css}}" {# -#} - > {#- -#} - </div> {#- -#} -</body> {#- -#} -</html> {#- -#} + {% endfor %} + ></script> {# #} + {% endif %} + <div id="rustdoc-vars" {#+ #} + data-root-path="{{page.root_path|safe}}" {#+ #} + data-static-root-path="{{static_root_path|safe}}" {#+ #} + data-current-crate="{{layout.krate}}" {#+ #} + data-themes="{{themes|join(",") }}" {#+ #} + data-resource-suffix="{{page.resource_suffix}}" {#+ #} + data-rustdoc-version="{{rustdoc_version}}" {#+ #} + data-search-js="{{files.search_js}}" {#+ #} + data-settings-js="{{files.settings_js}}" {#+ #} + data-settings-css="{{files.settings_css}}" {#+ #} + data-theme-light-css="{{files.theme_light_css}}" {#+ #} + data-theme-dark-css="{{files.theme_dark_css}}" {#+ #} + data-theme-ayu-css="{{files.theme_ayu_css}}" {#+ #} + > {# #} + </div> {# #} + <script src="{{static_root_path|safe}}{{files.storage_js}}"></script> {# #} + {% if page.css_class.contains("crate") %} + <script defer src="{{page.root_path|safe}}crates{{page.resource_suffix}}.js"></script> {# #} + {% else if page.css_class == "source" %} + <script defer src="{{static_root_path|safe}}{{files.source_script_js}}"></script> {# #} + <script defer src="{{page.root_path|safe}}source-files{{page.resource_suffix}}.js"></script> {# #} + {% else if !page.css_class.contains("mod") %} + <script defer src="sidebar-items{{page.resource_suffix}}.js"></script> {# #} + {% endif %} + <script defer src="{{static_root_path|safe}}{{files.main_js}}"></script> {# #} + {% if layout.scrape_examples_extension %} + <script defer src="{{static_root_path|safe}}{{files.scrape_examples_js}}"></script> {# #} + {% endif %} + <noscript> {# #} + <link rel="stylesheet" {#+ #} + media="(prefers-color-scheme:light)" {#+ #} + href="{{static_root_path|safe}}{{files.theme_light_css}}"> {# #} + <link rel="stylesheet" {#+ #} + media="(prefers-color-scheme:dark)" {#+ #} + href="{{static_root_path|safe}}{{files.theme_dark_css}}"> {# #} + <link rel="stylesheet" {#+ #} + href="{{static_root_path|safe}}{{files.noscript_css}}"> {# #} + </noscript> {# #} + {% if layout.css_file_extension.is_some() %} + <link rel="stylesheet" {#+ #} + href="{{page.root_path|safe}}theme{{page.resource_suffix}}.css"> {# #} + {% endif %} + {% if !layout.favicon.is_empty() %} + <link rel="icon" href="{{layout.favicon}}"> {# #} + {% else %} + <link rel="alternate icon" type="image/png" {#+ #} + href="{{static_root_path|safe}}{{files.rust_favicon_png_16}}"> {# #} + <link rel="alternate icon" type="image/png" {#+ #} + href="{{static_root_path|safe}}{{files.rust_favicon_png_32}}"> {# #} + <link rel="icon" type="image/svg+xml" {#+ #} + href="{{static_root_path|safe}}{{files.rust_favicon_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 }} + {% if page.css_class != "source" %} + <nav class="mobile-topbar"> {# #} + <button class="sidebar-menu-toggle">☰</button> {# #} + <a class="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}}{{files.rust_logo_svg}}" alt="logo"> {# #} + {% endif %} + </a> {# #} + <h2></h2> {# #} + </nav> {# #} + {% endif %} + <nav class="sidebar"> {# #} + {% if page.css_class != "source" %} + <a class="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}}{{files.rust_logo_svg}}" alt="logo"> {# #} + {% endif %} + </a> {# #} + {% endif %} + {{ sidebar|safe }} + </nav> {# #} + <main> {# #} + {% if page.css_class != "source" %}<div class="width-limiter">{% endif %} + <nav class="sub"> {# #} + {% if page.css_class == "source" %} + <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}}{{files.rust_logo_svg}}" alt="logo"> {# #} + {% endif %} + </a> {# #} + {% endif %} + <form class="search-form"> {# #} + <span></span> {# This empty span is a hacky fix for Safari - See #93184 #} + <input {#+ #} + class="search-input" {#+ #} + name="search" {#+ #} + aria-label="Run search in the documentation" {#+ #} + autocomplete="off" {#+ #} + spellcheck="false" {#+ #} + placeholder="Click or press ‘S’ to search, ‘?’ for more options…" {#+ #} + type="search"> {# #} + <div id="help-button" title="help" tabindex="-1"> {# #} + <a href="{{page.root_path|safe}}help.html">?</a> {# #} + </div> {# #} + <div id="settings-menu" tabindex="-1"> {# #} + <a href="{{page.root_path|safe}}settings.html" title="settings"> {# #} + <img width="22" height="22" alt="Change settings" {#+ #} + src="{{static_root_path|safe}}{{files.wheel_svg}}"> {# #} + </a> {# #} + </div> {# #} + </form> {# #} + </nav> {# #} + <section id="main-content" class="content">{{ content|safe }}</section> {# #} + {% if page.css_class != "source" %}</div>{% endif %} + </main> {# #} + {{ layout.external_html.after_content|safe }} +</body> {# #} +</html> {# #} diff --git a/src/librustdoc/html/templates/print_item.html b/src/librustdoc/html/templates/print_item.html index 3a1867b7f..edabac9a0 100644 --- a/src/librustdoc/html/templates/print_item.html +++ b/src/librustdoc/html/templates/print_item.html @@ -1,28 +1,28 @@ -<div class="main-heading"> {#- -#} - <h1> {#- -#} - {{-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" title="Copy item path to clipboard"> {#- -#} - <img src="{{static_root_path|safe}}{{clipboard_svg}}" {# -#} - width="19" height="18" {# -#} - alt="Copy item path"> {#- -#} - </button> {#- -#} - </h1> {#- -#} - <span class="out-of-band"> {#- -#} +<div class="main-heading"> {# #} + <h1> {# #} + {{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" title="Copy item path to clipboard"> {# #} + <img src="{{static_root_path|safe}}{{clipboard_svg}}" {#+ #} + width="19" height="18" {#+ #} + alt="Copy item path"> {# #} + </button> {# #} + </h1> {# #} + <span class="out-of-band"> {# #} {% if !stability_since_raw.is_empty() %} - {{- stability_since_raw|safe }} · {# -#} + {{ stability_since_raw|safe +}} · {#+ #} {% endif %} - {%- match src_href -%} - {%- when Some with (href) -%} - <a class="srclink" href="{{href|safe}}">source</a> · {# -#} - {%- else -%} - {%- endmatch -%} - <button id="toggle-all-docs" title="collapse all docs"> {#- -#} - [<span>−</span>] {#- -#} - </button> {#- -#} - </span> {#- -#} -</div> {#- -#} + {% match src_href %} + {% when Some with (href) %} + <a class="srclink" href="{{href|safe}}">source</a> · {#+ #} + {% else %} + {% endmatch %} + <button id="toggle-all-docs" title="collapse all docs"> {# #} + [<span>−</span>] {# #} + </button> {# #} + </span> {# #} +</div> {# #} diff --git a/src/librustdoc/html/templates/short_item_info.html b/src/librustdoc/html/templates/short_item_info.html new file mode 100644 index 000000000..75d155e91 --- /dev/null +++ b/src/librustdoc/html/templates/short_item_info.html @@ -0,0 +1,23 @@ +{% match self %} + {% when Self::Deprecation with { message } %} + <div class="stab deprecated"> {# #} + <span class="emoji">👎</span> {# #} + <span>{{message|safe}}</span> {# #} + </div> {# #} + {% when Self::Unstable with { feature, tracking } %} + <div class="stab unstable"> {# #} + <span class="emoji">🔬</span> {# #} + <span> {# #} + This is a nightly-only experimental API. ({# #} + <code>{{feature}}</code> {# #} + {% match tracking %} + {% when Some with ((url, num)) %} + <a href="{{url}}{{num}}">#{{num}}</a> {# #} + {% when None %} + {% endmatch %} + ) {# #} + </span> {# #} + </div> {# #} + {% when Self::Portability with { message } %} + <div class="stab portability">{{message|safe}}</div> {# #} +{% endmatch %} diff --git a/src/librustdoc/html/templates/sidebar.html b/src/librustdoc/html/templates/sidebar.html new file mode 100644 index 000000000..01d476ad2 --- /dev/null +++ b/src/librustdoc/html/templates/sidebar.html @@ -0,0 +1,37 @@ +{% if !title.is_empty() %} + <h2 class="location"> {# #} + <a href="#">{{title_prefix}}{{title}}</a> {# #} + </h2> +{% endif %} +<div class="sidebar-elems"> + {% if is_crate %} + <ul class="block"> + {% if !version.is_empty() %} + <li class="version">Version {{+ version}}</li> + {% endif %} + <li><a id="all-types" href="all.html">All Items</a></li> {# #} + </ul> + {% endif %} + + {% if self.should_render_blocks() %} + <section> + {% for block in blocks %} + {% if block.should_render() %} + {% if !block.heading.name.is_empty() %} + <h3><a href="#{{block.heading.href|safe}}">{{block.heading.name}}</a></h3> + {% endif %} + {% if !block.links.is_empty() %} + <ul class="block"> + {% for link in block.links %} + <li><a href="#{{link.href|safe}}">{{link.name}}</a></li> + {% endfor %} + </ul> + {% endif %} + {% endif %} + {% endfor %} + </section> + {% endif %} + {% if !path.is_empty() %} + <h2><a href="index.html">In {{+ path}}</a></h2> + {% endif %} +</div> diff --git a/src/librustdoc/html/templates/source.html b/src/librustdoc/html/templates/source.html new file mode 100644 index 000000000..42d01277d --- /dev/null +++ b/src/librustdoc/html/templates/source.html @@ -0,0 +1,21 @@ +<div class="example-wrap"> {# #} + {# https://developers.google.com/search/docs/crawling-indexing/robots-meta-tag#data-nosnippet-attr + Do not show "1 2 3 4 5 ..." in web search results. #} + <div data-nosnippet><pre class="src-line-numbers"> + {% for line in lines.clone() %} + {% if embedded %} + <span>{{line|safe}}</span> + {%~ else %} + <a href="#{{line|safe}}" id="{{line|safe}}">{{line|safe}}</a> + {%~ endif %} + {% endfor %} + </pre></div> {# #} + <pre class="rust"> {# #} + <code> + {% if needs_expansion %} + <button class="expand">↕</button> + {% endif %} + {{code_html|safe}} + </code> {# #} + </pre> {# #} +</div> |