Skip to content

Commit ded5052

Browse files
committedJul 4, 2021
custom extension does not reliably fix ref warnings
1 parent bab8e98 commit ded5052

File tree

5 files changed

+23
-58
lines changed

5 files changed

+23
-58
lines changed
 

‎docs/source/_exts/only_warn_on_broken_internal_refs.py

-50
This file was deleted.

‎docs/source/conf.py

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
"patched_html_translator",
6666
"widget_example",
6767
"build_custom_js",
68-
"only_warn_on_broken_internal_refs",
6968
]
7069

7170
# Add any paths that contain templates here, relative to this directory.

‎noxfile.py

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ def docs(session: Session) -> None:
5858
"python",
5959
"scripts/live_docs.py",
6060
"--open-browser",
61+
# watch python source too
62+
"--watch=src/idom",
6163
# for some reason this matches absolute paths
6264
"--ignore=**/auto/*",
6365
"--ignore=**/_static/custom.js",

‎src/idom/core/vdom.py

+20-6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from __future__ import annotations
77

8+
import inspect
89
import logging
910
from typing import Any, Iterable, List, Mapping, Optional, Sequence, Tuple, Union
1011

@@ -197,13 +198,16 @@ def constructor(
197198
raise TypeError(f"{tag!r} nodes cannot have children.")
198199
return model
199200

200-
constructor.__name__ = tag
201-
qualname_prefix = constructor.__qualname__.rsplit(".", 1)[0]
202-
constructor.__qualname__ = qualname_prefix + f".{tag}"
203-
constructor.__doc__ = (
204-
f"""Create a new ``<{tag}/>`` - returns a :class:`VdomDict`."""
205-
)
201+
module = _get_module_name_by_frame_index(1)
202+
if module is None:
203+
qualname = None
204+
else:
205+
qualname = module + "." + tag
206206

207+
constructor.__name__ = tag
208+
constructor.__module__ = module
209+
constructor.__qualname__ = qualname
210+
constructor.__doc__ = f"Return a new ``<{tag}/>`` :class:`VdomDict` element"
207211
return constructor
208212

209213

@@ -271,3 +275,13 @@ def _is_single_child(value: Any) -> bool:
271275
logger.error(f"Key not specified for dynamic child {child}")
272276

273277
return False
278+
279+
280+
def _get_module_name_by_frame_index(index: int) -> Optional[str]:
281+
frame = inspect.currentframe()
282+
for i in range(index + 1): # add one to ignore this frame
283+
if frame is None:
284+
return None
285+
else:
286+
frame = frame.f_back
287+
return frame.f_globals.get("__name__")

‎src/idom/html.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
External sources
77
----------------
88
9-
link = make_vdom_constructor("link", allow_children=False)
9+
- :func:`link`
1010
1111
1212
Content Sectioning

0 commit comments

Comments
 (0)
Please sign in to comment.