Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Commit

Permalink
support mulit 'parameter' type syntax (#61)
Browse files Browse the repository at this point in the history
* support mulit 'parameter' type syntax

* remove useless trace code
  • Loading branch information
bianliu1013 committed Oct 13, 2017
1 parent 9135a11 commit 294d490
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions docfx_yaml/monkeypatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def make_param(_id, _description, _type=None):
'description': _description,
}
if _type:
ret['type'] = [_type]
ret['type'] = _type
return ret

def transform_para(para_field):
Expand Down Expand Up @@ -223,16 +223,23 @@ def extract_exception_desc(field_object):
_type = u''.join(transform_para(n) for n in fieldtypes[field])
else:
_type = None

_para_types = []
if fieldtype.name == 'parameter':
# Remove @ and \n for cross reference in parameter type to apply to docfx correctly
if _type and _type.startswith('@'):
_type = _type[1:]
_type = _type.rstrip('\n')
if _type:
for _s_type in _type.split(' or '):
# Remove @ and \n for cross reference in parameter type to apply to docfx correctly
if _s_type and _s_type.startswith('@'):
_s_type = _s_type[1:]
_s_type = _s_type.rstrip('\n')

_data = make_param(_id=_id, _type=_type, _description=_description)
_para_types.append(_s_type)

_data = make_param(_id=_id, _type=_para_types, _description=_description)
data['parameters'].append(_data)
if fieldtype.name == 'variable':
_data = make_param(_id=_id, _type=_type, _description=_description)
_para_types.append(_type)
_data = make_param(_id=_id, _type=_para_types, _description=_description)
data['variables'].append(_data)

ret_list = extract_exception_desc(field_object)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

setup(
name='sphinx-docfx-yaml',
version='1.2.21',
version='1.2.22',
author='Eric Holscher',
author_email='eric@ericholscher.com',
url='https://github.com/ericholscher/sphinx-docfx-yaml',
Expand Down

0 comments on commit 294d490

Please sign in to comment.