Skip to content

Commit d28f03f

Browse files
author
Flax Authors
committed
Merge pull request #4500 from google:nnx-fix-fiddle
PiperOrigin-RevId: 718960084
2 parents 0eeab5a + 1301362 commit d28f03f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

docs_nnx/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
sys.path.insert(0, os.path.abspath('..'))
3636
# Include local extension.
3737
sys.path.append(os.path.abspath('./_ext'))
38+
# Set environment variable to indicate that we are building the docs.
39+
os.environ['FLAX_DOC_BUILD'] = 'true'
3840

3941
# patch sphinx
4042
# -- Project information -----------------------------------------------------

flax/nnx/object.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import dataclasses
1818
import inspect
19+
import os
1920
import threading
2021
import typing as tp
2122
from abc import ABCMeta
@@ -38,6 +39,7 @@
3839

3940
G = tp.TypeVar('G', bound='Object')
4041

42+
BUILDING_DOCS = 'FLAX_DOC_BUILD' in os.environ
4143

4244
def _collect_stats(
4345
node: tp.Any, node_stats: dict[int, dict[type[Variable], SizeBytes]]
@@ -157,7 +159,9 @@ def __init_subclass__(cls) -> None:
157159
init=cls._graph_node_init, # type: ignore
158160
)
159161

160-
cls.__signature__ = inspect.signature(cls.__init__)
162+
if BUILDING_DOCS:
163+
# set correct signature for sphinx
164+
cls.__signature__ = inspect.signature(cls.__init__)
161165

162166
if not tp.TYPE_CHECKING:
163167

0 commit comments

Comments
 (0)