Rename files

pull/9/head
Eric Holscher 9 years ago
parent f60b7d8880
commit 685665535f

@ -1,4 +0,0 @@
from .dotnet import DotNetDomain
from .python import PythonDomain
from .go import GoDomain
from .javascript import JavaScriptDomain

@ -11,7 +11,7 @@ import shutil
from sphinx.util.console import darkgreen, bold from sphinx.util.console import darkgreen, bold
from .domains import DotNetDomain, PythonDomain, GoDomain, JavaScriptDomain from .mappers import DotNetSphinxMapper, PythonSphinxMapper, GoSphinxMapper, JavaScriptSphinxMapper
default_options = ['members', 'undoc-members', 'private-members', 'special-members'] default_options = ['members', 'undoc-members', 'private-members', 'special-members']
@ -35,10 +35,10 @@ def run_autoapi(app):
app.env.autoapi_data = [] app.env.autoapi_data = []
mapping = { mapping = {
'python': PythonDomain, 'python': PythonSphinxMapper,
'dotnet': DotNetDomain, 'dotnet': DotNetSphinxMapper,
'go': GoDomain, 'go': GoSphinxMapper,
'javascript': JavaScriptDomain, 'javascript': JavaScriptSphinxMapper,
} }
domain = mapping[app.config.autoapi_type] domain = mapping[app.config.autoapi_type]

@ -0,0 +1,4 @@
from .dotnet import DotNetSphinxMapper
from .python import PythonSphinxMapper
from .go import GoSphinxMapper
from .javascript import JavaScriptSphinxMapper

@ -193,13 +193,13 @@ class SphinxMapperBase(object):
''' '''
self.objects[obj.id] = obj self.objects[obj.id] = obj
def map(self, options): def map(self, options=None):
'''Trigger find of serialized sources and build objects''' '''Trigger find of serialized sources and build objects'''
for path, data in self.paths.items(): for path, data in self.paths.items():
for obj in self.create_class(data, options=options): for obj in self.create_class(data, options=options):
self.add_object(obj) self.add_object(obj)
def create_class(self, obj, options): def create_class(self, obj, options=None):
''' '''
Create class object. Create class object.

@ -6,7 +6,7 @@ from .base import PythonMapperBase, SphinxMapperBase
MADE = set() MADE = set()
class DotNetDomain(SphinxMapperBase): class DotNetSphinxMapper(SphinxMapperBase):
'''Auto API domain handler for .NET '''Auto API domain handler for .NET
@ -37,7 +37,7 @@ class DotNetDomain(SphinxMapperBase):
return None return None
# Subclassed to iterate over items # Subclassed to iterate over items
def map(self, options, **kwargs): def map(self, options=None, **kwargs):
'''Trigger find of serialized sources and build objects''' '''Trigger find of serialized sources and build objects'''
for path, data in self.paths.items(): for path, data in self.paths.items():
for item in data['items']: for item in data['items']:
@ -46,7 +46,7 @@ class DotNetDomain(SphinxMapperBase):
self.organize_objects() self.organize_objects()
def create_class(self, data, options, **kwargs): def create_class(self, data, options=None, **kwargs):
''' '''
Return instance of class based on Roslyn type property Return instance of class based on Roslyn type property
@ -162,14 +162,14 @@ class DotNetDomain(SphinxMapperBase):
# top_level_file.write(content.render(pages=self.namespaces.values())) # top_level_file.write(content.render(pages=self.namespaces.values()))
class DotNetBase(PythonMapperBase): class DotNetPythonMapper(PythonMapperBase):
'''Base .NET object representation''' '''Base .NET object representation'''
language = 'dotnet' language = 'dotnet'
def __init__(self, obj, **kwargs): def __init__(self, obj, **kwargs):
super(DotNetBase, self).__init__(obj, **kwargs) super(DotNetPythonMapper, self).__init__(obj, **kwargs)
# Always exist # Always exist
self.id = obj['id'] self.id = obj['id']
@ -297,26 +297,26 @@ class DotNetBase(PythonMapperBase):
return self.ref_name.split('.')[-1] return self.ref_name.split('.')[-1]
class DotNetNamespace(DotNetBase): class DotNetNamespace(DotNetPythonMapper):
type = 'namespace' type = 'namespace'
ref_directive = 'ns' ref_directive = 'ns'
plural = 'namespaces' plural = 'namespaces'
top_level_object = True top_level_object = True
class DotNetMethod(DotNetBase): class DotNetMethod(DotNetPythonMapper):
type = 'method' type = 'method'
ref_directive = 'meth' ref_directive = 'meth'
plural = 'methods' plural = 'methods'
class DotNetProperty(DotNetBase): class DotNetProperty(DotNetPythonMapper):
type = 'property' type = 'property'
ref_directive = 'prop' ref_directive = 'prop'
plural = 'properties' plural = 'properties'
class DotNetEnum(DotNetBase): class DotNetEnum(DotNetPythonMapper):
type = 'enum' type = 'enum'
ref_type = 'enumeration' ref_type = 'enumeration'
ref_directive = 'enum' ref_directive = 'enum'
@ -324,7 +324,7 @@ class DotNetEnum(DotNetBase):
top_level_object = True top_level_object = True
class DotNetStruct(DotNetBase): class DotNetStruct(DotNetPythonMapper):
type = 'struct' type = 'struct'
ref_type = 'structure' ref_type = 'structure'
ref_directive = 'struct' ref_directive = 'struct'
@ -332,39 +332,39 @@ class DotNetStruct(DotNetBase):
top_level_object = True top_level_object = True
class DotNetConstructor(DotNetBase): class DotNetConstructor(DotNetPythonMapper):
type = 'constructor' type = 'constructor'
ref_directive = 'ctor' ref_directive = 'ctor'
plural = 'constructors' plural = 'constructors'
class DotNetInterface(DotNetBase): class DotNetInterface(DotNetPythonMapper):
type = 'interface' type = 'interface'
ref_directive = 'iface' ref_directive = 'iface'
plural = 'interfaces' plural = 'interfaces'
top_level_object = True top_level_object = True
class DotNetDelegate(DotNetBase): class DotNetDelegate(DotNetPythonMapper):
type = 'delegate' type = 'delegate'
ref_directive = 'del' ref_directive = 'del'
plural = 'delegates' plural = 'delegates'
top_level_object = True top_level_object = True
class DotNetClass(DotNetBase): class DotNetClass(DotNetPythonMapper):
type = 'class' type = 'class'
ref_directive = 'cls' ref_directive = 'cls'
plural = 'classes' plural = 'classes'
top_level_object = True top_level_object = True
class DotNetField(DotNetBase): class DotNetField(DotNetPythonMapper):
type = 'field' type = 'field'
plural = 'fields' plural = 'fields'
class DotNetEvent(DotNetBase): class DotNetEvent(DotNetPythonMapper):
type = 'event' type = 'event'
plural = 'events' plural = 'events'

@ -4,7 +4,7 @@ import subprocess
from .base import PythonMapperBase, SphinxMapperBase from .base import PythonMapperBase, SphinxMapperBase
class GoDomain(SphinxMapperBase): class GoSphinxMapper(SphinxMapperBase):
'''Auto API domain handler for Go '''Auto API domain handler for Go
@ -39,7 +39,7 @@ class GoDomain(SphinxMapperBase):
self.app.warn('Error reading file: {0}'.format(path)) self.app.warn('Error reading file: {0}'.format(path))
return None return None
def create_class(self, data, options, _type=None): def create_class(self, data, options=None, _type=None):
'''Return instance of class based on Go data '''Return instance of class based on Go data
Data keys handled here: Data keys handled here:
@ -89,13 +89,13 @@ class GoDomain(SphinxMapperBase):
yield obj yield obj
class GoBase(PythonMapperBase): class GoPythonMapper(PythonMapperBase):
language = 'go' language = 'go'
inverted_names = False inverted_names = False
def __init__(self, obj, **kwargs): def __init__(self, obj, **kwargs):
super(GoBase, self).__init__(obj, **kwargs) super(GoPythonMapper, self).__init__(obj, **kwargs)
self.name = obj.get('name') or obj.get('packageName') self.name = obj.get('name') or obj.get('packageName')
self.id = self.name self.id = self.name
@ -142,33 +142,33 @@ class GoBase(PythonMapperBase):
return self.obj.get('methods', []) return self.obj.get('methods', [])
class GoVariable(GoBase): class GoVariable(GoPythonMapper):
type = 'var' type = 'var'
inverted_names = True inverted_names = True
class GoMethod(GoBase): class GoMethod(GoPythonMapper):
type = 'method' type = 'method'
ref_directive = 'meth' ref_directive = 'meth'
class GoConstant(GoBase): class GoConstant(GoPythonMapper):
type = 'const' type = 'const'
inverted_names = True inverted_names = True
class GoFunction(GoBase): class GoFunction(GoPythonMapper):
type = 'func' type = 'func'
ref_type = 'function' ref_type = 'function'
class GoPackage(GoBase): class GoPackage(GoPythonMapper):
type = 'package' type = 'package'
ref_directive = 'pkg' ref_directive = 'pkg'
top_level_object = True top_level_object = True
class GoType(GoBase): class GoType(GoPythonMapper):
type = 'type' type = 'type'

@ -5,7 +5,7 @@ import subprocess
from .base import PythonMapperBase, SphinxMapperBase from .base import PythonMapperBase, SphinxMapperBase
class JavaScriptDomain(SphinxMapperBase): class JavaScriptSphinxMapper(SphinxMapperBase):
'''Auto API domain handler for Javascript '''Auto API domain handler for Javascript
@ -32,7 +32,7 @@ class JavaScriptDomain(SphinxMapperBase):
return None return None
# Subclassed to iterate over items # Subclassed to iterate over items
def map(self, options, **kwargs): def map(self, options=None, **kwargs):
'''Trigger find of serialized sources and build objects''' '''Trigger find of serialized sources and build objects'''
for path, data in self.paths.items(): for path, data in self.paths.items():
for item in data: for item in data:
@ -40,7 +40,7 @@ class JavaScriptDomain(SphinxMapperBase):
obj.jinja_env = self.jinja_env obj.jinja_env = self.jinja_env
self.add_object(obj) self.add_object(obj)
def create_class(self, data, options, **kwargs): def create_class(self, data, options=None, **kwargs):
'''Return instance of class based on Javascript data '''Return instance of class based on Javascript data
Data keys handled here: Data keys handled here:
@ -72,7 +72,7 @@ class JavaScriptDomain(SphinxMapperBase):
yield obj yield obj
class JavaScriptBase(PythonMapperBase): class JavaScriptPythonMapper(PythonMapperBase):
language = 'javascript' language = 'javascript'
@ -84,7 +84,7 @@ class JavaScriptBase(PythonMapperBase):
so we try and keep standard naming to keep templates more re-usable. so we try and keep standard naming to keep templates more re-usable.
''' '''
super(JavaScriptBase, self).__init__(obj, **kwargs) super(JavaScriptPythonMapper, self).__init__(obj, **kwargs)
self.name = obj.get('name') self.name = obj.get('name')
self.id = self.name self.id = self.name
@ -104,28 +104,28 @@ class JavaScriptBase(PythonMapperBase):
pass pass
class JavaScriptClass(JavaScriptBase): class JavaScriptClass(JavaScriptPythonMapper):
type = 'class' type = 'class'
ref_directive = 'class' ref_directive = 'class'
top_level_object = True top_level_object = True
class JavaScriptFunction(JavaScriptBase): class JavaScriptFunction(JavaScriptPythonMapper):
type = 'function' type = 'function'
ref_type = 'func' ref_type = 'func'
class JavaScriptData(JavaScriptBase): class JavaScriptData(JavaScriptPythonMapper):
type = 'data' type = 'data'
ref_directive = 'data' ref_directive = 'data'
class JavaScriptMember(JavaScriptBase): class JavaScriptMember(JavaScriptPythonMapper):
type = 'member' type = 'member'
ref_directive = 'member' ref_directive = 'member'
class JavaScriptAttribute(JavaScriptBase): class JavaScriptAttribute(JavaScriptPythonMapper):
type = 'attribute' type = 'attribute'
ref_directive = 'attr' ref_directive = 'attr'

@ -5,7 +5,7 @@ from epyparse import parsed
from .base import PythonMapperBase, SphinxMapperBase from .base import PythonMapperBase, SphinxMapperBase
class PythonDomain(SphinxMapperBase): class PythonSphinxMapper(SphinxMapperBase):
'''Auto API domain handler for Python '''Auto API domain handler for Python
@ -31,7 +31,7 @@ class PythonDomain(SphinxMapperBase):
self.app.warn('Error reading file: {0}'.format(path)) self.app.warn('Error reading file: {0}'.format(path))
return None return None
def create_class(self, data, options, **kwargs): def create_class(self, data, options=None, **kwargs):
'''Return instance of class based on Roslyn type property '''Return instance of class based on Roslyn type property
Data keys handled here: Data keys handled here:
@ -61,12 +61,12 @@ class PythonDomain(SphinxMapperBase):
yield obj yield obj
class PythonBase(PythonMapperBase): class PythonPythonMapper(PythonMapperBase):
language = 'python' language = 'python'
def __init__(self, obj, **kwargs): def __init__(self, obj, **kwargs):
super(PythonBase, self).__init__(obj, **kwargs) super(PythonPythonMapper, self).__init__(obj, **kwargs)
# Always exist # Always exist
self.id = obj['fullname'] self.id = obj['fullname']
@ -105,14 +105,14 @@ class PythonBase(PythonMapperBase):
return True return True
class PythonFunction(PythonBase): class PythonFunction(PythonPythonMapper):
type = 'function' type = 'function'
class PythonModule(PythonBase): class PythonModule(PythonPythonMapper):
type = 'module' type = 'module'
top_level_object = True top_level_object = True
class PythonClass(PythonBase): class PythonClass(PythonPythonMapper):
type = 'class' type = 'class'

@ -5,7 +5,7 @@ from contextlib import nested
from mock import patch from mock import patch
from autoapi.domains import dotnet from autoapi.mappers import dotnet
class DomainTests(unittest.TestCase): class DomainTests(unittest.TestCase):
@ -26,7 +26,7 @@ class DomainTests(unittest.TestCase):
def test_create_class(self): def test_create_class(self):
'''Test .NET class instance creation helper''' '''Test .NET class instance creation helper'''
dom = dotnet.DotNetDomain(self.application) dom = dotnet.DotNetSphinxMapper(self.application)
def _create_class(data): def _create_class(data):
return list(dom.create_class(data))[0] return list(dom.create_class(data))[0]
@ -54,7 +54,7 @@ class DomainTests(unittest.TestCase):
self.assertIsInstance(cls, dotnet.DotNetEvent) self.assertIsInstance(cls, dotnet.DotNetEvent)
def test_create_class_with_children(self): def test_create_class_with_children(self):
dom = dotnet.DotNetDomain(self.application) dom = dotnet.DotNetSphinxMapper(self.application)
def _create_class(data): def _create_class(data):
return list(dom.create_class(data))[0] return list(dom.create_class(data))[0]
@ -80,10 +80,10 @@ class DomainTests(unittest.TestCase):
'id': 'Foo.Bar', 'type': 'Class', 'summary': path} 'id': 'Foo.Bar', 'type': 'Class', 'summary': path}
with nested( with nested(
patch('autoapi.domains.dotnet.DotNetDomain.find_files', _mock_find), patch('autoapi.mappers.dotnet.DotNetSphinxMapper.find_files', _mock_find),
patch('autoapi.domains.dotnet.DotNetDomain.read_file', _mock_read), patch('autoapi.mappers.dotnet.DotNetSphinxMapper.read_file', _mock_read),
): ):
dom = dotnet.DotNetDomain(self.application) dom = dotnet.DotNetSphinxMapper(self.application)
dom.load('', '', '') dom.load('', '', '')
dom.map() dom.map()
objs = dom.objects objs = dom.objects

@ -2,7 +2,7 @@
import unittest import unittest
from autoapi.domains import dotnet from autoapi.mappers import dotnet
class NamespaceTests(unittest.TestCase): class NamespaceTests(unittest.TestCase):

Loading…
Cancel
Save