Skip to content

Commit

Permalink
DOC: hide sympified attributes from expression classes
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed May 20, 2024
1 parent 0b71c67 commit 512dc5f
Showing 1 changed file with 46 additions and 12 deletions.
58 changes: 46 additions & 12 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from __future__ import annotations

import importlib
import inspect
import os
import sys
from dataclasses import is_dataclass

from sphinx_api_relink.helpers import (
get_branch_name,
Expand All @@ -12,9 +15,51 @@
set_intersphinx_version_remapping,
)

from ampform.sympy._decorator import get_sympy_fields # noqa: PLC2701

sys.path.insert(0, os.path.abspath("."))
from _extend_docstrings import extend_docstrings # noqa: PLC2701


def _get_excluded_members() -> list[str]:
default_exclusions = {
"as_explicit",
"default_assumptions",
"doit",
"evaluate",
"is_commutative",
"is_extended_real",
"items",
"keys",
"precedence",
"values",
}
for cls in [
*_get_dataclasses_recursive("ampform"),
]:
fields = get_sympy_fields(cls)
arg_names = {f.name for f in fields}
default_exclusions.update(arg_names)
return sorted(default_exclusions)


def _get_dataclasses_recursive(module_name: str) -> list[type]:
module = importlib.import_module(module_name)
dataclass_list = _get_dataclasses(module)
for _, submodule in inspect.getmembers(module, inspect.ismodule):
if submodule.__name__.startswith(module_name):
dataclass_list.extend(_get_dataclasses_recursive(submodule.__name__))
return dataclass_list


def _get_dataclasses(module):
dataclass_list = []
for _, obj in inspect.getmembers(module):
if inspect.isclass(obj) and is_dataclass(obj):
dataclass_list.append(obj)
return dataclass_list


extend_docstrings()
set_intersphinx_version_remapping({
"ipython": {
Expand Down Expand Up @@ -85,18 +130,7 @@
}
author = "Common Partial Wave Analysis"
autodoc_default_options = {
"exclude-members": ", ".join([
"as_explicit",
"default_assumptions",
"doit",
"evaluate",
"is_commutative",
"is_extended_real",
"items",
"keys",
"precedence",
"values",
]),
"exclude-members": ", ".join(_get_excluded_members()),
"members": True,
"undoc-members": True,
"show-inheritance": True,
Expand Down

0 comments on commit 512dc5f

Please sign in to comment.