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 .domains import DotNetDomain, PythonDomain, GoDomain, JavaScriptDomain
from .mappers import DotNetSphinxMapper, PythonSphinxMapper, GoSphinxMapper, JavaScriptSphinxMapper
default_options = ['members', 'undoc-members', 'private-members', 'special-members']
@ -35,10 +35,10 @@ def run_autoapi(app):
app.env.autoapi_data = []
mapping = {
'python': PythonDomain,
'dotnet': DotNetDomain,
'go': GoDomain,
'javascript': JavaScriptDomain,
'python': PythonSphinxMapper,
'dotnet': DotNetSphinxMapper,
'go': GoSphinxMapper,
'javascript': JavaScriptSphinxMapper,
}
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
def map(self, options):
def map(self, options=None):
'''Trigger find of serialized sources and build objects'''
for path, data in self.paths.items():
for obj in self.create_class(data, options=options):
self.add_object(obj)
def create_class(self, obj, options):
def create_class(self, obj, options=None):
'''
Create class object.

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

@ -4,7 +4,7 @@ import subprocess
from .base import PythonMapperBase, SphinxMapperBase
class GoDomain(SphinxMapperBase):
class GoSphinxMapper(SphinxMapperBase):
'''Auto API domain handler for Go
@ -39,7 +39,7 @@ class GoDomain(SphinxMapperBase):
self.app.warn('Error reading file: {0}'.format(path))
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
Data keys handled here:
@ -89,13 +89,13 @@ class GoDomain(SphinxMapperBase):
yield obj
class GoBase(PythonMapperBase):
class GoPythonMapper(PythonMapperBase):
language = 'go'
inverted_names = False
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.id = self.name
@ -142,33 +142,33 @@ class GoBase(PythonMapperBase):
return self.obj.get('methods', [])
class GoVariable(GoBase):
class GoVariable(GoPythonMapper):
type = 'var'
inverted_names = True
class GoMethod(GoBase):
class GoMethod(GoPythonMapper):
type = 'method'
ref_directive = 'meth'
class GoConstant(GoBase):
class GoConstant(GoPythonMapper):
type = 'const'
inverted_names = True
class GoFunction(GoBase):
class GoFunction(GoPythonMapper):
type = 'func'
ref_type = 'function'
class GoPackage(GoBase):
class GoPackage(GoPythonMapper):
type = 'package'
ref_directive = 'pkg'
top_level_object = True
class GoType(GoBase):
class GoType(GoPythonMapper):
type = 'type'

@ -5,7 +5,7 @@ import subprocess
from .base import PythonMapperBase, SphinxMapperBase
class JavaScriptDomain(SphinxMapperBase):
class JavaScriptSphinxMapper(SphinxMapperBase):
'''Auto API domain handler for Javascript
@ -32,7 +32,7 @@ class JavaScriptDomain(SphinxMapperBase):
return None
# Subclassed to iterate over items
def map(self, options, **kwargs):
def map(self, options=None, **kwargs):
'''Trigger find of serialized sources and build objects'''
for path, data in self.paths.items():
for item in data:
@ -40,7 +40,7 @@ class JavaScriptDomain(SphinxMapperBase):
obj.jinja_env = self.jinja_env
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
Data keys handled here:
@ -72,7 +72,7 @@ class JavaScriptDomain(SphinxMapperBase):
yield obj
class JavaScriptBase(PythonMapperBase):
class JavaScriptPythonMapper(PythonMapperBase):
language = 'javascript'
@ -84,7 +84,7 @@ class JavaScriptBase(PythonMapperBase):
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.id = self.name
@ -104,28 +104,28 @@ class JavaScriptBase(PythonMapperBase):
pass
class JavaScriptClass(JavaScriptBase):
class JavaScriptClass(JavaScriptPythonMapper):
type = 'class'
ref_directive = 'class'
top_level_object = True
class JavaScriptFunction(JavaScriptBase):
class JavaScriptFunction(JavaScriptPythonMapper):
type = 'function'
ref_type = 'func'
class JavaScriptData(JavaScriptBase):
class JavaScriptData(JavaScriptPythonMapper):
type = 'data'
ref_directive = 'data'
class JavaScriptMember(JavaScriptBase):
class JavaScriptMember(JavaScriptPythonMapper):
type = 'member'
ref_directive = 'member'
class JavaScriptAttribute(JavaScriptBase):
class JavaScriptAttribute(JavaScriptPythonMapper):
type = 'attribute'
ref_directive = 'attr'

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

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

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

Loading…
Cancel
Save