Skip to content

Commit

Permalink
Merge pull request #8 from compas-dev/missing-descriptions
Browse files Browse the repository at this point in the history
Auto-generate docstring in procedural mode if not present
  • Loading branch information
gonzalocasas authored Aug 24, 2022
2 parents 2078b26 + 8668690 commit 7d2affc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions componentize.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def validate_source_bundle(source):
icon = bitmap_from_image_path(icon)

with open(code, 'r') as f:
code = f.read()
python_code = f.read()

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

return icon, code, data
ghpython = data.get('ghpython')
sdk_mode = ghpython and ghpython.get('isAdvancedMode', False)

if r'"""' not in python_code and sdk_mode is False:
python_code = r'"""{}"""{}{}'.format(data.get('description', 'Generated by Componentizer'), os.linesep, python_code)

return icon, python_code, data


def parse_param_access(access):
Expand Down

0 comments on commit 7d2affc

Please sign in to comment.