pub enum DocStringKind {
Starlark,
Rust,
}
Expand description
Controls the formatting to use when parsing DocString
s 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
sourceimpl Clone for DocStringKind
impl Clone for DocStringKind
sourcefn clone(&self) -> DocStringKind
fn clone(&self) -> DocStringKind
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Dupe for DocStringKind
impl Dupe for DocStringKind
impl Copy for DocStringKind
Auto Trait Implementations
impl RefUnwindSafe for DocStringKind
impl Send for DocStringKind
impl Sync for DocStringKind
impl Unpin for DocStringKind
impl UnwindSafe for DocStringKind
Blanket Implementations
sourceimpl<T> AsARef<T> for T where
T: ?Sized,
impl<T> AsARef<T> for T where
T: ?Sized,
sourcefn try_as_aref(this: &T) -> Result<ARef<'_, T>, BorrowError>
fn try_as_aref(this: &T) -> Result<ARef<'_, T>, BorrowError>
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more