diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-09-05 18:58:56 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-05 18:58:56 +0200 |
| commit | 9be97ae8e29b99a030a327cdb50e1997a4ff3470 (patch) | |
| tree | 8b78e601cf29af214f649a8b176c342f5f846e10 /src/librustdoc/html/templates | |
| parent | 15e7a67b502b2f4729ef39d7a517fe9e762bd438 (diff) | |
| parent | 7157f98cb481766873306238185fb5d4522a903a (diff) | |
Rollup merge of #129796 - GuillaumeGomez:unify-code-examples, r=notriddle
Unify scraped examples with other code examples Fixes #129763. This first PR both fixes #129763 but also unifies buttons display for code examples:  You can test it [here](https://rustdoc.crud.net/imperio/unify-code-examples/doc/scrape_examples/fn.test.html) and [here](https://rustdoc.crud.net/imperio/unify-code-examples/doc/scrape_examples/fn.test_many.html). I'm planning to send a follow-up to make the buttons generated in JS directly (or I can do it in this PR directly if you prefer). cc ```@willcrichton``` r? ```@notriddle```
Diffstat (limited to 'src/librustdoc/html/templates')
| -rw-r--r-- | src/librustdoc/html/templates/scraped_source.html | 33 | ||||
| -rw-r--r-- | src/librustdoc/html/templates/source.html | 14 |
2 files changed, 37 insertions, 10 deletions
diff --git a/src/librustdoc/html/templates/scraped_source.html b/src/librustdoc/html/templates/scraped_source.html new file mode 100644 index 00000000000..e1fc2e69378 --- /dev/null +++ b/src/librustdoc/html/templates/scraped_source.html @@ -0,0 +1,33 @@ +<div class="scraped-example{% if !info.needs_expansion +%} expanded{% endif %}" data-locs="{{info.locations}}"> {# #} + <div class="scraped-example-title"> + {{info.name +}} (<a href="{{info.url}}">{{info.title}}</a>) {# #} + </div> + <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 class="src-line-numbers" data-nosnippet> {# #} + <pre> + {% for line in lines.clone() %} + {# ~#} + <span>{{line|safe}}</span> + {% endfor %} + </pre> {# #} + </div> {# #} + <pre class="rust"> {# #} + <code> + {{code_html|safe}} + </code> {# #} + </pre> {# #} + {% if info.needs_prev_next_buttons || info.needs_expansion %} + <div class="button-holder"> + {% if info.needs_prev_next_buttons %} + <button class="prev">≺</button> {# #} + <button class="next">≻</button> + {% endif %} + {% if info.needs_expansion %} + <button class="expand">↕</button> + {% endif %} + </div> + {% endif %} + </div> {# #} +</div> {# #} diff --git a/src/librustdoc/html/templates/source.html b/src/librustdoc/html/templates/source.html index 42d01277db2..60a47f1b5de 100644 --- a/src/librustdoc/html/templates/source.html +++ b/src/librustdoc/html/templates/source.html @@ -1,21 +1,15 @@ -<div class="example-wrap"> {# #} +<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 %} + {# ~#} + <a href="#{{line|safe}}" id="{{line|safe}}">{{line|safe}}</a> {% endfor %} </pre></div> {# #} <pre class="rust"> {# #} <code> - {% if needs_expansion %} - <button class="expand">↕</button> - {% endif %} {{code_html|safe}} </code> {# #} </pre> {# #} -</div> +</div> {# #} |
