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

Commit

Permalink
Fix Bug: support or\n and ~ for parameter and return type (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannanwang1 authored and bianliu1013 committed Oct 13, 2017
1 parent 294d490 commit 53068a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions docfx_yaml/monkeypatch.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from docutils import nodes
from functools import partial

Expand Down Expand Up @@ -206,9 +207,9 @@ def extract_exception_desc(field_object):
returntype_ret = transform_node(returntype_node)
if returntype_ret:
# Support or in returntype
for returntype in returntype_ret.split(' or '):
# Remove @ and \n for cross reference in return type to apply to docfx correctly
if returntype.startswith('@'):
for returntype in re.split(' or[ \n]', returntype_ret):
# Remove @ ~ and \n for cross reference in return type to apply to docfx correctly
if returntype.startswith('@') or returntype.startswith('~'):
returntype = returntype[1:]
data['return'].setdefault('type', []).append(returntype.rstrip('\n'))
if fieldtype.name == 'returnvalue':
Expand All @@ -227,9 +228,10 @@ def extract_exception_desc(field_object):
_para_types = []
if fieldtype.name == 'parameter':
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('@'):
# Support or in parameter type
for _s_type in re.split(' or[ \n]', _type):
# Remove @ ~ and \n for cross reference in parameter type to apply to docfx correctly
if _s_type and (_s_type.startswith('@') or _s_type.startswith('~')):
_s_type = _s_type[1:]
_s_type = _s_type.rstrip('\n')

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.22',
version='1.2.23',
author='Eric Holscher',
author_email='eric@ericholscher.com',
url='https://github.com/ericholscher/sphinx-docfx-yaml',
Expand Down

0 comments on commit 53068a8

Please sign in to comment.