Rename some methods.
Most of the methods returning `impl Display` have `print` in their name. This commit renames a few that didn't follow that convention.
This commit is contained in:
@@ -705,13 +705,13 @@ fn resolved_path(
|
|||||||
f,
|
f,
|
||||||
"{path}::{anchor}",
|
"{path}::{anchor}",
|
||||||
path = join_with_double_colon(&fqp[..fqp.len() - 1]),
|
path = join_with_double_colon(&fqp[..fqp.len() - 1]),
|
||||||
anchor = anchor(did, *fqp.last().unwrap(), cx)
|
anchor = print_anchor(did, *fqp.last().unwrap(), cx)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
write!(f, "{}", last.name)
|
write!(f, "{}", last.name)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
write!(f, "{}", anchor(did, last.name, cx))
|
write!(f, "{}", print_anchor(did, last.name, cx))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
write!(w, "{path}{args}", args = last.args.print(cx))?;
|
write!(w, "{path}{args}", args = last.args.print(cx))?;
|
||||||
@@ -797,7 +797,7 @@ fn primitive_link_fragment(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tybounds(
|
fn print_tybounds(
|
||||||
bounds: &[clean::PolyTrait],
|
bounds: &[clean::PolyTrait],
|
||||||
lt: &Option<clean::Lifetime>,
|
lt: &Option<clean::Lifetime>,
|
||||||
cx: &Context<'_>,
|
cx: &Context<'_>,
|
||||||
@@ -829,7 +829,7 @@ fn print_higher_ranked_params_with_space(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn anchor(did: DefId, text: Symbol, cx: &Context<'_>) -> impl Display {
|
pub(crate) fn print_anchor(did: DefId, text: Symbol, cx: &Context<'_>) -> impl Display {
|
||||||
fmt::from_fn(move |f| {
|
fmt::from_fn(move |f| {
|
||||||
let parts = href(did, cx);
|
let parts = href(did, cx);
|
||||||
if let Ok((url, short_ty, fqp)) = parts {
|
if let Ok((url, short_ty, fqp)) = parts {
|
||||||
@@ -863,7 +863,7 @@ fn fmt_type(
|
|||||||
}
|
}
|
||||||
clean::DynTrait(bounds, lt) => {
|
clean::DynTrait(bounds, lt) => {
|
||||||
f.write_str("dyn ")?;
|
f.write_str("dyn ")?;
|
||||||
tybounds(bounds, lt, cx).fmt(f)
|
print_tybounds(bounds, lt, cx).fmt(f)
|
||||||
}
|
}
|
||||||
clean::Infer => write!(f, "_"),
|
clean::Infer => write!(f, "_"),
|
||||||
clean::Primitive(clean::PrimitiveType::Never) => {
|
clean::Primitive(clean::PrimitiveType::Never) => {
|
||||||
@@ -1128,7 +1128,7 @@ impl clean::Impl {
|
|||||||
self.print_type(inner_type, f, use_absolute, cx)?;
|
self.print_type(inner_type, f, use_absolute, cx)?;
|
||||||
write!(f, ">")?;
|
write!(f, ">")?;
|
||||||
} else {
|
} else {
|
||||||
write!(f, "{}<", anchor(ty.def_id(), last, cx))?;
|
write!(f, "{}<", print_anchor(ty.def_id(), last, cx))?;
|
||||||
self.print_type(inner_type, f, use_absolute, cx)?;
|
self.print_type(inner_type, f, use_absolute, cx)?;
|
||||||
write!(f, ">")?;
|
write!(f, ">")?;
|
||||||
}
|
}
|
||||||
@@ -1203,7 +1203,7 @@ impl clean::Impl {
|
|||||||
&& self.kind.is_fake_variadic()
|
&& self.kind.is_fake_variadic()
|
||||||
{
|
{
|
||||||
let ty = generics[0];
|
let ty = generics[0];
|
||||||
let wrapper = anchor(path.def_id(), path.last(), cx);
|
let wrapper = print_anchor(path.def_id(), path.last(), cx);
|
||||||
if f.alternate() {
|
if f.alternate() {
|
||||||
write!(f, "{wrapper:#}<")?;
|
write!(f, "{wrapper:#}<")?;
|
||||||
} else {
|
} else {
|
||||||
@@ -1416,7 +1416,7 @@ pub(crate) fn visibility_print_with_space(item: &clean::Item, cx: &Context<'_>)
|
|||||||
debug!("path={path:?}");
|
debug!("path={path:?}");
|
||||||
// modified from `resolved_path()` to work with `DefPathData`
|
// modified from `resolved_path()` to work with `DefPathData`
|
||||||
let last_name = path.data.last().unwrap().data.get_opt_name().unwrap();
|
let last_name = path.data.last().unwrap().data.get_opt_name().unwrap();
|
||||||
let anchor = anchor(vis_did, last_name, cx);
|
let anchor = print_anchor(vis_did, last_name, cx);
|
||||||
|
|
||||||
let mut s = "pub(in ".to_owned();
|
let mut s = "pub(in ".to_owned();
|
||||||
for seg in &path.data[..path.data.len() - 1] {
|
for seg in &path.data[..path.data.len() - 1] {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use rustc_span::edition::Edition;
|
|||||||
use rustc_span::{FileName, Symbol, sym};
|
use rustc_span::{FileName, Symbol, sym};
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
use super::print_item::{full_path, item_path, print_item};
|
use super::print_item::{full_path, print_item, print_item_path};
|
||||||
use super::sidebar::{ModuleLike, Sidebar, print_sidebar, sidebar_module_like};
|
use super::sidebar::{ModuleLike, Sidebar, print_sidebar, sidebar_module_like};
|
||||||
use super::{AllTypes, LinkFromSrc, StylePath, collect_spans_and_sources, scrape_examples_help};
|
use super::{AllTypes, LinkFromSrc, StylePath, collect_spans_and_sources, scrape_examples_help};
|
||||||
use crate::clean::types::ExternalLocation;
|
use crate::clean::types::ExternalLocation;
|
||||||
@@ -266,7 +266,7 @@ impl<'tcx> Context<'tcx> {
|
|||||||
for name in &names[..names.len() - 1] {
|
for name in &names[..names.len() - 1] {
|
||||||
write!(f, "{name}/")?;
|
write!(f, "{name}/")?;
|
||||||
}
|
}
|
||||||
write!(f, "{}", item_path(ty, names.last().unwrap().as_str()))
|
write!(f, "{}", print_item_path(ty, names.last().unwrap().as_str()))
|
||||||
});
|
});
|
||||||
match self.shared.redirections {
|
match self.shared.redirections {
|
||||||
Some(ref redirections) => {
|
Some(ref redirections) => {
|
||||||
@@ -278,7 +278,7 @@ impl<'tcx> Context<'tcx> {
|
|||||||
let _ = write!(
|
let _ = write!(
|
||||||
current_path,
|
current_path,
|
||||||
"{}",
|
"{}",
|
||||||
item_path(ty, names.last().unwrap().as_str())
|
print_item_path(ty, names.last().unwrap().as_str())
|
||||||
);
|
);
|
||||||
redirections.borrow_mut().insert(current_path, path.to_string());
|
redirections.borrow_mut().insert(current_path, path.to_string());
|
||||||
}
|
}
|
||||||
@@ -847,7 +847,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
|
|||||||
if !buf.is_empty() {
|
if !buf.is_empty() {
|
||||||
let name = item.name.as_ref().unwrap();
|
let name = item.name.as_ref().unwrap();
|
||||||
let item_type = item.type_();
|
let item_type = item.type_();
|
||||||
let file_name = item_path(item_type, name.as_str()).to_string();
|
let file_name = print_item_path(item_type, name.as_str()).to_string();
|
||||||
self.shared.ensure_dir(&self.dst)?;
|
self.shared.ensure_dir(&self.dst)?;
|
||||||
let joint_dst = self.dst.join(&file_name);
|
let joint_dst = self.dst.join(&file_name);
|
||||||
self.shared.fs.write(joint_dst, buf)?;
|
self.shared.fs.write(joint_dst, buf)?;
|
||||||
|
|||||||
@@ -413,7 +413,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
|
|||||||
|
|
||||||
match myitem.kind {
|
match myitem.kind {
|
||||||
clean::ExternCrateItem { ref src } => {
|
clean::ExternCrateItem { ref src } => {
|
||||||
use crate::html::format::anchor;
|
use crate::html::format::print_anchor;
|
||||||
|
|
||||||
match *src {
|
match *src {
|
||||||
Some(src) => {
|
Some(src) => {
|
||||||
@@ -421,7 +421,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
|
|||||||
w,
|
w,
|
||||||
"<dt><code>{}extern crate {} as {};",
|
"<dt><code>{}extern crate {} as {};",
|
||||||
visibility_print_with_space(myitem, cx),
|
visibility_print_with_space(myitem, cx),
|
||||||
anchor(myitem.item_id.expect_def_id(), src, cx),
|
print_anchor(myitem.item_id.expect_def_id(), src, cx),
|
||||||
EscapeBodyTextWithWbr(myitem.name.unwrap().as_str())
|
EscapeBodyTextWithWbr(myitem.name.unwrap().as_str())
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
@@ -430,7 +430,11 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
|
|||||||
w,
|
w,
|
||||||
"<dt><code>{}extern crate {};",
|
"<dt><code>{}extern crate {};",
|
||||||
visibility_print_with_space(myitem, cx),
|
visibility_print_with_space(myitem, cx),
|
||||||
anchor(myitem.item_id.expect_def_id(), myitem.name.unwrap(), cx)
|
print_anchor(
|
||||||
|
myitem.item_id.expect_def_id(),
|
||||||
|
myitem.name.unwrap(),
|
||||||
|
cx
|
||||||
|
)
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -439,7 +443,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
|
|||||||
|
|
||||||
clean::ImportItem(ref import) => {
|
clean::ImportItem(ref import) => {
|
||||||
let stab_tags = import.source.did.map_or_else(String::new, |import_def_id| {
|
let stab_tags = import.source.did.map_or_else(String::new, |import_def_id| {
|
||||||
extra_info_tags(tcx, myitem, item, Some(import_def_id)).to_string()
|
print_extra_info_tags(tcx, myitem, item, Some(import_def_id)).to_string()
|
||||||
});
|
});
|
||||||
|
|
||||||
let id = match import.kind {
|
let id = match import.kind {
|
||||||
@@ -497,7 +501,9 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
|
|||||||
write!(
|
write!(
|
||||||
w,
|
w,
|
||||||
"<dt>\
|
"<dt>\
|
||||||
<a class=\"{class}\" href=\"{href}\" title=\"{title}\">{name}</a>\
|
<a class=\"{class}\" href=\"{href}\" title=\"{title1} {title2}\">\
|
||||||
|
{name}\
|
||||||
|
</a>\
|
||||||
{visibility_and_hidden}\
|
{visibility_and_hidden}\
|
||||||
{unsafety_flag}\
|
{unsafety_flag}\
|
||||||
{stab_tags}\
|
{stab_tags}\
|
||||||
@@ -505,11 +511,12 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
|
|||||||
{docs_before}{docs}{docs_after}",
|
{docs_before}{docs}{docs_after}",
|
||||||
name = EscapeBodyTextWithWbr(myitem.name.unwrap().as_str()),
|
name = EscapeBodyTextWithWbr(myitem.name.unwrap().as_str()),
|
||||||
visibility_and_hidden = visibility_and_hidden,
|
visibility_and_hidden = visibility_and_hidden,
|
||||||
stab_tags = extra_info_tags(tcx, myitem, item, None),
|
stab_tags = print_extra_info_tags(tcx, myitem, item, None),
|
||||||
class = myitem.type_(),
|
class = myitem.type_(),
|
||||||
unsafety_flag = unsafety_flag,
|
unsafety_flag = unsafety_flag,
|
||||||
href = item_path(myitem.type_(), myitem.name.unwrap().as_str()),
|
href = print_item_path(myitem.type_(), myitem.name.unwrap().as_str()),
|
||||||
title = format_args!("{} {}", myitem.type_(), full_path(cx, myitem)),
|
title1 = myitem.type_(),
|
||||||
|
title2 = full_path(cx, myitem),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -524,7 +531,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
|
|||||||
|
|
||||||
/// Render the stability, deprecation and portability tags that are displayed in the item's summary
|
/// Render the stability, deprecation and portability tags that are displayed in the item's summary
|
||||||
/// at the module level.
|
/// at the module level.
|
||||||
fn extra_info_tags(
|
fn print_extra_info_tags(
|
||||||
tcx: TyCtxt<'_>,
|
tcx: TyCtxt<'_>,
|
||||||
item: &clean::Item,
|
item: &clean::Item,
|
||||||
parent: &clean::Item,
|
parent: &clean::Item,
|
||||||
@@ -639,7 +646,7 @@ fn item_function(cx: &Context<'_>, it: &clean::Item, f: &clean::Function) -> imp
|
|||||||
fn item_trait(cx: &Context<'_>, it: &clean::Item, t: &clean::Trait) -> impl fmt::Display {
|
fn item_trait(cx: &Context<'_>, it: &clean::Item, t: &clean::Trait) -> impl fmt::Display {
|
||||||
fmt::from_fn(|w| {
|
fmt::from_fn(|w| {
|
||||||
let tcx = cx.tcx();
|
let tcx = cx.tcx();
|
||||||
let bounds = bounds(&t.bounds, false, cx);
|
let bounds = print_bounds(&t.bounds, false, cx);
|
||||||
let required_types =
|
let required_types =
|
||||||
t.items.iter().filter(|m| m.is_required_associated_type()).collect::<Vec<_>>();
|
t.items.iter().filter(|m| m.is_required_associated_type()).collect::<Vec<_>>();
|
||||||
let provided_types = t.items.iter().filter(|m| m.is_associated_type()).collect::<Vec<_>>();
|
let provided_types = t.items.iter().filter(|m| m.is_associated_type()).collect::<Vec<_>>();
|
||||||
@@ -1236,7 +1243,7 @@ fn item_trait_alias(
|
|||||||
attrs = render_attributes_in_pre(it, "", cx),
|
attrs = render_attributes_in_pre(it, "", cx),
|
||||||
name = it.name.unwrap(),
|
name = it.name.unwrap(),
|
||||||
generics = t.generics.print(cx),
|
generics = t.generics.print(cx),
|
||||||
bounds = bounds(&t.bounds, true, cx),
|
bounds = print_bounds(&t.bounds, true, cx),
|
||||||
where_clause =
|
where_clause =
|
||||||
print_where_clause(&t.generics, cx, 0, Ending::NoNewline).maybe_display(),
|
print_where_clause(&t.generics, cx, 0, Ending::NoNewline).maybe_display(),
|
||||||
)
|
)
|
||||||
@@ -2185,14 +2192,18 @@ pub(super) fn full_path(cx: &Context<'_>, item: &clean::Item) -> String {
|
|||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn item_path(ty: ItemType, name: &str) -> impl Display {
|
pub(super) fn print_item_path(ty: ItemType, name: &str) -> impl Display {
|
||||||
fmt::from_fn(move |f| match ty {
|
fmt::from_fn(move |f| match ty {
|
||||||
ItemType::Module => write!(f, "{}index.html", ensure_trailing_slash(name)),
|
ItemType::Module => write!(f, "{}index.html", ensure_trailing_slash(name)),
|
||||||
_ => write!(f, "{ty}.{name}.html"),
|
_ => write!(f, "{ty}.{name}.html"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bounds(bounds: &[clean::GenericBound], trait_alias: bool, cx: &Context<'_>) -> impl Display {
|
fn print_bounds(
|
||||||
|
bounds: &[clean::GenericBound],
|
||||||
|
trait_alias: bool,
|
||||||
|
cx: &Context<'_>,
|
||||||
|
) -> impl Display {
|
||||||
(!bounds.is_empty())
|
(!bounds.is_empty())
|
||||||
.then_some(fmt::from_fn(move |f| {
|
.then_some(fmt::from_fn(move |f| {
|
||||||
let has_lots_of_bounds = bounds.len() > 2;
|
let has_lots_of_bounds = bounds.len() > 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user