pub enum DocStringKind {
    Starlark,
    Rust,
}
Expand description

Controls the formatting to use when parsing DocStrings from raw docstrings

Variants

Starlark

Docstrings provided by users in starlark files, following python-y documentation style.

For functions, they are the piece in """ that come right after the def foo(): line, and they have sections for additional details. An example from a starlark file might be:

""" Module level docs here """

def some_function(val: "string") -> "string":
    """ This function takes a string and returns it.

    This is where an explanation might go, but I have none

    Args:
        val: This is the value that gets returned

    Returns:
        The original value, because identity functions are fun.

Rust

Docstrings used with #[starlark_module] in rust.

These are the documentation strings prefixed by /// (like these docs) on #[starlark_module], and the functions / attributes within it. It supports a section # Arguments, and # Returns, and removes some lines from code blocks that are valid for rustdoc, but not useful for people using these functions via starlark. An example might be something like:

/// These are where the module / object level docs go
#[starlark_module]
fn add_some_value(builder: &mut GlobalsBuilder) {
    /// attr1 is an attribute that does nothing interesting.
    #[attribute]
    fn attr1(_this: Value<'v>) -> String {
        Ok("attr1".to_owned())
    }
    /// Copies a string
    ///
    /// This is where details would be, if this were
    /// a more interesting function.
    ///
    /// # Arguments
    /// * `s`: This is string that is returned.
    ///
    /// # Returns
    /// The a copy of the original string.
    fn copy_string(s: &str) -> String {
        Ok(s.to_owned())
    }
}

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Get an ARef pointing at this type.

Try and get an ARef pointing at this type. Returns an Err if the type Self is a RefCell which is already mutably borrowed. Read more

Return the underlying RefCell if Self is one, otherwise None.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Convert between two equal types.

Convert between references to two equal types.

Convert between mutable references to two equal types.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.