<!DOCTYPE HTML> <html lang="en" class="sidebar-visible no-js"> <head> <!-- Book generated using mdBook --> <meta charset="UTF-8"> <title>Command-line arguments - </title> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="theme-color" content="#ffffff" /> <base href=""> <link rel="stylesheet" href="book.css"> <link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css"> <link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css"> <link rel="shortcut icon" href="favicon.png"> <!-- Font Awesome --> <link rel="stylesheet" href="_FontAwesome/css/font-awesome.css"> <link rel="stylesheet" href="highlight.css"> <link rel="stylesheet" href="tomorrow-night.css"> <link rel="stylesheet" href="ayu-highlight.css"> <!-- Custom theme stylesheets --> </head> <body class="light"> <!-- Work around some values being stored in localStorage wrapped in quotes --> <script type="text/javascript"> try { var theme = localStorage.getItem('mdbook-theme'); var sidebar = localStorage.getItem('mdbook-sidebar'); if (theme.startsWith('"') && theme.endsWith('"')) { localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1)); } if (sidebar.startsWith('"') && sidebar.endsWith('"')) { localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1)); } } catch (e) { } </script> <!-- Set the theme before any content is loaded, prevents flash --> <script type="text/javascript"> var theme; try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { } if (theme === null || theme === undefined) { theme = 'light'; } document.body.className = theme; document.querySelector('html').className = theme + ' js'; </script> <!-- Hide / unhide sidebar before it is displayed --> <script type="text/javascript"> var html = document.querySelector('html'); var sidebar = 'hidden'; if (document.body.clientWidth >= 1080) { try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { } sidebar = sidebar || 'visible'; } html.classList.remove('sidebar-visible'); html.classList.add("sidebar-" + sidebar); </script> <nav id="sidebar" class="sidebar" aria-label="Table of contents"> <ol class="chapter"><li><a href="what-is-rustdoc.html"><strong aria-hidden="true">1.</strong> What is rustdoc?</a></li><li><a href="command-line-arguments.html" class="active"><strong aria-hidden="true">2.</strong> Command-line arguments</a></li><li><a href="the-doc-attribute.html"><strong aria-hidden="true">3.</strong> The #[doc] attribute</a></li><li><a href="documentation-tests.html"><strong aria-hidden="true">4.</strong> Documentation tests</a></li><li><a href="passes.html"><strong aria-hidden="true">5.</strong> Passes</a></li><li><a href="unstable-features.html"><strong aria-hidden="true">6.</strong> Unstable features</a></li></ol> </nav> <div id="page-wrapper" class="page-wrapper"> <div class="page"> <div id="menu-bar" class="menu-bar"> <div id="menu-bar-sticky-container"> <div class="left-buttons"> <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar"> <i class="fa fa-bars"></i> </button> <button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list"> <i class="fa fa-paint-brush"></i> </button> <ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu"> <li role="none"><button role="menuitem" class="theme" id="light">Light <span class="default">(default)</span></button></li> <li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li> <li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li> <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li> <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li> </ul> <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar"> <i class="fa fa-search"></i> </button> </div> <h1 class="menu-title"></h1> <div class="right-buttons"> <a href="print.html" title="Print this book" aria-label="Print this book"> <i id="print-button" class="fa fa-print"></i> </a> </div> </div> </div> <div id="search-wrapper" class="hidden"> <form id="searchbar-outer" class="searchbar-outer"> <input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header"> </form> <div id="searchresults-outer" class="searchresults-outer hidden"> <div id="searchresults-header" class="searchresults-header"></div> <ul id="searchresults"> </ul> </div> </div> <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> <script type="text/javascript"> document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible'); document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible'); Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) { link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1); }); </script> <div id="content" class="content"> <main> <a class="header" href="command-line-arguments.html#command-line-arguments" id="command-line-arguments"><h1>Command-line arguments</h1></a> <p>Here's the list of arguments you can pass to <code>rustdoc</code>:</p> <a class="header" href="command-line-arguments.html#a-h--help-help" id="a-h--help-help"><h2><code>-h</code>/<code>--help</code>: help</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc -h $ rustdoc --help </code></pre> <p>This will show <code>rustdoc</code>'s built-in help, which largely consists of a list of possible command-line flags.</p> <p>Some of <code>rustdoc</code>'s flags are unstable; this page only shows stable options, <code>--help</code> will show them all.</p> <a class="header" href="command-line-arguments.html#a-v--version-version-information" id="a-v--version-version-information"><h2><code>-V</code>/<code>--version</code>: version information</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc -V $ rustdoc --version </code></pre> <p>This will show <code>rustdoc</code>'s version, which will look something like this:</p> <pre><code class="language-text">rustdoc 1.17.0 (56124baa9 2017-04-24) </code></pre> <a class="header" href="command-line-arguments.html#a-v--verbose-more-verbose-output" id="a-v--verbose-more-verbose-output"><h2><code>-v</code>/<code>--verbose</code>: more verbose output</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc -v src/lib.rs $ rustdoc --verbose src/lib.rs </code></pre> <p>This enables "verbose mode", which means that more information will be written to standard out. What is written depends on the other flags you've passed in. For example, with <code>--version</code>:</p> <pre><code class="language-text">$ rustdoc --verbose --version rustdoc 1.17.0 (56124baa9 2017-04-24) binary: rustdoc commit-hash: hash commit-date: date host: host-triple release: 1.17.0 LLVM version: 3.9 </code></pre> <a class="header" href="command-line-arguments.html#a-r--input-format-input-format" id="a-r--input-format-input-format"><h2><code>-r</code>/<code>--input-format</code>: input format</h2></a> <p>This flag is currently ignored; the idea is that <code>rustdoc</code> would support various input formats, and you could specify them via this flag.</p> <p>Rustdoc only supports Rust source code and Markdown input formats. If the file ends in <code>.md</code> or <code>.markdown</code>, <code>rustdoc</code> treats it as a Markdown file. Otherwise, it assumes that the input file is Rust.</p> <a class="header" href="command-line-arguments.html#a-w--output-format-output-format" id="a-w--output-format-output-format"><h2><code>-w</code>/<code>--output-format</code>: output format</h2></a> <p>This flag is currently ignored; the idea is that <code>rustdoc</code> would support various output formats, and you could specify them via this flag.</p> <p>Rustdoc only supports HTML output, and so this flag is redundant today.</p> <a class="header" href="command-line-arguments.html#a-o--output-output-path" id="a-o--output-output-path"><h2><code>-o</code>/<code>--output</code>: output path</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc src/lib.rs -o target\\doc $ rustdoc src/lib.rs --output target\\doc </code></pre> <p>By default, <code>rustdoc</code>'s output appears in a directory named <code>doc</code> in the current working directory. With this flag, it will place all output into the directory you specify.</p> <a class="header" href="command-line-arguments.html#a--crate-name-controlling-the-name-of-the-crate" id="a--crate-name-controlling-the-name-of-the-crate"><h2><code>--crate-name</code>: controlling the name of the crate</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc src/lib.rs --crate-name mycrate </code></pre> <p>By default, <code>rustdoc</code> assumes that the name of your crate is the same name as the <code>.rs</code> file. <code>--crate-name</code> lets you override this assumption with whatever name you choose.</p> <a class="header" href="command-line-arguments.html#a-l--library-path-where-to-look-for-dependencies" id="a-l--library-path-where-to-look-for-dependencies"><h2><code>-L</code>/<code>--library-path</code>: where to look for dependencies</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc src/lib.rs -L target/debug/deps $ rustdoc src/lib.rs --library-path target/debug/deps </code></pre> <p>If your crate has dependencies, <code>rustdoc</code> needs to know where to find them. Passing <code>--library-path</code> gives <code>rustdoc</code> a list of places to look for these dependencies.</p> <p>This flag takes any number of directories as its argument, and will use all of them when searching.</p> <a class="header" href="command-line-arguments.html#a--cfg-passing-configuration-flags" id="a--cfg-passing-configuration-flags"><h2><code>--cfg</code>: passing configuration flags</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc src/lib.rs --cfg feature="foo" </code></pre> <p>This flag accepts the same values as <code>rustc --cfg</code>, and uses it to configure compilation. The example above uses <code>feature</code>, but any of the <code>cfg</code> values are acceptable.</p> <a class="header" href="command-line-arguments.html#a--extern-specify-a-dependencys-location" id="a--extern-specify-a-dependencys-location"><h2><code>--extern</code>: specify a dependency's location</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc src/lib.rs --extern lazy-static=/path/to/lazy-static </code></pre> <p>Similar to <code>--library-path</code>, <code>--extern</code> is about specifying the location of a dependency. <code>--library-path</code> provides directories to search in, <code>--extern</code> instead lets you specify exactly which dependency is located where.</p> <a class="header" href="command-line-arguments.html#a-c--codegen-pass-codegen-options-to-rustc" id="a-c--codegen-pass-codegen-options-to-rustc"><h2><code>-C</code>/<code>--codegen</code>: pass codegen options to rustc</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc src/lib.rs -C target_feature=+avx $ rustdoc src/lib.rs --codegen target_feature=+avx $ rustdoc --test src/lib.rs -C target_feature=+avx $ rustdoc --test src/lib.rs --codegen target_feature=+avx $ rustdoc --test README.md -C target_feature=+avx $ rustdoc --test README.md --codegen target_feature=+avx </code></pre> <p>When rustdoc generates documentation, looks for documentation tests, or executes documentation tests, it needs to compile some rust code, at least part-way. This flag allows you to tell rustdoc to provide some extra codegen options to rustc when it runs these compilations. Most of the time, these options won't affect a regular documentation run, but if something depends on target features to be enabled, or documentation tests need to use some additional options, this flag allows you to affect that.</p> <p>The arguments to this flag are the same as those for the <code>-C</code> flag on rustc. Run <code>rustc -C help</code> to get the full list.</p> <a class="header" href="command-line-arguments.html#a--passes-add-more-rustdoc-passes" id="a--passes-add-more-rustdoc-passes"><h2><code>--passes</code>: add more rustdoc passes</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc --passes list $ rustdoc src/lib.rs --passes strip-priv-imports </code></pre> <p>An argument of "list" will print a list of possible "rustdoc passes", and other arguments will be the name of which passes to run in addition to the defaults.</p> <p>For more details on passes, see <a href="passes.html">the chapter on them</a>.</p> <p>See also <code>--no-defaults</code>.</p> <a class="header" href="command-line-arguments.html#a--no-defaults-dont-run-default-passes" id="a--no-defaults-dont-run-default-passes"><h2><code>--no-defaults</code>: don't run default passes</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc src/lib.rs --no-defaults </code></pre> <p>By default, <code>rustdoc</code> will run several passes over your code. This removes those defaults, allowing you to use <code>--passes</code> to specify exactly which passes you want.</p> <p>For more details on passes, see <a href="passes.html">the chapter on them</a>.</p> <p>See also <code>--passes</code>.</p> <a class="header" href="command-line-arguments.html#a--test-run-code-examples-as-tests" id="a--test-run-code-examples-as-tests"><h2><code>--test</code>: run code examples as tests</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc src/lib.rs --test </code></pre> <p>This flag will run your code examples as tests. For more, see <a href="documentation-tests.html">the chapter on documentation tests</a>.</p> <p>See also <code>--test-args</code>.</p> <a class="header" href="command-line-arguments.html#a--test-args-pass-options-to-test-runner" id="a--test-args-pass-options-to-test-runner"><h2><code>--test-args</code>: pass options to test runner</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc src/lib.rs --test --test-args ignored </code></pre> <p>This flag will pass options to the test runner when running documentation tests. For more, see <a href="documentation-tests.html">the chapter on documentation tests</a>.</p> <p>See also <code>--test</code>.</p> <a class="header" href="command-line-arguments.html#a--target-generate-documentation-for-the-specified-target-triple" id="a--target-generate-documentation-for-the-specified-target-triple"><h2><code>--target</code>: generate documentation for the specified target triple</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc src/lib.rs --target x86_64-pc-windows-gnu </code></pre> <p>Similar to the <code>--target</code> flag for <code>rustc</code>, this generates documentation for a target triple that's different than your host triple.</p> <p>All of the usual caveats of cross-compiling code apply.</p> <a class="header" href="command-line-arguments.html#a--markdown-css-include-more-css-files-when-rendering-markdown" id="a--markdown-css-include-more-css-files-when-rendering-markdown"><h2><code>--markdown-css</code>: include more CSS files when rendering markdown</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc README.md --markdown-css foo.css </code></pre> <p>When rendering Markdown files, this will create a <code><link></code> element in the <code><head></code> section of the generated HTML. For example, with the invocation above,</p> <pre><code class="language-html"><link rel="stylesheet" type="text/css" href="foo.css"> </code></pre> <p>will be added.</p> <p>When rendering Rust files, this flag is ignored.</p> <a class="header" href="command-line-arguments.html#a--html-in-header-include-more-html-in-head" id="a--html-in-header-include-more-html-in-head"><h2><code>--html-in-header</code>: include more HTML in <head></h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc src/lib.rs --html-in-header header.html $ rustdoc README.md --html-in-header header.html </code></pre> <p>This flag takes a list of files, and inserts them into the <code><head></code> section of the rendered documentation.</p> <a class="header" href="command-line-arguments.html#a--html-before-content-include-more-html-before-the-content" id="a--html-before-content-include-more-html-before-the-content"><h2><code>--html-before-content</code>: include more HTML before the content</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc src/lib.rs --html-before-content extra.html $ rustdoc README.md --html-before-content extra.html </code></pre> <p>This flag takes a list of files, and inserts them inside the <code><body></code> tag but before the other content <code>rustdoc</code> would normally produce in the rendered documentation.</p> <a class="header" href="command-line-arguments.html#a--html-after-content-include-more-html-after-the-content" id="a--html-after-content-include-more-html-after-the-content"><h2><code>--html-after-content</code>: include more HTML after the content</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc src/lib.rs --html-after-content extra.html $ rustdoc README.md --html-after-content extra.html </code></pre> <p>This flag takes a list of files, and inserts them before the <code></body></code> tag but after the other content <code>rustdoc</code> would normally produce in the rendered documentation.</p> <a class="header" href="command-line-arguments.html#a--markdown-playground-url-control-the-location-of-the-playground" id="a--markdown-playground-url-control-the-location-of-the-playground"><h2><code>--markdown-playground-url</code>: control the location of the playground</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc README.md --markdown-playground-url https://play.rust-lang.org/ </code></pre> <p>When rendering a Markdown file, this flag gives the base URL of the Rust Playground, to use for generating <code>Run</code> buttons.</p> <a class="header" href="command-line-arguments.html#a--markdown-no-toc-dont-generate-a-table-of-contents" id="a--markdown-no-toc-dont-generate-a-table-of-contents"><h2><code>--markdown-no-toc</code>: don't generate a table of contents</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc README.md --markdown-no-toc </code></pre> <p>When generating documentation from a Markdown file, by default, <code>rustdoc</code> will generate a table of contents. This flag suppresses that, and no TOC will be generated.</p> <a class="header" href="command-line-arguments.html#a-e--extend-css-extend-rustdocs-css" id="a-e--extend-css-extend-rustdocs-css"><h2><code>-e</code>/<code>--extend-css</code>: extend rustdoc's CSS</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc src/lib.rs -e extra.css $ rustdoc src/lib.rs --extend-css extra.css </code></pre> <p>With this flag, the contents of the files you pass are included at the bottom of Rustdoc's <code>theme.css</code> file.</p> <p>While this flag is stable, the contents of <code>theme.css</code> are not, so be careful! Updates may break your theme extensions.</p> <a class="header" href="command-line-arguments.html#a--sysroot-override-the-system-root" id="a--sysroot-override-the-system-root"><h2><code>--sysroot</code>: override the system root</h2></a> <p>Using this flag looks like this:</p> <pre><code class="language-bash">$ rustdoc src/lib.rs --sysroot /path/to/sysroot </code></pre> <p>Similar to <code>rustc --sysroot</code>, this lets you change the sysroot <code>rustdoc</code> uses when compiling your code.</p> </main> <nav class="nav-wrapper" aria-label="Page navigation"> <!-- Mobile navigation buttons --> <a rel="prev" href="what-is-rustdoc.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <i class="fa fa-angle-left"></i> </a> <a rel="next" href="the-doc-attribute.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <i class="fa fa-angle-right"></i> </a> <div style="clear: both"></div> </nav> </div> </div> <nav class="nav-wide-wrapper" aria-label="Page navigation"> <a href="what-is-rustdoc.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <i class="fa fa-angle-left"></i> </a> <a href="the-doc-attribute.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <i class="fa fa-angle-right"></i> </a> </nav> </div> <script src="searchindex.js" type="text/javascript" charset="utf-8"></script> <script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script> <script src="mark.min.js" type="text/javascript" charset="utf-8"></script> <script src="searcher.js" type="text/javascript" charset="utf-8"></script> <script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script> <script src="highlight.js" type="text/javascript" charset="utf-8"></script> <script src="book.js" type="text/javascript" charset="utf-8"></script> <!-- Custom JS scripts --> </body> </html>