Skip to content

Commit eb490ac

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

5 files changed

Lines changed: 46 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: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,28 @@ 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+
class VuetifyWidget(VueWidget):
115+
116+
_model_name = Unicode("VuetifyWidgetModel").tag(sync=True)
117+
118+
_view_name = Unicode("VuetifyView").tag(sync=True)
119+
120+
_view_module = Unicode("jupyter-vuetify").tag(sync=True)
121+
122+
_model_module = Unicode("jupyter-vuetify").tag(sync=True)
123+
124+
_view_module_version = Unicode(semver).tag(sync=True)
125+
126+
_model_module_version = Unicode(semver).tag(sync=True)
127+
128+
_metadata = Dict(default_value=None, allow_none=True).tag(sync=True)
110129
111130
112131
"""
@@ -117,7 +136,7 @@ def generate_python():
117136

118137
code += textwrap.dedent(
119138
f"""\
120-
__all__ = ["{'", "'.join([name[1:] for name, _ in components])}"]
139+
__all__ = ["VuetifyWidget", "{'", "'.join([name[1:] for name, _ in components])}"]
121140
"""
122141
)
123142

@@ -184,7 +203,7 @@ def generate_js():
184203
return code
185204

186205

187-
with open("../ipyvuetify/vuetify_widgets.py", "w") as f:
206+
with open("../ipyvuetify/generated.py", "w") as f:
188207
f.write(generate_python())
189208

190209
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)