def GET_docs(self): # controllers to gather docs from. from r2.controllers.api import ApiController, ApiminimalController from r2.controllers.front import FrontController from r2.controllers import listingcontroller api_controllers = [(ApiController, '/api'), (ApiminimalController, '/api'), (FrontController, '')] for name, value in vars(listingcontroller).iteritems(): if name.endswith('Controller'): api_controllers.append((value, '')) # merge documentation info together. api_docs = defaultdict(dict) for controller, url_prefix in api_controllers: for section, contents in self.docs_from_controller( controller, url_prefix).iteritems(): api_docs[section].update(contents) return BoringPage(_('api documentation'), content=ApiHelp(api_docs=api_docs), css_class="api-help", show_sidebar=False, show_firsttext=False).render()
def GET_docs(self, mode): # controllers to gather docs from. from r2.controllers.api import ApiController, ApiminimalController from r2.controllers.apiv1.user import APIv1UserController from r2.controllers.apiv1.gold import APIv1GoldController from r2.controllers.apiv1.scopes import APIv1ScopesController from r2.controllers.captcha import CaptchaController from r2.controllers.front import FrontController from r2.controllers.wiki import WikiApiController, WikiController from r2.controllers.multi import MultiApiController from r2.controllers import listingcontroller api_controllers = [ (APIv1UserController, '/api/v1'), (APIv1GoldController, '/api/v1'), (APIv1ScopesController, '/api/v1'), (ApiController, '/api'), (ApiminimalController, '/api'), (WikiApiController, '/api/wiki'), (WikiController, '/wiki'), (MultiApiController, '/api/multi'), (CaptchaController, ''), (FrontController, ''), ] for name, value in vars(listingcontroller).iteritems(): if name.endswith('Controller'): api_controllers.append((value, '')) # bring in documented plugin controllers api_controllers.extend(g.plugins.get_documented_controllers()) # merge documentation info together. api_docs = defaultdict(dict) oauth_index = defaultdict(set) for controller, url_prefix in api_controllers: controller_docs = self.docs_from_controller(controller, url_prefix, mode == 'oauth') for section, contents in controller_docs.iteritems(): api_docs[section].update(contents) for variant, method_dict in contents.iteritems(): for method, docs in method_dict.iteritems(): for scope in docs['oauth_scopes']: oauth_index[scope].add((section, variant, method)) return BoringPage( _('api documentation'), content=ApiHelp( api_docs=api_docs, oauth_index=oauth_index, mode=mode, ), css_class="api-help", show_sidebar=False, show_infobar=False ).render()
def GET_docs(self, mode): # controllers to gather docs from. from r2.controllers.api import ApiController, ApiminimalController from r2.controllers.apiv1 import APIv1Controller from r2.controllers.front import FrontController from r2.controllers import listingcontroller api_controllers = [(APIv1Controller, '/api/v1'), (ApiController, '/api'), (ApiminimalController, '/api'), (FrontController, '')] for name, value in vars(listingcontroller).iteritems(): if name.endswith('Controller'): api_controllers.append((value, '')) # merge documentation info together. api_docs = defaultdict(dict) oauth_index = defaultdict(set) for controller, url_prefix in api_controllers: controller_docs = self.docs_from_controller( controller, url_prefix, mode == 'oauth') for section, contents in controller_docs.iteritems(): api_docs[section].update(contents) for variant, method_dict in contents.iteritems(): for method, docs in method_dict.iteritems(): for scope in docs['oauth_scopes']: oauth_index[scope].add((section, variant, method)) return BoringPage(_('api documentation'), content=ApiHelp( api_docs=api_docs, oauth_index=oauth_index, mode=mode, ), css_class="api-help", show_sidebar=False, show_firsttext=False).render()