rustdoc: format fns like format rfc 39
This commit is contained in:
parent
f77ee2ff0f
commit
8206d0c54e
@ -945,6 +945,10 @@ impl<'a> fmt::Display for Method<'a> {
|
|||||||
let mut args = String::new();
|
let mut args = String::new();
|
||||||
let mut args_plain = String::new();
|
let mut args_plain = String::new();
|
||||||
for (i, input) in decl.inputs.values.iter().enumerate() {
|
for (i, input) in decl.inputs.values.iter().enumerate() {
|
||||||
|
if i == 0 {
|
||||||
|
args.push_str("<br>");
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(selfty) = input.to_self() {
|
if let Some(selfty) = input.to_self() {
|
||||||
match selfty {
|
match selfty {
|
||||||
clean::SelfValue => {
|
clean::SelfValue => {
|
||||||
@ -986,8 +990,8 @@ impl<'a> fmt::Display for Method<'a> {
|
|||||||
args_plain.push_str(&format!("{:#}", input.type_));
|
args_plain.push_str(&format!("{:#}", input.type_));
|
||||||
}
|
}
|
||||||
if i + 1 < decl.inputs.values.len() {
|
if i + 1 < decl.inputs.values.len() {
|
||||||
args.push_str(",");
|
args.push(',');
|
||||||
args_plain.push_str(",");
|
args_plain.push(',');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1003,27 +1007,19 @@ impl<'a> fmt::Display for Method<'a> {
|
|||||||
format!("{}", decl.output)
|
format!("{}", decl.output)
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut output: String;
|
|
||||||
let plain: String;
|
|
||||||
let pad = repeat(" ").take(indent).collect::<String>();
|
let pad = repeat(" ").take(indent).collect::<String>();
|
||||||
if arrow.is_empty() {
|
let plain = format!("{pad}({args}){arrow}",
|
||||||
output = format!("({})", args);
|
pad = pad,
|
||||||
plain = format!("{}({})", pad, args_plain);
|
args = args_plain,
|
||||||
} else {
|
arrow = arrow_plain);
|
||||||
output = format!("({args})<br>{arrow}", args = args, arrow = arrow);
|
|
||||||
plain = format!("{pad}({args}){arrow}",
|
|
||||||
pad = pad,
|
|
||||||
args = args_plain,
|
|
||||||
arrow = arrow_plain);
|
|
||||||
}
|
|
||||||
|
|
||||||
if plain.len() > 80 {
|
let output = if plain.len() > 80 {
|
||||||
let pad = repeat(" ").take(indent).collect::<String>();
|
let pad = "<br> ";
|
||||||
let pad = format!("<br>{}", pad);
|
format!("({args}<br>){arrow}", args = args.replace("<br>", pad), arrow = arrow)
|
||||||
output = output.replace("<br>", &pad);
|
|
||||||
} else {
|
} else {
|
||||||
output = output.replace("<br>", "");
|
format!("({args}){arrow}", args = args.replace("<br>", ""), arrow = arrow)
|
||||||
}
|
};
|
||||||
|
|
||||||
if f.alternate() {
|
if f.alternate() {
|
||||||
write!(f, "{}", output.replace("<br>", "\n"))
|
write!(f, "{}", output.replace("<br>", "\n"))
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user