[v6,8/9] dts: fix custom enum behaviour with docs
Checks
Commit Message
When building docs without any dependencies, autodoc will mock all the
packages missing from the system. Because DTS makes use of a special
enum library called aenum, autodoc fails to recognise enum inheriting
it as such and raises exceptions as a consequence.
This change extends the already in-place mechanism for type checking
that pretends that aenums are builtin enums to the API doc building
process.
Fixes: 039256daa8bf ("dts: add topology capability")
Fixes: c89d00380603 ("dts: add NIC capability support")
Signed-off-by: Luca Vizzarro <luca.vizzarro@arm.com>
Reviewed-by: Paul Szczepanek <paul.szczepanek@arm.com>
---
dts/framework/remote_session/testpmd_shell.py | 3 ++-
dts/framework/testbed_model/topology.py | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
@@ -20,10 +20,11 @@
from collections.abc import Callable, MutableSet
from dataclasses import dataclass, field
from enum import Flag, auto
+from os import environ
from pathlib import PurePath
from typing import TYPE_CHECKING, Any, ClassVar, Concatenate, ParamSpec, TypeAlias
-if TYPE_CHECKING:
+if TYPE_CHECKING or environ.get("DTS_DOC_BUILD"):
from enum import Enum as NoAliasEnum
else:
from aenum import NoAliasEnum
@@ -8,9 +8,10 @@
"""
from dataclasses import dataclass
+from os import environ
from typing import TYPE_CHECKING, Iterable
-if TYPE_CHECKING:
+if TYPE_CHECKING or environ.get("DTS_DOC_BUILD"):
from enum import Enum as NoAliasEnum
else:
from aenum import NoAliasEnum