Expand description
Documents a single function.
Fields
docs: Option<DocString>
Documentation for the function. If parsed, this should generally be the first statement of a function’s body if that statement is a string literal. Any sections like “Args:”, “Returns”, etc are kept intact. It is up to the consumer to remove these sections if they are present.
params: Vec<Param>
The parameters that this function takes. Docs for these parameters should generally be extracted from the main docstring’s details.
ret: Return
Details about what this function returns.
Implementations
sourceimpl Function
impl Function
sourcepub fn from_docstring<F: FnOnce(HashMap<String, Option<DocString>>) -> Vec<Param>>(
kind: DocStringKind,
params_producer: F,
return_type: Option<Type>,
raw_docstring: Option<&str>
) -> Self
pub fn from_docstring<F: FnOnce(HashMap<String, Option<DocString>>) -> Vec<Param>>(
kind: DocStringKind,
params_producer: F,
return_type: Option<Type>,
raw_docstring: Option<&str>
) -> Self
Parses function documentation out of a docstring
Arguments
kind
: The kind of docstring. This determines the formatting that is parsed.params_producer
: A function that takes a mapping of parameter names -> docstrings, and creates a vec of params. These are then returned in the mainFunction
object.return_type
: The return type. This is pulled from typing info / directly from users, so it cannot be inferred generically.raw_docstring
: The raw docstring to be parsed and potentially modified, removing the sections detailing arguments and return values. The format is determined bykind
.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Function
impl<'de> Deserialize<'de> for Function
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Function
Auto Trait Implementations
impl RefUnwindSafe for Function
impl Send for Function
impl Sync for Function
impl Unpin for Function
impl UnwindSafe for Function
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> Serialize for T where
T: Serialize + ?Sized,
impl<T> Serialize for T where
T: Serialize + ?Sized,
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>
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