2015-04-08 05:54:53 +00:00
|
|
|
from .settings import env
|
|
|
|
|
|
|
|
|
|
|
|
class AutoAPIBase(object):
|
|
|
|
|
|
|
|
language = 'base'
|
|
|
|
type = 'base'
|
|
|
|
|
|
|
|
def __init__(self, obj):
|
|
|
|
self.obj = obj
|
|
|
|
|
|
|
|
def render(self, ctx=None):
|
|
|
|
if not ctx:
|
|
|
|
ctx = {}
|
|
|
|
template = env.get_template(
|
|
|
|
'{language}/{type}.rst'.format(language=self.language, type=self.type)
|
|
|
|
)
|
2015-04-08 22:56:05 +00:00
|
|
|
ctx.update(**self.__dict__)
|
2015-04-08 06:42:06 +00:00
|
|
|
return template.render(**ctx)
|
2015-04-08 05:54:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UnknownType(AutoAPIBase):
|
|
|
|
|
|
|
|
def render(self, ctx=None):
|
|
|
|
print "Unknown Type: %s" % (self.obj['type'])
|
|
|
|
super(UnknownType, self).render(ctx=ctx)
|