Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

DOC: Add __init__ documentation to class documentation #263

Merged
merged 1 commit into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@
apidoc_separate_modules = True
apidoc_extra_args = ["--module-first", "-d 1", "-T"]


# -- Options for autodoc extension -------------------------------------------
autoclass_content = "both"


# -- Options for intersphinx extension ---------------------------------------

# Example configuration for intersphinx: refer to the Python standard library.
Expand All @@ -253,3 +258,25 @@

# -- Options for versioning extension ----------------------------------------
scv_show_banner = True


# -- Special functions -------------------------------------------------------
import inspect


def autodoc_process_signature(app, what, name, obj, options, signature, return_annotation):
"""Replace the class signature by the signature from cls.__init__"""

if what == "class" and hasattr(obj, "__init__"):
try:
init_signature = inspect.signature(obj.__init__)
# Convert the Signature object to a string
return str(init_signature), return_annotation
except ValueError:
# Handle cases where `inspect.signature` fails
return signature, return_annotation
return signature, return_annotation


def setup(app):
app.connect("autodoc-process-signature", autodoc_process_signature)
2 changes: 0 additions & 2 deletions src/eddymotion/model/gpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ def __init__(
l_bounds: tuple[float, float] = BOUNDS_LAMBDA,
):
r"""
Initialize an exponential Kriging kernel.
Parameters
----------
Expand Down Expand Up @@ -370,7 +369,6 @@ def __init__(
l_bounds: tuple[float, float] = BOUNDS_LAMBDA,
):
r"""
Initialize a spherical Kriging kernel.
Parameters
----------
Expand Down
Loading