File tree Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 1- from .common import Import , import_module , hotswap
1+ from .common import Import , define_module , hotswap
22from .display import display
33from .inputs import Input
44from .images import Image
88 "display" ,
99 "node" ,
1010 "Image" ,
11- "import_module " ,
11+ "define_module " ,
1212 "hotswap" ,
1313 "html" ,
1414 "Input" ,
Original file line number Diff line number Diff line change 77from idom .tools import Var
88
99
10- def import_module (name : str , source : Any , raw : bool = False ) -> "Import" :
10+ def define_module (name : str , source : Any , raw : bool = False ) -> "Import" :
11+ """Add a module to the client
12+
13+ Parameters:
14+ name:
15+ What the module will be named (excluding the ``.js`` file extension). This
16+ matters if you want to import this module from another later since this will
17+ be the filename the module is saved under.
18+ source:
19+ The module's source.
20+ raw:
21+ If false, then ``source`` should be a file path to the module's source.
22+ If true, this should be the literal source code for the module.
23+
24+ Returns:
25+ An :class:`Import` element for the newly defined module.
26+ """
1127 if not raw :
1228 with open (str (source ), "r" ) as f :
1329 source = f .read ()
Original file line number Diff line number Diff line change 44
55import pytest
66
7- from idom .widgets import Import , import_module
7+ from idom .widgets import Import , define_module
88from idom import client
99
1010HERE = Path (__file__ ).parent
@@ -30,7 +30,7 @@ def test_raise_on_missing_import_path():
3030
3131
3232def test_custom_module (driver , display , victory ):
33- my_chart = import_module ("my_chart" , HERE / "my_chart.js" )
33+ my_chart = define_module ("my_chart" , HERE / "my_chart.js" )
3434
3535 display (my_chart .Chart )
3636
You can’t perform that action at this time.
0 commit comments