Skip to content

Commit 7d2affc

Browse files
authored
Merge pull request #8 from compas-dev/missing-descriptions
Auto-generate docstring in procedural mode if not present
2 parents 2078b26 + 8668690 commit 7d2affc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

componentize.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def validate_source_bundle(source):
116116
icon = bitmap_from_image_path(icon)
117117

118118
with open(code, 'r') as f:
119-
code = f.read()
119+
python_code = f.read()
120120

121121
with open(data, 'r') as f:
122122
data = json.load(f)
@@ -127,7 +127,13 @@ def validate_source_bundle(source):
127127
if data['exposure'] not in EXPOSURE['valid']:
128128
raise ValueError('Invalid exposure value. Accepted values are {}'.format(sorted(EXPOSURE['valid'])))
129129

130-
return icon, code, data
130+
ghpython = data.get('ghpython')
131+
sdk_mode = ghpython and ghpython.get('isAdvancedMode', False)
132+
133+
if r'"""' not in python_code and sdk_mode is False:
134+
python_code = r'"""{}"""{}{}'.format(data.get('description', 'Generated by Componentizer'), os.linesep, python_code)
135+
136+
return icon, python_code, data
131137

132138

133139
def parse_param_access(access):

0 commit comments

Comments
 (0)