From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/librustdoc/html/templates/STYLE.md | 37 +++++++ src/librustdoc/html/templates/page.html | 148 ++++++++++++++++++++++++++ src/librustdoc/html/templates/print_item.html | 30 ++++++ 3 files changed, 215 insertions(+) create mode 100644 src/librustdoc/html/templates/STYLE.md create mode 100644 src/librustdoc/html/templates/page.html create mode 100644 src/librustdoc/html/templates/print_item.html (limited to 'src/librustdoc/html/templates') diff --git a/src/librustdoc/html/templates/STYLE.md b/src/librustdoc/html/templates/STYLE.md new file mode 100644 index 000000000..fff65e3b5 --- /dev/null +++ b/src/librustdoc/html/templates/STYLE.md @@ -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 diff --git a/src/librustdoc/html/templates/page.html b/src/librustdoc/html/templates/page.html new file mode 100644 index 000000000..8e25f6764 --- /dev/null +++ b/src/librustdoc/html/templates/page.html @@ -0,0 +1,148 @@ + {#- -#} + {#- -#} + {#- -#} + {#- -#} + {#- -#} + {#- -#} + {#- -#} + {#- -#} + {{page.title}} {#- -#} + {#- -#} + {#- -#} + {#- -#} + {#- -#} + {#- -#} + {#- -#} + {#- -#} + {#- -#} + {%- for theme in themes -%} + + {%- endfor -%} + {#- -#} + {#- -#} + {%- 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 !layout.logo.is_empty() %} + logo {#- -#} + {%- else -%} + {#- -#} + {%- endif -%} + {#- -#} + {#- -#} +
{#- -#} +
{{- content|safe -}}
{#- -#} +
{#- -#} +
{#- -#} + {{- layout.external_html.after_content|safe -}} +
{#- -#} +
{#- -#} + {#- -#} + {#- -#} diff --git a/src/librustdoc/html/templates/print_item.html b/src/librustdoc/html/templates/print_item.html new file mode 100644 index 000000000..c755157d2 --- /dev/null +++ b/src/librustdoc/html/templates/print_item.html @@ -0,0 +1,30 @@ +
{#- -#} +

{#- -#} + {#- -#} + {{-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 }} · {# -#} + {% endif %} + {%- match src_href -%} + {%- when Some with (href) -%} + source · {# -#} + {%- else -%} + {%- endmatch -%} + {#- -#} + [] {#- -#} + {#- -#} + {#- -#} +
{#- -#} -- cgit v1.2.3