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

Improve std::process module docs #45295

Merged
merged 6 commits into from Oct 29, 2017
Merged

Improve std::process module docs #45295

merged 6 commits into from Oct 29, 2017

Conversation

Technius
Copy link
Contributor

Addresses part of #29370

I've changed the first cat example to a "Hello World" example involving echo, and I've also added another example showing how to pipe output. I'm still working on the module-level description.

For now, I'd like feedback on the examples.

r? @steveklabnik

@rust-highfive
Copy link
Collaborator

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.

//! let mut child = Command::new("/bin/cat")
//! .arg("file.txt")
//! // Note that by default, the output of the command will be sent to stdout
//! let child = Command::new("echo")
Copy link
Member

Choose a reason for hiding this comment

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

child needs to be mut.

[01:19:37] failures:
[01:19:37] 
[01:19:37] ---- process.rs - process (line 21) stdout ----
[01:19:37] 	error[E0596]: cannot borrow immutable local variable `child` as mutable
[01:19:37]   --> process.rs:12:13
[01:19:37]    |
[01:19:37] 7  | let child = Command::new("echo")
[01:19:37]    |     ----- consider changing this to `mut child`
[01:19:37] ...
[01:19:37] 12 | let ecode = child.wait()
[01:19:37]    |             ^^^^^ cannot borrow mutably
[01:19:37] 
[01:19:37] thread 'rustc' panicked at 'couldn't compile the test', /checkout/src/librustdoc/test.rs:283:12
[01:19:37] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:19:37] 
[01:19:37] 
[01:19:37] failures:
[01:19:37]     process.rs - process (line 21)
[01:19:37] 
[01:19:37] test result: FAILED. 877 passed; 1 failed; 10 ignored; 0 measured; 0 filtered out

@kennytm kennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 15, 2017
Copy link
Member

@steveklabnik steveklabnik left a comment

Choose a reason for hiding this comment

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

This looks good, but a few questions. Also travis is failing for some reason.

//!
//! TODO
//!
//! # Examples
Copy link
Member

Choose a reason for hiding this comment

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

why is this moved down? The above is still an example 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! I planned on having a brief overview of the entire module first and then show some additional examples. Maybe I should rename the "Example" section to "Additional Examples"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just figured out that I could just fold the examples into the section describing Stdio. I'll be updating the PR soon.

//!
//! # Handling I/O
//!
//! TODO
Copy link
Member

Choose a reason for hiding this comment

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

do you intend on filling this out in this PR? If not, I'd remove this section.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I plan on adding a few demonstrations of Stdio here. Incidentally, the TODO is causing travis to fail.

@Technius Technius changed the title [WIP] Improve std::process module docs Improve std::process module docs Oct 18, 2017
@Technius
Copy link
Contributor Author

I think I've covered almost everything. If there's something else that I should mention in the docs, let me know!

@carols10cents
Copy link
Member

Looks like this is back in @steveklabnik's court-- I think he's at conferences this week though :)

@steveklabnik
Copy link
Member

Yup, sorry that it took me some time. Looks great, thanks a ton!

@bors: r+ rollup

@bors
Copy link
Contributor

bors commented Oct 27, 2017

📌 Commit 3566832 has been approved by steveklabnik

@kennytm kennytm added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 27, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Oct 28, 2017
Improve std::process module docs

Addresses part of rust-lang#29370

I've changed the first `cat` example to a "Hello World" example involving echo, and I've also added another example showing how to pipe output. I'm still working on the module-level description.

For now, I'd like feedback on the examples.

r? @steveklabnik
@kennytm
Copy link
Member

kennytm commented Oct 28, 2017

@bors r-

The example failed to run on Windows.

[01:31:48] ---- process.rs - process (line 76) stdout ----
[01:31:48] 	thread 'rustc' panicked at 'test executable failed:
[01:31:48] 
[01:31:48] thread 'main' panicked at 'failed to execute child: Error { repr: Os { code: 2, message: "The system cannot find the file specified." } }', src\libcore\result.rs:906:4
[01:31:48] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:31:48] 
[01:31:48] ', src\librustdoc\test.rs:323:16
[01:31:48] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:31:48] 
[01:31:48] 
[01:31:48] failures:
[01:31:48]     process.rs - process (line 76)

//! Note that [`ChildStderr`] and [`ChildStdout`] implement [`Write`] and
//! [`ChildStdin`] implements [`Read`]:
//!
//! ```
Copy link
Member

Choose a reason for hiding this comment

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

Windows does not have /bin/cat. Could you keep it ```no_run or change to another program for this example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added no_run to the example involving cat and the example involving sed.

@kennytm kennytm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 28, 2017
@kennytm
Copy link
Member

kennytm commented Oct 29, 2017

@bors r=steveklabnik

@bors
Copy link
Contributor

bors commented Oct 29, 2017

📌 Commit 84ab6ae has been approved by steveklabnik

@bors
Copy link
Contributor

bors commented Oct 29, 2017

⌛ Testing commit 84ab6ae with merge 7d475a2...

bors added a commit that referenced this pull request Oct 29, 2017
Improve std::process module docs

Addresses part of #29370

I've changed the first `cat` example to a "Hello World" example involving echo, and I've also added another example showing how to pipe output. I'm still working on the module-level description.

For now, I'd like feedback on the examples.

r? @steveklabnik
@kennytm kennytm added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 29, 2017
@bors
Copy link
Contributor

bors commented Oct 29, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: steveklabnik
Pushing 7d475a2 to master...

@bors bors merged commit 84ab6ae into rust-lang:master Oct 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants