From d94d9a6fe18ddf5e5c61adbb1b4a59707e74dbaa Mon Sep 17 00:00:00 2001 From: Camelid Date: Wed, 24 Feb 2021 21:41:43 -0800 Subject: [PATCH] Fix code blocks in `/about` * Add `lang-` classes so hl.js identifies them correctly (it thought Rust was C++ and TOML was INI before) * Remove large blank space caused by newlines in HTML source --- templates/core/about/builds.html | 22 +++++++++------------- templates/core/about/metadata.html | 2 +- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/templates/core/about/builds.html b/templates/core/about/builds.html index 46c2fc5df..cf0c70c65 100644 --- a/templates/core/about/builds.html +++ b/templates/core/about/builds.html @@ -32,13 +32,11 @@

Detecting Docs.rs To recognize Docs.rs from build.rs files, you can test for the environment variable DOCS_RS, e.g.: {% filter dedent(levels=4) -%} -
-            
-                if let Ok(_) = std::env::var("DOCS_RS") {
-                    // ... your code here ...
-                }
-            
-        
+

+            if let Ok(_) = std::env::var("DOCS_RS") {
+                // ... your code here ...
+            }
+        
{%- endfilter %} This approach can be helpful if you need dependencies for building the library, but not for building the documentation.

@@ -51,12 +49,10 @@

Cross-compiling

You can configure how your crate is built by adding package metadata to your Cargo.toml, e.g.: {% filter dedent -%} -

-            
-                [package.metadata.docs.rs]
-                rustc-args = ["--cfg", "docsrs"]
-            
-        
+

+            [package.metadata.docs.rs]
+            rustc-args = ["--cfg", "docsrs"]
+        
{%- endfilter %} Here, the compiler arguments are set so that #[cfg(docsrs)] (not to be confused with #[cfg(doc)]) can be used for conditional compilation. This approach is also useful for setting cargo features. diff --git a/templates/core/about/metadata.html b/templates/core/about/metadata.html index fe4fc8b3f..2ed383ae0 100644 --- a/templates/core/about/metadata.html +++ b/templates/core/about/metadata.html @@ -14,7 +14,7 @@

Metadata for custom builds

The available configuration flags you can customize are:

-
{%- include "core/Cargo.toml.example" -%}
+
{%- include "core/Cargo.toml.example" -%}
{%- endblock body %}