mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:47 +00:00
[pydoclint
] Implement docstring-missing-exception
and docstring-extraneous-exception
(DOC501
, DOC502
) (#11471)
## Summary These are the first rules implemented as part of #458, but I plan to implement more. Specifically, this implements `docstring-missing-exception` which checks for raised exceptions not documented in the docstring, and `docstring-extraneous-exception` which checks for exceptions in the docstring not present in the body. ## Test Plan Test fixtures added for both google and numpy style.
This commit is contained in:
parent
53b84ab054
commit
4bc73dd87e
21 changed files with 1161 additions and 67 deletions
|
@ -163,6 +163,7 @@ impl SectionKind {
|
|||
pub(crate) struct SectionContexts<'a> {
|
||||
contexts: Vec<SectionContextData>,
|
||||
docstring: &'a Docstring<'a>,
|
||||
style: SectionStyle,
|
||||
}
|
||||
|
||||
impl<'a> SectionContexts<'a> {
|
||||
|
@ -221,9 +222,14 @@ impl<'a> SectionContexts<'a> {
|
|||
Self {
|
||||
contexts,
|
||||
docstring,
|
||||
style,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn style(&self) -> SectionStyle {
|
||||
self.style
|
||||
}
|
||||
|
||||
pub(crate) fn len(&self) -> usize {
|
||||
self.contexts.len()
|
||||
}
|
||||
|
@ -396,7 +402,7 @@ impl<'a> SectionContext<'a> {
|
|||
NewlineWithTrailingNewline::with_offset(lines, self.offset() + self.data.summary_full_end)
|
||||
}
|
||||
|
||||
fn following_lines_str(&self) -> &'a str {
|
||||
pub(crate) fn following_lines_str(&self) -> &'a str {
|
||||
&self.docstring_body.as_str()[self.following_range_relative()]
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue