Struct starlark::docs::DocFunction
source · pub struct DocFunction {
pub docs: Option<DocString>,
pub params: Vec<DocParam>,
pub ret: DocReturn,
pub as_type: Option<Ty>,
}
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<DocParam>
The parameters that this function takes. Docs for these parameters should generally be extracted from the main docstring’s details.
ret: DocReturn
Details about what this function returns.
as_type: Option<Ty>
Does this function act as type?
Implementations§
source§impl DocFunction
impl DocFunction
sourcepub fn find_param_with_name(&self, param_name: &str) -> Option<&DocParam>
pub fn find_param_with_name(&self, param_name: &str) -> Option<&DocParam>
Used by LSP.
sourcepub fn from_docstring(
kind: DocStringKind,
params: Vec<DocParam>,
return_type: Ty,
raw_docstring: Option<&str>,
as_type: Option<Ty>
) -> Self
pub fn from_docstring( kind: DocStringKind, params: Vec<DocParam>, return_type: Ty, raw_docstring: Option<&str>, as_type: Option<Ty> ) -> Self
Parses function documentation out of a docstring
§Arguments
kind
: The kind of docstring. This determines the formatting that is parsed.params
: The parameters of the function.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§
source§impl Allocative for DocFunction
impl Allocative for DocFunction
source§impl Clone for DocFunction
impl Clone for DocFunction
source§fn clone(&self) -> DocFunction
fn clone(&self) -> DocFunction
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for DocFunction
impl Debug for DocFunction
source§impl Default for DocFunction
impl Default for DocFunction
source§fn default() -> DocFunction
fn default() -> DocFunction
Returns the “default value” for a type. Read more
source§impl PartialEq for DocFunction
impl PartialEq for DocFunction
source§fn eq(&self, other: &DocFunction) -> bool
fn eq(&self, other: &DocFunction) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for DocFunction
impl Serialize for DocFunction
impl StructuralPartialEq for DocFunction
Auto Trait Implementations§
impl !RefUnwindSafe for DocFunction
impl Send for DocFunction
impl Sync for DocFunction
impl Unpin for DocFunction
impl !UnwindSafe for DocFunction
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more