Use more docstrings as descriptions

This commit is contained in:
Joel Collins 2019-11-20 12:08:25 +00:00
parent d3f2807bb9
commit 9b387985e3
12 changed files with 88 additions and 59 deletions

View file

@ -5,6 +5,23 @@ from collections import abc
from functools import reduce
from contextlib import contextmanager
def bottom_level_name(obj):
return obj.__name__.split('.')[-1]
def description_from_view(view_class):
methods = []
for method_key in ["get", "post", "put", "delete"]:
if hasattr(view_class, method_key):
methods.append(method_key.upper())
brief_description = get_docstring(view_class).partition('\n')[0].strip()
d = {
"methods": methods,
"description": brief_description
}
return d
def get_docstring(obj):
ds = obj.__doc__
if ds: