Skip to content

Minor librustdoc cleanup and refactoring. - #36903

Merged
bors merged 8 commits into
rust-lang:masterfrom
frewsxcv:typekind
Oct 4, 2016
Merged

Minor librustdoc cleanup and refactoring.#36903
bors merged 8 commits into
rust-lang:masterfrom
frewsxcv:typekind

Conversation

@frewsxcv

Copy link
Copy Markdown
Contributor

No description provided.

@rust-highfive

Copy link
Copy Markdown
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@frewsxcv

Copy link
Copy Markdown
ContributorAuthor

r? @GuillaumeGomez

@frewsxcv

Copy link
Copy Markdown
ContributorAuthor

I need a sanity check for 19f6130

Here's the new print function it will use:

pubfnpath_to_string(p:&hir::Path) -> String{
to_string(|s| s.print_path(p,false,0))
}

fnprint_path(&mutself,
path:&hir::Path,
colons_before_params:bool,
depth:usize)
-> io::Result<()>{
self.maybe_print_comment(path.span.lo)?;
letmut first = !path.global;
for segment in&path.segments[..path.segments.len() - depth]{
if first {
first = false
}else{
word(&mutself.s,"::")?
}
self.print_name(segment.name)?;
self.print_path_parameters(&segment.parameters, colons_before_params)?;
}
Ok(())
}

@jseyfriedjseyfried left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me modulo comments.

Comment threadsrc/librustdoc/clean/mod.rs Outdated
CLikeVariant
} else {
TupleVariant(struct_def.fields().iter().map(|x| x.ty.clean(cx)).collect())
impl VariantKind {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make this an implementation of Clean<VariantKind> for hir::VariantData?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d6fb0c8d6a01beab132f1df7832794401ac92a46

Comment threadsrc/librustdoc/clean/mod.rs Outdated
PatKind::Wild => "_".to_string(),
PatKind::Binding(_, ref p, _) => p.node.to_string(),
PatKind::TupleStruct(ref p, ..) | PatKind::Path(None, ref p) => path_to_string(p),
PatKind::TupleStruct(ref p, ..) | PatKind::Path(None, ref p) => p.to_string(),

@jseyfriedjseyfriedOct 2, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hir::print::State::print_path begins with self.maybe_print_comment(path.span.lo), which might actually print a comment in this case:

fnf(arg1:(),// Some comment
path::to::TupleStruct(x): path::to::TupleStruct){//^ The `name_from_pat` of this tuple struct pattern might include "// Some comment"}

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think I should add an parameter to that function to control whether the comment gets printed or just ditch that commit?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably ditch the commit to be on the safe side since I don't understand the pretty printer, especially in edge cases (e.g. it might emit newlines and indents in long patterns).

Comment threadsrc/librustdoc/clean/mod.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this can fit on one line

Comment threadsrc/librustdoc/clean/mod.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this can fit on one line

Comment threadsrc/librustdoc/html/render.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this would be easier for me to read:

iflet clean::VariantItem(Variant{kind:VariantKind::Struct(ref s)}) =
variant.inner{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or

iflet clean::VariantItem(Variant{kind:VariantKind::Struct(ref s)}) = variant.inner{

@frewsxcv

Copy link
Copy Markdown
ContributorAuthor

Latest force push removes 19f6130 and makes the suggested style changes.

@jseyfried

Copy link
Copy Markdown
Contributor

Thanks! @bors r+

@bors

bors commented Oct 3, 2016

Copy link
Copy Markdown
Collaborator

📌 Commit 35d214a has been approved by jseyfried

Manishearth added a commit to Manishearth/rust that referenced this pull request Oct 4, 2016
bors added a commit that referenced this pull request Oct 4, 2016
Rollup of 12 pull requests
- Successful merges: #36798, #36878, #36902, #36903, #36908, #36916, #36917, #36921, #36928, #36938, #36941, #36951
- Failed merges:
@bors
bors merged commit 35d214a into rust-lang:masterOct 4, 2016
critiqjo pushed a commit to critiqjo/rustdoc that referenced this pull request Dec 16, 2016
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@frewsxcv@rust-highfive@jseyfried@bors@steveklabnik@GuillaumeGomez