123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- #!/usr/bin/env bash
- # Copyright Materialize, Inc. and contributors. All rights reserved.
- #
- # Use of this software is governed by the Business Source License
- # included in the LICENSE file at the root of this repository.
- #
- # As of the Change Date specified in that file, in accordance with
- # the Business Source License, use of this software will be governed
- # by the Apache License, Version 2.0.
- #
- # doc — renders API documentation.
- # When using a nightly toolchain, this script will automatically enables the use
- # of some unstable niceties, like the `doc_cfg` annotations to indicate in the
- # docs what features must be enabled to use an item.
- #
- # CI always uses a nightly toolchain to run this script. To use one locally:
- #
- # $ RUSTUP_TOOLCHAIN=nightly bin/doc
- #
- set -euo pipefail
- cd "$(dirname "$0")/.."
- . misc/shlib/shlib.bash
- RUSTDOCFLAGS+=" -D warnings "
- if [[ $(cargo -V) = *nightly* ]]; then
- RUSTDOCFLAGS+=" --cfg nightly_doc_features"
- fi
- export RUSTDOCFLAGS
- target=${CARGO_TARGET_DIR:-target}
- cargo doc --all-features "$@"
- crates=$(cargo metadata --format-version=1 \
- | jq -r -f misc/doc/crates.jq --arg pwd "$(pwd)")
- # Create a nice homepage for the docs. It's awful that we have to copy the
- # HTML template like this, but the upstream issue [0] that would resolve this is
- # now five years old and doesn't look close to resolution.
- # [0]: https://github.com/rust-lang/cargo/issues/739
- cat > "$target"/doc/index.html <<EOF
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta name="generator" content="rustdoc">
- <meta name="description" content="API documentation for Materialize.">
- <meta name="keywords" content="rust, rustlang, rust-lang, materialize">
- <title>Materialize - Rust</title>
- <link rel="preload" as="font" type="font/woff2" crossorigin href="SourceSerif4-Regular.ttf.woff2">
- <link rel="preload" as="font" type="font/woff2" crossorigin href="FiraSans-Regular.woff2">
- <link rel="preload" as="font" type="font/woff2" crossorigin href="FiraSans-Medium.woff2">
- <link rel="preload" as="font" type="font/woff2" crossorigin href="SourceCodePro-Regular.ttf.woff2">
- <link rel="preload" as="font" type="font/woff2" crossorigin href="SourceSerif4-Bold.ttf.woff2">
- <link rel="preload" as="font" type="font/woff2" crossorigin href="SourceCodePro-Semibold.ttf.woff2">
- <link rel="stylesheet" type="text/css" href="normalize.css">
- <link rel="stylesheet" type="text/css" href="rustdoc.css" id="mainThemeStyle">
- <link rel="stylesheet" type="text/css" href="ayu.css" disabled>
- <link rel="stylesheet" type="text/css" href="dark.css" disabled>
- <link rel="stylesheet" type="text/css" href="light.css" id="themeStyle">
- <script id="default-settings" ></script><script src="storage.js"></script><script src="crates.js"></script><script defer src="main.js"></script>
- <noscript>
- <link rel="stylesheet" href="noscript.css">
- </noscript>
- <link rel="alternate icon" type="image/png" href="favicon-16x16.png">
- <link rel="alternate icon" type="image/png" href="favicon-32x32.png">
- <link rel="icon" type="image/svg+xml" href="favicon.svg">
- </head>
- <body class="rustdoc mod crate">
- <!--[if lte IE 11]>
- <div class="warning">This old browser is unsupported and will most likely display funky things.</div>
- <![endif]-->
- <nav class="mobile-topbar">
- <button class="sidebar-menu-toggle">☰</button>
- <a class="sidebar-logo" href="index.html">
- <div class="logo-container"><img class="rust-logo" src="rust-logo.svg" alt="logo"></div>
- </a>
- <h2 class="location"></h2>
- </nav>
- <nav class="sidebar">
- <a class="sidebar-logo" href="index.html">
- <div class="logo-container"><img class="rust-logo" src="rust-logo.svg" alt="logo"></div>
- </a>
- <div class="sidebar-elems">
- <div id="sidebar-vars" data-name="materialize" data-ty="root" data-relpath=""></div>
- <script>
- addEventListener("DOMContentLoaded", function () {
- initSidebarItems({});
- });
- </script>
- </div>
- </nav>
- <main>
- <div class="width-limiter">
- <div class="sub-container">
- <a class="sub-logo-container" href="index.html"><img class="rust-logo" src="rust-logo.svg" alt="logo"></a>
- <nav class="sub">
- <div class="theme-picker hidden">
- <button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="22" height="22" alt="Pick another theme!" src="brush.svg"></button>
- <div id="theme-choices" role="menu"></div>
- </div>
- <form class="search-form">
- <div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="wheel.svg"></a></div>
- </form>
- </nav>
- </div>
- <section id="main-content" class="content">
- <h1 class='fqn'>
- <span class='in-band'>Materialize documentation</span>
- </h1>
- <p>This is the home of Materialize's internal API documentation.</p>
- <h2>Important crates</h2>
- <table>
- $crates
- </table>
- </section>
- <section id="search" class="content hidden"></section>
- </div>
- </main>
- <div id="rustdoc-vars" data-root-path="." data-current-crate="materialize" data-resource-suffix="" data-themes="ayu,dark,light"></div>
- </body>
- </html>
- EOF
- # Make the logo link to the nice homepage we just created. Otherwise it just
- # links to the root of whatever crate you happen to be looking at.
- cat >> "$target"/doc/main.js <<EOF
- ;
- for (const logo of document.querySelectorAll("img[alt=logo]")) {
- var link = logo.closest("a");
- if (link.href != "index.html") {
- link.href = "../index.html";
- }
- }
- EOF
- echo "Docs are in $target/doc/index.html"
|