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 MethodsBuilder) {
    /// attr1 is an attribute that does nothing interesting.
    #[starlark(attribute)]
    fn attr1<'v>(this: Value<'v>) -> anyhow::Result<String> {
        let _ = this;
        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<'v>(this: Value<'v>, s: &str) -> anyhow::Result<String> {
        let _ = this;
        Ok(s.to_owned())
    }
}

Trait Implementations§

source§

impl Clone for DocStringKind

source§

fn clone(&self) -> DocStringKind

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Dupe for DocStringKind

source§

fn dupe(&self) -> Self

source§

impl Copy for DocStringKind

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToAst for T

source§

fn ast(self, begin: usize, end: usize) -> Spanned<Self>

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.