examples: export __doc__ in example projects
This commit is contained in:
parent
e4b98408f5
commit
00ea4bccce
|
@ -1,5 +1,9 @@
|
|||
# import the contents of the Rust library into the Python extension
|
||||
# optional: include the documentation from the Rust module
|
||||
from .maturin_starter import *
|
||||
from .maturin_starter import __all__, __doc__
|
||||
|
||||
__all__ = __all__ + ["PythonClass"]
|
||||
|
||||
|
||||
class PythonClass:
|
||||
|
|
|
@ -19,6 +19,7 @@ impl ExampleClass {
|
|||
}
|
||||
}
|
||||
|
||||
/// An example module implemented in Rust using PyO3.
|
||||
#[pymodule]
|
||||
fn maturin_starter(py: Python, m: &PyModule) -> PyResult<()> {
|
||||
m.add_class::<ExampleClass>()?;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from maturin_starter import PythonClass, ExampleClass
|
||||
from maturin_starter import ExampleClass, PythonClass
|
||||
|
||||
|
||||
def test_python_class() -> None:
|
||||
|
@ -9,3 +9,11 @@ def test_python_class() -> None:
|
|||
def test_example_class() -> None:
|
||||
example = ExampleClass(value=11)
|
||||
assert example.value == 11
|
||||
|
||||
|
||||
def test_doc() -> None:
|
||||
import maturin_starter
|
||||
|
||||
assert (
|
||||
maturin_starter.__doc__ == "An example module implemented in Rust using PyO3."
|
||||
)
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
# import the contents of the Rust library into the Python extension
|
||||
# optional: include the documentation from the Rust module
|
||||
from ._setuptools_rust_starter import *
|
||||
from ._setuptools_rust_starter import __all__, __doc__
|
||||
|
||||
__all__ = __all__ + ["PythonClass"]
|
||||
|
||||
|
||||
class PythonClass:
|
||||
|
|
|
@ -19,6 +19,7 @@ impl ExampleClass {
|
|||
}
|
||||
}
|
||||
|
||||
/// An example module implemented in Rust using PyO3.
|
||||
#[pymodule]
|
||||
fn _setuptools_rust_starter(py: Python, m: &PyModule) -> PyResult<()> {
|
||||
m.add_class::<ExampleClass>()?;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from setuptools_rust_starter import PythonClass, ExampleClass
|
||||
from setuptools_rust_starter import ExampleClass, PythonClass
|
||||
|
||||
|
||||
def test_python_class() -> None:
|
||||
|
@ -9,3 +9,12 @@ def test_python_class() -> None:
|
|||
def test_example_class() -> None:
|
||||
example = ExampleClass(value=11)
|
||||
assert example.value == 11
|
||||
|
||||
|
||||
def test_doc() -> None:
|
||||
import setuptools_rust_starter
|
||||
|
||||
assert (
|
||||
setuptools_rust_starter.__doc__
|
||||
== "An example module implemented in Rust using PyO3."
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue