MCPcopy Index your code
hub / github.com/hugapi/hug / documentation

Method documentation

hug/api.py:224–270  ·  view source on GitHub ↗

Generates and returns documentation for this API endpoint

(self, base_url=None, api_version=None, prefix="")

Source from the content-addressed store, hash-verified

222 self.not_found_handlers[version] = handler
223
224 def documentation(self, base_url=None, api_version=None, prefix=""):
225 """Generates and returns documentation for this API endpoint"""
226 documentation = OrderedDict()
227 base_url = self.base_url if base_url is None else base_url
228 overview = self.api.doc
229 if overview:
230 documentation["overview"] = overview
231
232 version_dict = OrderedDict()
233 versions = self.versions
234 versions_list = list(versions)
235 if None in versions_list:
236 versions_list.remove(None)
237 if False in versions_list:
238 versions_list.remove(False)
239 if api_version is None and len(versions_list) > 0:
240 api_version = max(versions_list)
241 documentation["version"] = api_version
242 elif api_version is not None:
243 documentation["version"] = api_version
244 if versions_list:
245 documentation["versions"] = versions_list
246 for router_base_url, routes in self.routes.items():
247 for url, methods in routes.items():
248 for method, method_versions in methods.items():
249 for version, handler in method_versions.items():
250 if getattr(handler, "private", False):
251 continue
252 if version is None:
253 applies_to = versions
254 else:
255 applies_to = (version,)
256 for version in applies_to:
257 if api_version and version != api_version:
258 continue
259 if base_url and router_base_url != base_url:
260 continue
261 doc = version_dict.setdefault(url, OrderedDict())
262 doc[method] = handler.documentation(
263 doc.get(method, None),
264 version=version,
265 prefix=prefix,
266 base_url=router_base_url,
267 url=url,
268 )
269 documentation["handlers"] = version_dict
270 return documentation
271
272 def serve(self, host="", port=8000, no_documentation=False, display_intro=True):
273 """Runs the basic hug development server against this API"""

Callers 1

handle_404Method · 0.95

Calls 1

getMethod · 0.45

Tested by

no test coverage detected