Skip to content

Commit

Permalink
docs: Improve formatting and linking.
Browse files Browse the repository at this point in the history
  • Loading branch information
waywardmonkeys authored and djc committed Oct 23, 2023
1 parent 889084f commit a7456f6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/draw_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl ProgressDrawTarget {
/// hidden. This is done so that piping to a file will not produce
/// useless escape codes in that file.
///
/// Will panic if refresh_rate is `0`.
/// Will panic if `refresh_rate` is `0`.
pub fn term(term: Term, refresh_rate: u8) -> Self {
Self {
kind: TargetKind::Term {
Expand Down
12 changes: 6 additions & 6 deletions src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,47 +66,47 @@ pub struct ProgressBarIter<T> {
impl<T> ProgressBarIter<T> {
/// Builder-like function for setting underlying progress bar's style.
///
/// See [ProgressBar::with_style].
/// See [`ProgressBar::with_style`].
pub fn with_style(mut self, style: ProgressStyle) -> Self {
self.progress = self.progress.with_style(style);
self
}

/// Builder-like function for setting underlying progress bar's prefix.
///
/// See [ProgressBar::with_prefix].
/// See [`ProgressBar::with_prefix`].
pub fn with_prefix(mut self, prefix: impl Into<Cow<'static, str>>) -> Self {
self.progress = self.progress.with_prefix(prefix);
self
}

/// Builder-like function for setting underlying progress bar's message.
///
/// See [ProgressBar::with_message].
/// See [`ProgressBar::with_message`].
pub fn with_message(mut self, message: impl Into<Cow<'static, str>>) -> Self {
self.progress = self.progress.with_message(message);
self
}

/// Builder-like function for setting underlying progress bar's position.
///
/// See [ProgressBar::with_position].
/// See [`ProgressBar::with_position`].
pub fn with_position(mut self, position: u64) -> Self {
self.progress = self.progress.with_position(position);
self
}

/// Builder-like function for setting underlying progress bar's elapsed time.
///
/// See [ProgressBar::with_elapsed].
/// See [`ProgressBar::with_elapsed`].
pub fn with_elapsed(mut self, elapsed: Duration) -> Self {
self.progress = self.progress.with_elapsed(elapsed);
self
}

/// Builder-like function for setting underlying progress bar's finish behavior.
///
/// See [ProgressBar::with_finish].
/// See [`ProgressBar::with_finish`].
pub fn with_finish(mut self, finish: ProgressFinish) -> Self {
self.progress = self.progress.with_finish(finish);
self
Expand Down
7 changes: 6 additions & 1 deletion src/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ impl MultiProgress {
/// Creates a new multi progress object.
///
/// Progress bars added to this object by default draw directly to stderr, and refresh
/// a maximum of 15 times a second. To change the refresh rate set the draw target to
/// a maximum of 15 times a second. To change the refresh rate [set] the [draw target] to
/// one with a different refresh rate.
///
/// [set]: MultiProgress::set_draw_target
/// [draw target]: ProgressDrawTarget
pub fn new() -> Self {
Self::default()
}
Expand All @@ -40,6 +43,8 @@ impl MultiProgress {
}

/// Sets a different draw target for the multiprogress bar.
///
/// Use [`MultiProgress::with_draw_target`] to set the draw target during creation.
pub fn set_draw_target(&self, target: ProgressDrawTarget) {
let mut state = self.state.write().unwrap();
state.draw_target.disconnect(Instant::now());
Expand Down
11 changes: 9 additions & 2 deletions src/progress_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ impl ProgressBar {
/// Creates a new progress bar with a given length
///
/// This progress bar by default draws directly to stderr, and refreshes a maximum of 15 times
/// a second. To change the refresh rate, set the draw target to one with a different refresh
/// a second. To change the refresh rate, [set] the [draw target] to one with a different refresh
/// rate.
///
/// [set]: ProgressBar::set_draw_target
/// [draw target]: ProgressDrawTarget
pub fn new(len: u64) -> Self {
Self::with_draw_target(Some(len), ProgressDrawTarget::stderr())
}
Expand Down Expand Up @@ -378,6 +381,8 @@ impl ProgressBar {
/// running [`MultiProgress::add`]) will unlink this progress bar. If you don't want this
/// behavior, call [`MultiProgress::set_draw_target`] instead.
///
/// Use [`ProgressBar::with_draw_target`] to set the draw target during creation.
///
/// [`MultiProgress`]: crate::MultiProgress
/// [`MultiProgress::add`]: crate::MultiProgress::add
/// [`MultiProgress::set_draw_target`]: crate::MultiProgress::set_draw_target
Expand All @@ -391,7 +396,7 @@ impl ProgressBar {
///
/// Useful for external code that writes to the standard output.
///
/// If the progress bar was added to a MultiProgress, it will suspend the entire MultiProgress
/// If the progress bar was added to a [`MultiProgress`], it will suspend the entire `MultiProgress`].
///
/// **Note:** The internal lock is held while `f` is executed. Other threads trying to print
/// anything on the progress bar will be blocked until `f` finishes.
Expand All @@ -404,6 +409,8 @@ impl ProgressBar {
/// println!("Log message");
/// })
/// ```
///
/// [`MultiProgress`]: crate::MultiProgress
pub fn suspend<F: FnOnce() -> R, R>(&self, f: F) -> R {
self.state().suspend(Instant::now(), f)
}
Expand Down

0 comments on commit a7456f6

Please sign in to comment.