Skip to content

Commit f04bca0

Browse files
committed
Add _imports_.py generation.
1 parent 93ae2c7 commit f04bca0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

dash/development/component_generator.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import subprocess
66
import shlex
77
import os
8+
import textwrap
89

910
from .base_component import generate_class_file
1011

@@ -43,8 +44,11 @@ def generate_components(component_src, output_dir):
4344

4445
metadata = json.loads(out.decode())
4546

47+
components = []
48+
4649
for component_path, component_data in metadata.items():
4750
name = component_path.split('/')[-1].split('.')[0]
51+
components.append(name)
4852
generate_class_file(
4953
name,
5054
component_data['props'],
@@ -56,6 +60,20 @@ def generate_components(component_src, output_dir):
5660
with open(os.path.join(output_dir, 'metadata.json'), 'w') as f:
5761
json.dump(metadata, f)
5862

63+
with open(os.path.join(output_dir, '_imports_.py'), 'w') as f:
64+
f.write(textwrap.dedent(
65+
'''
66+
{}
67+
68+
__all__ = [
69+
{}
70+
]
71+
'''.format(
72+
'\n'.join('from {0} import {0}'.format(x) for x in components),
73+
',\n'.join(' "{}"'.format(x) for x in components)
74+
)
75+
))
76+
5977

6078
def cli():
6179
if len(sys.argv) != 3:

0 commit comments

Comments
 (0)