Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write the "passes" chapter of the rustdoc book #43790

Merged
merged 1 commit into from
Aug 15, 2017

Conversation

steveklabnik
Copy link
Member

cc #42322

r? @rust-lang/docs

Copy link
Member

@QuietMisdreavus QuietMisdreavus left a comment

Choose a reason for hiding this comment

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

When #43348 is merged, will you want to add its propagate-doc-cfg pass? It relies on the #[doc(cfg)] attribute form, which will be behind a feature flag when it's first released.

space.

It takes this indentation amount from the first line. For example:
Copy link
Member

@QuietMisdreavus QuietMisdreavus Aug 10, 2017

Choose a reason for hiding this comment

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

In my experience it takes this indentation amount from the smallest indentation it sees over the whole docstring. This is the entire reason #42760 exists. Putting an example with differently-indented lines like below, but with the order reversed, will demonstrate this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I took the examples from the tests. Maybe we should add more tests for those cases.

Copy link
Member

Choose a reason for hiding this comment

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

What it seems to do is take the smallest indent from the whole document but it will ignore the indent on the first line if the second line isn't entirely white-space. It also always removes white-space from the beginning of the first line and doesn't remove anything from lines which are entirely white-space. I'm sure the logic can be improved because there are also #38173 and #38739 which I think are also caused by this.

Copy link
Member Author

Choose a reason for hiding this comment

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

should we maybe just be more vague about this, rather than going into this level of detail? That way we can tweak it in the future.

@steveklabnik
Copy link
Member Author

When #43348 is merged, will you want to add its propagate-doc-cfg pass? It relies on the #[doc(cfg)] attribute form, which will be behind a feature flag when it's first released.

Hmmm how to handle unstable things is.... something I haven't though of yet.

```text
line1
line2
Copy link
Member

Choose a reason for hiding this comment

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

this should be:

```text
line1
line2
```

Copy link
Member Author

@steveklabnik steveklabnik Aug 11, 2017

Choose a reason for hiding this comment

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

not according to the tests, unless i made a mistake

Copy link
Member

Choose a reason for hiding this comment

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

#[test]
fn should_ignore_first_line_indent() {
// The first line of the first paragraph may not be indented as
// far due to the way the doc string was written:
//
// #[doc = "Start way over here
// and continue here"]
let s = "line1\n line2".to_string();
let r = unindent(&s);
assert_eq!(r, "line1\nline2");
}

## `collapse-docs`

With this pass, multiple `#[doc]` attributes are convered into one single
Copy link
Member

Choose a reason for hiding this comment

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

*converted

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

space.

It takes this indentation amount from the first line. For example:
Copy link
Member

Choose a reason for hiding this comment

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

What it seems to do is take the smallest indent from the whole document but it will ignore the indent on the first line if the second line isn't entirely white-space. It also always removes white-space from the beginning of the first line and doesn't remove anything from lines which are entirely white-space. I'm sure the logic can be improved because there are also #38173 and #38739 which I think are also caused by this.

```text
line1
line2
Copy link
Member

Choose a reason for hiding this comment

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

Actually, this one would also be:

```text
line1
line2
```

However

```text
  line1

      line2
```

becomes:

```text
line1

    line2
```

Whether the second line is entirely white-space or not makes a difference.

@shepmaster shepmaster added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 11, 2017
@steveklabnik
Copy link
Member Author

I've gone with #43790 (comment), this should be ready for review


* [`--passes`](command-line-arguments.html#--passes-add-more-rustdoc-passes)
* [`--no-defaults`](ommand-line-arguments.html#--no-defaults-dont-run-default-passes)
Copy link
Contributor

Choose a reason for hiding this comment

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

typo in link (missing c)

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed, thanks

@QuietMisdreavus
Copy link
Member

@bors r+ rollup

❤️

@bors
Copy link
Contributor

bors commented Aug 14, 2017

📌 Commit 7a5ee17 has been approved by QuietMisdreavus

space.

The exact rules are left under-specified so that we can fix issues that we find.
Copy link
Member

Choose a reason for hiding this comment

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

This line confuses me. Is this pass anything more complex than removing a single space if it exists? Are we not able to fix issues if we specify the rules?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, just saw this was approved. Don't block this PR on my comment here, but feel free to answer if there's an answer

Copy link
Member

Choose a reason for hiding this comment

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

The current semantics are a bit awkward to specify completely, see the thread at #43790 (comment) for a brief summary. I think the thought for stating this was that if we describe everything it does then it would create a situation where either we get penned in by the current implementation, or the docs inevitably get out of sync when we patch around various issues.

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Aug 15, 2017
…tMisdreavus

Write the "passes" chapter of the rustdoc book

cc rust-lang#42322

r? @rust-lang/docs
bors added a commit that referenced this pull request Aug 15, 2017
Rollup of 6 pull requests

- Successful merges: #43756, #43790, #43846, #43848, #43862, #43868
- Failed merges:
@bors bors merged commit 7a5ee17 into rust-lang:master Aug 15, 2017
bors added a commit that referenced this pull request Aug 15, 2017
Ship the rustdoc book

Fixes #42322, as it's the last step.

Blocked on #43790, though they will not conflict.

r? @rust-lang/docs
@steveklabnik steveklabnik deleted the rustdoc-passes branch October 25, 2017 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants