From 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:20:39 +0200 Subject: Merging upstream version 1.70.0+dfsg1. Signed-off-by: Daniel Baumann --- src/librustdoc/html/templates/STYLE.md | 39 +-- src/librustdoc/html/templates/item_info.html | 7 + src/librustdoc/html/templates/item_union.html | 23 ++ src/librustdoc/html/templates/page.html | 297 +++++++++++---------- src/librustdoc/html/templates/print_item.html | 52 ++-- src/librustdoc/html/templates/short_item_info.html | 23 ++ src/librustdoc/html/templates/sidebar.html | 37 +++ src/librustdoc/html/templates/source.html | 21 ++ 8 files changed, 307 insertions(+), 192 deletions(-) create mode 100644 src/librustdoc/html/templates/item_info.html create mode 100644 src/librustdoc/html/templates/item_union.html create mode 100644 src/librustdoc/html/templates/short_item_info.html create mode 100644 src/librustdoc/html/templates/sidebar.html create mode 100644 src/librustdoc/html/templates/source.html (limited to 'src/librustdoc/html/templates') 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() %} + {# #} + {% for item in items %} + {{item|safe}} {# #} + {% endfor %} + +{% 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 @@ +

+    {{ self.render_attributes_in_pre() | safe }}
+    {{ self.render_union() | safe }}
+
+{{ self.document() | safe }} +{% if self.fields_iter().peek().is_some() %} +

+ Fields§ +

+ {% for (field, ty) in self.fields_iter() %} + {% let name = field.name.expect("union field name") %} + + § + {{ name }}: {{ self.print_ty(ty) | safe }} + + {% if let Some(stability_class) = self.stability_field(field) %} + + {% 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 @@ - {#- -#} - {#- -#} - {#- -#} - {#- -#} - {#- -#} - {#- -#} - {#- -#} - {{page.title}} {#- -#} - {#- -#} - {#- -#} - {#- -#} - {#- -#} - {#- -#} - {#- -#} - {#- -#} - {#- -#} - {#- -#} - {#- -#} - {#- -#} - {%- for theme in themes -%} - {#- -#} - {%- endfor -%} - {%- if !layout.default_settings.is_empty() -%} - {#- -#} - {%- endif -%} - {#- -#} - {%- if page.css_class.contains("crate") -%} - {#- -#} - {%- else if page.css_class == "source" -%} - {#- -#} - {#- -#} - {%- else if !page.css_class.contains("mod") -%} - {#- -#} - {%- endif -%} - {#- -#} - {%- if layout.scrape_examples_extension -%} - {#- -#} - {%- endif -%} - {#- -#} - {%- if layout.css_file_extension.is_some() -%} - {#- -#} - {%- endif -%} - {%- if !layout.favicon.is_empty() -%} - {#- -#} - {%- else -%} - {#- -#} - {#- -#} - {#- -#} - {%- endif -%} - {{- layout.external_html.in_header|safe -}} - {#- -#} - {#- -#} - {#- -#} - {{- layout.external_html.before_content|safe -}} - {%- if page.css_class != "source" -%} - {#- -#} - {%- endif -%} - {#- -#} -
{#- -#} - {%- if page.css_class != "source" -%}
{%- endif -%} - {#- -#} -
{{- content|safe -}}
{#- -#} - {%- if page.css_class != "source" -%}
{%- endif -%} -
{#- -#} - {{- layout.external_html.after_content|safe -}} -
{#- -#} -
{#- -#} - {#- -#} - {#- -#} + {% endfor %} + > {# #} + {% endif %} +
{# #} +
{# #} + {# #} + {% if page.css_class.contains("crate") %} + {# #} + {% else if page.css_class == "source" %} + {# #} + {# #} + {% else if !page.css_class.contains("mod") %} + {# #} + {% endif %} + {# #} + {% if layout.scrape_examples_extension %} + {# #} + {% endif %} + {# #} + {% if layout.css_file_extension.is_some() %} + {# #} + {% endif %} + {% if !layout.favicon.is_empty() %} + {# #} + {% else %} + {# #} + {# #} + {# #} + {% endif %} + {{ layout.external_html.in_header|safe }} + {# #} + {# #} + {# #} + {{ layout.external_html.before_content|safe }} + {% if page.css_class != "source" %} + {# #} + {% endif %} + {# #} +
{# #} + {% if page.css_class != "source" %}
{% endif %} + {# #} +
{{ content|safe }}
{# #} + {% if page.css_class != "source" %}
{% endif %} +
{# #} + {{ layout.external_html.after_content|safe }} + {# #} + {# #} 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 @@ -
{#- -#} -

{#- -#} - {{-typ-}} - {#- The breadcrumbs of the item path, like std::string -#} - {%- for component in path_components -%} - {{component.name}}:: - {%- endfor -%} - {{name}} {#- -#} - {#- -#} -

{#- -#} - {#- -#} +
{# #} +

{# #} + {{typ}} + {# The breadcrumbs of the item path, like std::string #} + {% for component in path_components %} + {{component.name}}:: + {% endfor %} + {{name}} {# #} + {# #} +

{# #} + {# #} {% if !stability_since_raw.is_empty() %} - {{- stability_since_raw|safe }} · {# -#} + {{ stability_since_raw|safe +}} · {#+ #} {% endif %} - {%- match src_href -%} - {%- when Some with (href) -%} - source · {# -#} - {%- else -%} - {%- endmatch -%} - {#- -#} - {#- -#} -
{#- -#} + {% match src_href %} + {% when Some with (href) %} + source · {#+ #} + {% else %} + {% endmatch %} + {# #} +
{# #} +
{# #} 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 } %} +
{# #} + 👎 {# #} + {{message|safe}} {# #} +
{# #} + {% when Self::Unstable with { feature, tracking } %} +
{# #} + 🔬 {# #} + {# #} + This is a nightly-only experimental API. ({# #} + {{feature}} {# #} + {% match tracking %} + {% when Some with ((url, num)) %} +  #{{num}} {# #} + {% when None %} + {% endmatch %} + ) {# #} + {# #} +
{# #} + {% when Self::Portability with { message } %} +
{{message|safe}}
{# #} +{% 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() %} +

{# #} + {{title_prefix}}{{title}} {# #} +

+{% endif %} + 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 @@ +
{# #} + {# 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. #} +
+        {% for line in lines.clone() %}
+            {% if embedded %}
+                {{line|safe}}
+            {%~ else %}
+                {{line|safe}}
+            {%~ endif %}
+        {% endfor %}
+    
{# #} +
 {# #}
+        
+            {% if needs_expansion %}
+                
+            {% endif %}
+            {{code_html|safe}}
+         {# #}
+    
{# #} +
-- cgit v1.2.3