mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 04:08:40 +00:00
Rollup merge of #74359 - lzutao:rustdoc-tostring, r=GuillaumeGomez
rustdoc: Rename internal API fns to `into_string` to avoid surprising listed in API guidelines.
This commit is contained in:
commit
61fccf05f9
@ -37,14 +37,14 @@ impl ExternalHtml {
|
|||||||
let bc = format!(
|
let bc = format!(
|
||||||
"{}{}",
|
"{}{}",
|
||||||
bc,
|
bc,
|
||||||
Markdown(&m_bc, &[], id_map, codes, edition, playground).to_string()
|
Markdown(&m_bc, &[], id_map, codes, edition, playground).into_string()
|
||||||
);
|
);
|
||||||
let ac = load_external_files(after_content, diag)?;
|
let ac = load_external_files(after_content, diag)?;
|
||||||
let m_ac = load_external_files(md_after_content, diag)?;
|
let m_ac = load_external_files(md_after_content, diag)?;
|
||||||
let ac = format!(
|
let ac = format!(
|
||||||
"{}{}",
|
"{}{}",
|
||||||
ac,
|
ac,
|
||||||
Markdown(&m_ac, &[], id_map, codes, edition, playground).to_string()
|
Markdown(&m_ac, &[], id_map, codes, edition, playground).into_string()
|
||||||
);
|
);
|
||||||
Some(ExternalHtml { in_header: ih, before_content: bc, after_content: ac })
|
Some(ExternalHtml { in_header: ih, before_content: bc, after_content: ac })
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
//! let s = "My *markdown* _text_";
|
//! let s = "My *markdown* _text_";
|
||||||
//! let mut id_map = IdMap::new();
|
//! let mut id_map = IdMap::new();
|
||||||
//! let md = Markdown(s, &[], &mut id_map, ErrorCodes::Yes, Edition::Edition2015, &None);
|
//! let md = Markdown(s, &[], &mut id_map, ErrorCodes::Yes, Edition::Edition2015, &None);
|
||||||
//! let html = md.to_string();
|
//! let html = md.into_string();
|
||||||
//! // ... something using html
|
//! // ... something using html
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
@ -848,7 +848,7 @@ impl LangString {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Markdown<'_> {
|
impl Markdown<'_> {
|
||||||
pub fn to_string(self) -> String {
|
pub fn into_string(self) -> String {
|
||||||
let Markdown(md, links, mut ids, codes, edition, playground) = self;
|
let Markdown(md, links, mut ids, codes, edition, playground) = self;
|
||||||
|
|
||||||
// This is actually common enough to special-case
|
// This is actually common enough to special-case
|
||||||
@ -878,7 +878,7 @@ impl Markdown<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl MarkdownWithToc<'_> {
|
impl MarkdownWithToc<'_> {
|
||||||
pub fn to_string(self) -> String {
|
pub fn into_string(self) -> String {
|
||||||
let MarkdownWithToc(md, mut ids, codes, edition, playground) = self;
|
let MarkdownWithToc(md, mut ids, codes, edition, playground) = self;
|
||||||
|
|
||||||
let p = Parser::new_ext(md, opts());
|
let p = Parser::new_ext(md, opts());
|
||||||
@ -899,7 +899,7 @@ impl MarkdownWithToc<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl MarkdownHtml<'_> {
|
impl MarkdownHtml<'_> {
|
||||||
pub fn to_string(self) -> String {
|
pub fn into_string(self) -> String {
|
||||||
let MarkdownHtml(md, mut ids, codes, edition, playground) = self;
|
let MarkdownHtml(md, mut ids, codes, edition, playground) = self;
|
||||||
|
|
||||||
// This is actually common enough to special-case
|
// This is actually common enough to special-case
|
||||||
@ -926,7 +926,7 @@ impl MarkdownHtml<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl MarkdownSummaryLine<'_> {
|
impl MarkdownSummaryLine<'_> {
|
||||||
pub fn to_string(self) -> String {
|
pub fn into_string(self) -> String {
|
||||||
let MarkdownSummaryLine(md, links) = self;
|
let MarkdownSummaryLine(md, links) = self;
|
||||||
// This is actually common enough to special-case
|
// This is actually common enough to special-case
|
||||||
if md.is_empty() {
|
if md.is_empty() {
|
||||||
|
@ -134,7 +134,7 @@ fn test_header() {
|
|||||||
fn t(input: &str, expect: &str) {
|
fn t(input: &str, expect: &str) {
|
||||||
let mut map = IdMap::new();
|
let mut map = IdMap::new();
|
||||||
let output =
|
let output =
|
||||||
Markdown(input, &[], &mut map, ErrorCodes::Yes, DEFAULT_EDITION, &None).to_string();
|
Markdown(input, &[], &mut map, ErrorCodes::Yes, DEFAULT_EDITION, &None).into_string();
|
||||||
assert_eq!(output, expect, "original: {}", input);
|
assert_eq!(output, expect, "original: {}", input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +166,8 @@ fn test_header() {
|
|||||||
fn test_header_ids_multiple_blocks() {
|
fn test_header_ids_multiple_blocks() {
|
||||||
let mut map = IdMap::new();
|
let mut map = IdMap::new();
|
||||||
fn t(map: &mut IdMap, input: &str, expect: &str) {
|
fn t(map: &mut IdMap, input: &str, expect: &str) {
|
||||||
let output = Markdown(input, &[], map, ErrorCodes::Yes, DEFAULT_EDITION, &None).to_string();
|
let output =
|
||||||
|
Markdown(input, &[], map, ErrorCodes::Yes, DEFAULT_EDITION, &None).into_string();
|
||||||
assert_eq!(output, expect, "original: {}", input);
|
assert_eq!(output, expect, "original: {}", input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +229,7 @@ fn test_markdown_html_escape() {
|
|||||||
fn t(input: &str, expect: &str) {
|
fn t(input: &str, expect: &str) {
|
||||||
let mut idmap = IdMap::new();
|
let mut idmap = IdMap::new();
|
||||||
let output =
|
let output =
|
||||||
MarkdownHtml(input, &mut idmap, ErrorCodes::Yes, DEFAULT_EDITION, &None).to_string();
|
MarkdownHtml(input, &mut idmap, ErrorCodes::Yes, DEFAULT_EDITION, &None).into_string();
|
||||||
assert_eq!(output, expect, "original: {}", input);
|
assert_eq!(output, expect, "original: {}", input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1895,7 +1895,7 @@ fn render_markdown(
|
|||||||
cx.shared.edition,
|
cx.shared.edition,
|
||||||
&cx.shared.playground
|
&cx.shared.playground
|
||||||
)
|
)
|
||||||
.to_string()
|
.into_string()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2185,7 +2185,7 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
|
|||||||
</tr>",
|
</tr>",
|
||||||
name = *myitem.name.as_ref().unwrap(),
|
name = *myitem.name.as_ref().unwrap(),
|
||||||
stab_tags = stability_tags(myitem),
|
stab_tags = stability_tags(myitem),
|
||||||
docs = MarkdownSummaryLine(doc_value, &myitem.links()).to_string(),
|
docs = MarkdownSummaryLine(doc_value, &myitem.links()).into_string(),
|
||||||
class = myitem.type_(),
|
class = myitem.type_(),
|
||||||
add = add,
|
add = add,
|
||||||
stab = stab.unwrap_or_else(String::new),
|
stab = stab.unwrap_or_else(String::new),
|
||||||
@ -2278,7 +2278,7 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
|
|||||||
cx.shared.edition,
|
cx.shared.edition,
|
||||||
&cx.shared.playground,
|
&cx.shared.playground,
|
||||||
);
|
);
|
||||||
message.push_str(&format!(": {}", html.to_string()));
|
message.push_str(&format!(": {}", html.into_string()));
|
||||||
}
|
}
|
||||||
stability.push(format!(
|
stability.push(format!(
|
||||||
"<div class='stab deprecated'><span class='emoji'>👎</span> {}</div>",
|
"<div class='stab deprecated'><span class='emoji'>👎</span> {}</div>",
|
||||||
@ -2332,7 +2332,7 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
|
|||||||
cx.shared.edition,
|
cx.shared.edition,
|
||||||
&cx.shared.playground,
|
&cx.shared.playground,
|
||||||
)
|
)
|
||||||
.to_string()
|
.into_string()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3632,7 +3632,7 @@ fn render_impl(
|
|||||||
cx.shared.edition,
|
cx.shared.edition,
|
||||||
&cx.shared.playground
|
&cx.shared.playground
|
||||||
)
|
)
|
||||||
.to_string()
|
.into_string()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,9 +68,9 @@ pub fn render<P: AsRef<Path>>(
|
|||||||
let mut ids = IdMap::new();
|
let mut ids = IdMap::new();
|
||||||
let error_codes = ErrorCodes::from(UnstableFeatures::from_environment().is_nightly_build());
|
let error_codes = ErrorCodes::from(UnstableFeatures::from_environment().is_nightly_build());
|
||||||
let text = if !options.markdown_no_toc {
|
let text = if !options.markdown_no_toc {
|
||||||
MarkdownWithToc(text, &mut ids, error_codes, edition, &playground).to_string()
|
MarkdownWithToc(text, &mut ids, error_codes, edition, &playground).into_string()
|
||||||
} else {
|
} else {
|
||||||
Markdown(text, &[], &mut ids, error_codes, edition, &playground).to_string()
|
Markdown(text, &[], &mut ids, error_codes, edition, &playground).into_string()
|
||||||
};
|
};
|
||||||
|
|
||||||
let err = write!(
|
let err = write!(
|
||||||
|
@ -127,7 +127,7 @@ impl Formatter for HTMLFormatter {
|
|||||||
DEFAULT_EDITION,
|
DEFAULT_EDITION,
|
||||||
&Some(playground)
|
&Some(playground)
|
||||||
)
|
)
|
||||||
.to_string()
|
.into_string()
|
||||||
)?
|
)?
|
||||||
}
|
}
|
||||||
None => write!(output, "<p>No description.</p>\n")?,
|
None => write!(output, "<p>No description.</p>\n")?,
|
||||||
|
Loading…
Reference in New Issue
Block a user