Skip to content

Commit

Permalink
Merge pull request #840 from gwenn/doc_link
Browse files Browse the repository at this point in the history
Use rustdoc links
  • Loading branch information
gwenn authored Jan 19, 2025
2 parents 8cc8c68 + 936c39a commit ad276dd
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ pub fn extract_word(
}
}

/// Returns the longest common prefix among all `Candidate::replacement()`s.
/// Returns the longest common prefix among all [`Candidate::replacement()`]s.
pub fn longest_common_prefix<C: Candidate>(candidates: &[C]) -> Option<&str> {
if candidates.is_empty() {
return None;
Expand Down
16 changes: 8 additions & 8 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,25 @@ impl Config {

/// Completion behaviour.
///
/// By default, `CompletionType::Circular`.
/// By default, [`CompletionType::Circular`].
#[must_use]
pub fn completion_type(&self) -> CompletionType {
self.completion_type
}

/// When listing completion alternatives, only display
/// one screen of possibilities at a time (used for `CompletionType::List`
/// one screen of possibilities at a time (used for [`CompletionType::List`]
/// mode).
#[must_use]
pub fn completion_prompt_limit(&self) -> usize {
self.completion_prompt_limit
}

/// Duration (milliseconds) Rustyline will wait for a character when
/// reading an ambiguous key sequence (used for `EditMode::Vi` mode on unix
/// platform).
/// reading an ambiguous key sequence (used for [`EditMode::Vi`] mode on
/// unix platform).
///
/// By default, no timeout (-1) or 500ms if `EditMode::Vi` is activated.
/// By default, no timeout (-1) or 500ms if [`EditMode::Vi`] is activated.
#[must_use]
pub fn keyseq_timeout(&self) -> Option<u16> {
self.keyseq_timeout
Expand Down Expand Up @@ -329,7 +329,7 @@ pub struct Builder {
}

impl Builder {
/// Returns a `Config` builder.
/// Returns a [`Config`] builder.
#[must_use]
pub fn new() -> Self {
Self {
Expand Down Expand Up @@ -474,7 +474,7 @@ impl Builder {
self
}

/// Builds a `Config` with the settings specified so far.
/// Builds a [`Config`] with the settings specified so far.
#[must_use]
pub fn build(self) -> Config {
self.p
Expand All @@ -487,7 +487,7 @@ impl Configurer for Builder {
}
}

/// Trait for component that holds a `Config`.
/// Trait for component that holds a [`Config`].
pub trait Configurer {
/// `Config` accessor.
fn config_mut(&mut self) -> &mut Config;
Expand Down
5 changes: 3 additions & 2 deletions src/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use crate::config::CompletionType;
use std::borrow::Cow::{self, Borrowed, Owned};
use std::cell::Cell;

/// Describe which kind of action has been triggering the call to `Highlighter`.
/// Describe which kind of action has been triggering the call to
/// [`Highlighter`].
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum CmdKind {
/// Cursor moved
Expand Down Expand Up @@ -48,7 +49,7 @@ pub trait Highlighter {
/// Takes the completion `candidate` and
/// returns the highlighted version (with ANSI color).
///
/// Currently, used only with `CompletionType::List`.
/// Currently, used only with [`CompletionType::List`].
fn highlight_candidate<'c>(
&self,
candidate: &'c str, // FIXME should be Completer::Candidate
Expand Down
12 changes: 6 additions & 6 deletions src/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ impl MemHistory {
}

/// Customized constructor with:
/// - `Config::max_history_size()`,
/// - `Config::history_ignore_space()`,
/// - `Config::history_duplicates()`.
/// - [`Config::max_history_size()`],
/// - [`Config::history_ignore_space()`],
/// - [`Config::history_duplicates()`].
#[must_use]
pub fn with_config(config: Config) -> Self {
Self {
Expand Down Expand Up @@ -473,9 +473,9 @@ impl FileHistory {
}

/// Customized constructor with:
/// - `Config::max_history_size()`,
/// - `Config::history_ignore_space()`,
/// - `Config::history_duplicates()`.
/// - [`Config::max_history_size()`],
/// - [`Config::history_ignore_space()`],
/// - [`Config::history_duplicates()`].
#[must_use]
pub fn with_config(config: Config) -> Self {
Self {
Expand Down
7 changes: 4 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,8 @@ impl<H: Helper, I: History> Editor<H, I> {

/// This method will read a line from STDIN and will display a `prompt`.
///
/// `prompt` should not be styled (in case the terminal doesn't support ANSI) directly: use `Highlighter::highlight_prompt` instead.
/// `prompt` should not be styled (in case the terminal doesn't support
/// ANSI) directly: use [`Highlighter::highlight_prompt`] instead.
///
/// It uses terminal-style interaction if `stdin` is connected to a
/// terminal.
Expand All @@ -641,8 +642,8 @@ impl<H: Helper, I: History> Editor<H, I> {
self.readline_with(prompt, None)
}

/// This function behaves in the exact same manner as `readline`, except
/// that it pre-populates the input area.
/// This function behaves in the exact same manner as [`Editor::readline`],
/// except that it pre-populates the input area.
///
/// The text that resides in the input area is given as a 2-tuple.
/// The string on the left of the tuple is what will appear to the left of
Expand Down
6 changes: 3 additions & 3 deletions src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl<'i> ValidationContext<'i> {
///
/// Rustyline uses the method provided by this trait to decide whether hitting
/// the enter key will end the current editing session and return the current
/// line buffer to the caller of `Editor::readline` or variants.
/// line buffer to the caller of [`crate::Editor::readline`] or variants.
pub trait Validator {
/// Takes the currently edited `input` and returns a
/// `ValidationResult` indicating whether it is valid or not along
Expand All @@ -62,8 +62,8 @@ pub trait Validator {
/// delimiters are fully balanced.
///
/// If you implement more complex validation checks it's probably
/// a good idea to also implement a `Hinter` to provide feedback
/// about what is invalid.
/// a good idea to also implement a [`crate::hint::Hinter`] to provide
/// feedback about what is invalid.
///
/// For auto-correction like a missing closing quote or to reject invalid
/// char while typing, the input will be mutable (TODO).
Expand Down

0 comments on commit ad276dd

Please sign in to comment.