Skip to content

Commit d438c4f

Browse files
feat: keep same module structure for generated python code
1 parent d7abb21 commit d438c4f

5 files changed

Lines changed: 47 additions & 32 deletions

File tree

generate_source/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ if ! test -d "vuetify"; then
99
cd ..
1010
fi
1111
python generate_code.py
12-
pre-commit run --files ../ipyvuetify/vuetify_widgets.py ../js/src/Widgets.js
12+
pre-commit run --files ../ipyvuetify/generated.py ../js/src/Widgets.js

generate_source/generate_code.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,29 @@ class {name[1:]}(VuetifyWidget):
104104
def generate_python():
105105
code = textwrap.dedent(
106106
"""\
107-
from traitlets import Unicode, Union, Float, List as TList, Dict, Bool, Any
108-
109-
from .vuetify_widget import VuetifyWidget
107+
from ipyvue import VueWidget
108+
from traitlets import Any, Bool, Dict, Float, Unicode, Union
109+
from traitlets import List as TList
110+
111+
from ._version import semver
112+
113+
114+
115+
class VuetifyWidget(VueWidget):
116+
117+
_model_name = Unicode("VuetifyWidgetModel").tag(sync=True)
118+
119+
_view_name = Unicode("VuetifyView").tag(sync=True)
120+
121+
_view_module = Unicode("jupyter-vuetify").tag(sync=True)
122+
123+
_model_module = Unicode("jupyter-vuetify").tag(sync=True)
124+
125+
_view_module_version = Unicode(semver).tag(sync=True)
126+
127+
_model_module_version = Unicode(semver).tag(sync=True)
128+
129+
_metadata = Dict(default_value=None, allow_none=True).tag(sync=True)
110130
111131
112132
"""
@@ -117,7 +137,7 @@ def generate_python():
117137

118138
code += textwrap.dedent(
119139
f"""\
120-
__all__ = ["{'", "'.join([name[1:] for name, _ in components])}"]
140+
__all__ = ["VuetifyWidget", "{'", "'.join([name[1:] for name, _ in components])}"]
121141
"""
122142
)
123143

@@ -184,7 +204,7 @@ def generate_js():
184204
return code
185205

186206

187-
with open("../ipyvuetify/vuetify_widgets.py", "w") as f:
207+
with open("../ipyvuetify/generated.py", "w") as f:
188208
f.write(generate_python())
189209

190210
with open("../js/src/Widgets.js", "w") as f:

ipyvuetify/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from ._version import __version__
2+
from .generated import * # noqa: F403
23
from .Html import Html
34
from .Themes import theme
4-
from .vuetify_widgets import * # noqa: F403
55
from .VuetifyTemplate import VuetifyTemplate
66

77

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
1+
from ipyvue import VueWidget
12
from traitlets import Any, Bool, Dict, Float, Unicode, Union
23
from traitlets import List as TList
34

4-
from .vuetify_widget import VuetifyWidget
5+
from ._version import semver
6+
7+
8+
class VuetifyWidget(VueWidget):
9+
10+
_model_name = Unicode("VuetifyWidgetModel").tag(sync=True)
11+
12+
_view_name = Unicode("VuetifyView").tag(sync=True)
13+
14+
_view_module = Unicode("jupyter-vuetify").tag(sync=True)
15+
16+
_model_module = Unicode("jupyter-vuetify").tag(sync=True)
17+
18+
_view_module_version = Unicode(semver).tag(sync=True)
19+
20+
_model_module_version = Unicode(semver).tag(sync=True)
21+
22+
_metadata = Dict(default_value=None, allow_none=True).tag(sync=True)
523

624

725
class Alert(VuetifyWidget):
@@ -6705,6 +6723,7 @@ class WindowItem(VuetifyWidget):
67056723

67066724

67076725
__all__ = [
6726+
"VuetifyWidget",
67086727
"Alert",
67096728
"AlertTitle",
67106729
"App",

ipyvuetify/vuetify_widget.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)