Skip to content

Commit

Permalink
Removed docs on members
Browse files Browse the repository at this point in the history
  • Loading branch information
yamoling committed Feb 19, 2025
1 parent c8226d0 commit ad4903c
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 19 deletions.
2 changes: 0 additions & 2 deletions examples/pure/pure.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ class Number(Enum):

@property
def is_float(self) -> builtins.bool:
"""Whether the number is a float."""
...

@property
def is_integer(self) -> builtins.bool:
"""Whether the number is an integer."""
...

def ahash_dict() -> builtins.dict[builtins.str, builtins.int]: ...
Expand Down
11 changes: 0 additions & 11 deletions pyo3-stub-gen/src/generate/member.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use itertools::Itertools;

use crate::{generate::*, type_info::*, TypeInfo};
use std::{
collections::HashSet,
Expand All @@ -12,7 +10,6 @@ pub struct MemberDef {
pub is_property: bool,
pub name: &'static str,
pub r#type: TypeInfo,
pub doc: &'static str,
}

impl Import for MemberDef {
Expand All @@ -27,27 +24,19 @@ impl From<&MemberInfo> for MemberDef {
is_property: false,
name: info.name,
r#type: (info.r#type)(),
doc: info.doc,
}
}
}

impl fmt::Display for MemberDef {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let indent = indent();
let doc = self.doc.split("\n").join(&format!("\n{indent}"));
if self.is_property {
writeln!(f, "{indent}@property")?;
writeln!(f, "{indent}def {}(self) -> {}:", self.name, self.r#type)?;
if !doc.is_empty() {
writeln!(f, r#"{indent} """{doc}""""#)?;
}
writeln!(f, "{indent} ...")
} else {
writeln!(f, "{indent}{}: {}", self.name, self.r#type)?;
if !doc.is_empty() {
writeln!(f, r#"{indent}"""{doc}""""#)?;
}
Ok(())
}
}
Expand Down
2 changes: 0 additions & 2 deletions pyo3-stub-gen/src/generate/stub_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ impl StubInfoBuilder {
is_property: false,
name: getter.name,
r#type: (getter.r#type)(),
doc: getter.doc,
});
}
for method in info.methods {
Expand All @@ -146,7 +145,6 @@ impl StubInfoBuilder {
is_property: true,
name: getter.name,
r#type: (getter.r#type)(),
doc: getter.doc,
});
}
for method in info.methods {
Expand Down
6 changes: 2 additions & 4 deletions pyo3-stub-gen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
//! MemberInfo {
//! name: "name",
//! r#type: <String as ::pyo3_stub_gen::PyStubType>::type_output,
//! doc: "Name docstring",
//! doc: "",
//! },
//! MemberInfo {
//! name: "description",
//! r#type: <Option<String> as ::pyo3_stub_gen::PyStubType>::type_output,
//! doc: "Description docstring",
//! doc: "",
//! },
//! ],
//! doc: "Docstring used in Python",
Expand All @@ -61,9 +61,7 @@
//! Docstring used in Python
//! """
//! name: str
//! """Name docstring"""
//! description: Optional[str]
//! """Description docstring"""
//! ```
//!
//! We want to generate this [type_info::PyClassInfo] section automatically from `MyClass` Rust struct definition.
Expand Down

0 comments on commit ad4903c

Please sign in to comment.