Skip to content

Commit 8af1851

Browse files
authored
Rollup merge of #131928 - aDotInTheVoid:wait-we-support-this, r=GuillaumeGomez
rustdoc: Document `markdown` module. Rustdoc markdown handling is currently split between: - html::markdown, which contains all the meaty login - markdown, which is only used for when rustdoc renders a standalone markdown file Adds module-level doc-comment to markdown, and rename the function so it's clear that it's doing IO (instead of just rendering to a string).
2 parents af2c7df + 3b78956 commit 8af1851

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/librustdoc/html/render/write_shared.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub(crate) fn write_shared(
112112
md_opts.output = cx.dst.clone();
113113
md_opts.external_html = cx.shared.layout.external_html.clone();
114114
try_err!(
115-
crate::markdown::render(&index_page, md_opts, cx.shared.edition()),
115+
crate::markdown::render_and_write(&index_page, md_opts, cx.shared.edition()),
116116
&index_page
117117
);
118118
}

src/librustdoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ fn main_args(
817817
return wrap_return(
818818
dcx,
819819
interface::run_compiler(config, |_compiler| {
820-
markdown::render(&md_input, render_options, edition)
820+
markdown::render_and_write(&md_input, render_options, edition)
821821
}),
822822
);
823823
}

src/librustdoc/markdown.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
//! Standalone markdown rendering.
2+
//!
3+
//! For the (much more common) case of rendering markdown in doc-comments, see
4+
//! [crate::html::markdown].
5+
//!
6+
//! This is used when [rendering a markdown file to an html file][docs], without processing
7+
//! rust source code.
8+
//!
9+
//! [docs]: https://doc.rust-lang.org/stable/rustdoc/#using-standalone-markdown-files
10+
111
use std::fmt::Write as _;
212
use std::fs::{File, create_dir_all, read_to_string};
313
use std::io::prelude::*;
@@ -33,7 +43,7 @@ fn extract_leading_metadata(s: &str) -> (Vec<&str>, &str) {
3343
/// (e.g., output = "bar" => "bar/foo.html").
3444
///
3545
/// Requires session globals to be available, for symbol interning.
36-
pub(crate) fn render<P: AsRef<Path>>(
46+
pub(crate) fn render_and_write<P: AsRef<Path>>(
3747
input: P,
3848
options: RenderOptions,
3949
edition: Edition,

0 commit comments

Comments
 (0)