Replace non-existant :dn:ref: reference with :any: for now

This will resolve more lookups as proper references, not anchor links. The :any:
lookup is strict though, the domain should implement it's own :dn:obj: generic
lookup.
pull/39/head
Anthony Johnson 9 years ago
parent 2fd908e2a7
commit 1688b53f42

@ -35,12 +35,12 @@ DOC_COMMENT_PARAM_PATTERN = re.compile(
# Comment member identities # Comment member identities
# From: https://msdn.microsoft.com/en-us/library/vstudio/fsbx0t7x(v=VS.100).aspx # From: https://msdn.microsoft.com/en-us/library/vstudio/fsbx0t7x(v=VS.100).aspx
DOC_COMMENT_IDENTITIES = { DOC_COMMENT_IDENTITIES = {
'N': 'ns', 'N': 'dn:ns',
'T': 'ref', # can be any type (class, delegate, enum, etc), so use ref 'T': 'any', # can be any type (class, delegate, enum, etc), so use any
'F': 'field', 'F': 'dn:field',
'P': 'prop', 'P': 'dn:prop',
'M': 'meth', 'M': 'dn:meth',
'E': 'event', 'E': 'dn:event',
} }
@ -378,19 +378,19 @@ class DotNetPythonMapper(PythonMapperBase):
.replace('<', '\<') .replace('<', '\<')
.replace('`', '\`')) .replace('`', '\`'))
reftype = 'ref' reftype = 'any'
replacement = '' replacement = ''
# Given the pattern of `\w:\w+`, inspect first letter of # Given the pattern of `\w:\w+`, inspect first letter of
# reference for identity type # reference for identity type
if ref[1] == ':' and ref[0] in DOC_COMMENT_IDENTITIES: if ref[1] == ':' and ref[0] in DOC_COMMENT_IDENTITIES:
reftype = DOC_COMMENT_IDENTITIES[ref[:1]] reftype = DOC_COMMENT_IDENTITIES[ref[:1]]
ref = ref[2:] ref = ref[2:]
replacement = ':dn:{reftype}:`{ref}`'.format( replacement = ':{reftype}:`{ref}`'.format(
reftype=reftype, ref=ref) reftype=reftype, ref=ref)
elif ref[:2] == '!:': elif ref[:2] == '!:':
replacement = ref[2:] replacement = ref[2:]
else: else:
replacement = ':dn:ref:`{ref}`'.format(ref=ref) replacement = ':any:`{ref}`'.format(ref=ref)
# Escape following text # Escape following text
text_end = text[found.end():] text_end = text[found.end():]

@ -95,7 +95,7 @@ class DomainTests(unittest.TestCase):
'''XML doc comment parsing''' '''XML doc comment parsing'''
ret = dotnet.DotNetPythonMapper.transform_doc_comments( ret = dotnet.DotNetPythonMapper.transform_doc_comments(
'This is an example comment <see cref="FOO" />') 'This is an example comment <see cref="FOO" />')
self.assertEqual(ret, 'This is an example comment :dn:ref:`FOO`') self.assertEqual(ret, 'This is an example comment :any:`FOO`')
ret = dotnet.DotNetPythonMapper.transform_doc_comments( ret = dotnet.DotNetPythonMapper.transform_doc_comments(
'This is an example comment <see cref="!:FOO" />') 'This is an example comment <see cref="!:FOO" />')
@ -121,7 +121,7 @@ class DomainTests(unittest.TestCase):
"""XML transform escaping""" """XML transform escaping"""
ret = dotnet.DotNetPythonMapper.transform_doc_comments( ret = dotnet.DotNetPythonMapper.transform_doc_comments(
'Foo <see cref="Foo`1" /> Bar') 'Foo <see cref="Foo`1" /> Bar')
self.assertEqual(ret, 'Foo :dn:ref:`Foo\\`1` Bar') self.assertEqual(ret, 'Foo :any:`Foo\\`1` Bar')
ret = dotnet.DotNetPythonMapper.transform_doc_comments( ret = dotnet.DotNetPythonMapper.transform_doc_comments(
'No space before<see cref="M:Foo`1" />or after') 'No space before<see cref="M:Foo`1" />or after')

Loading…
Cancel
Save