Skip to content

Fix code blocks in /about #1315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions templates/core/about/builds.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@ <h4 id="detecting-docsrs"> <a href="#detecting-docsrs">Detecting Docs.rs</a> </h
<p>
To recognize Docs.rs from <code>build.rs</code> files, you can test for the environment variable <code>DOCS_RS</code>, e.g.:
{% filter dedent(levels=4) -%}
<pre>
<code>
if let Ok(_) = std::env::var("DOCS_RS") {
// ... your code here ...
}
</code>
</pre>
<pre><code class="lang-rust">
if let Ok(_) = std::env::var("DOCS_RS") {
// ... your code here ...
}
</code></pre>
{%- endfilter %}
This approach can be helpful if you need dependencies for building the library, but not for building the documentation.
</p>
Expand All @@ -51,12 +49,10 @@ <h4 id="cross-compiling"> <a href="#cross-compiling">Cross-compiling</a> </h4>
<p>
You can configure how your crate is built by adding <a href="metadata">package metadata</a> to your <code>Cargo.toml</code>, e.g.:
{% filter dedent -%}
<pre>
<code>
[package.metadata.docs.rs]
rustc-args = ["--cfg", "docsrs"]
</code>
</pre>
<pre><code class="lang-toml">
[package.metadata.docs.rs]
rustc-args = ["--cfg", "docsrs"]
</code></pre>
{%- endfilter %}
Here, the compiler arguments are set so that <code>#[cfg(docsrs)]</code> (not to be confused with <code>#[cfg(doc)]</code>) can be used for conditional compilation.
This approach is also useful for setting <a href="https://doc.rust-lang.org/cargo/reference/features.html">cargo features</a>.
Expand Down
2 changes: 1 addition & 1 deletion templates/core/about/metadata.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1>Metadata for custom builds</h1>

<p>The available configuration flags you can customize are:</p>

<pre><code>{%- include "core/Cargo.toml.example" -%}</code></pre>
<pre><code class="lang-toml">{%- include "core/Cargo.toml.example" -%}</code></pre>
</div>
</div>
{%- endblock body %}
Expand Down