本文整理汇总了Python中django.contrib.admindocs.utils.parse_docstring方法的典型用法代码示例。如果您正苦于以下问题:Python utils.parse_docstring方法的具体用法?Python utils.parse_docstring怎么用?Python utils.parse_docstring使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.admindocs.utils
的用法示例。
在下文中一共展示了utils.parse_docstring方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_context_data
# 需要导入模块: from django.contrib.admindocs import utils [as 别名]
# 或者: from django.contrib.admindocs.utils import parse_docstring [as 别名]
def get_context_data(self, **kwargs):
view = self.kwargs['view']
urlconf = urlresolvers.get_urlconf()
if urlresolvers.get_resolver(urlconf)._is_callback(view):
mod, func = urlresolvers.get_mod_func(view)
view_func = getattr(import_module(mod), func)
else:
raise Http404
title, body, metadata = utils.parse_docstring(view_func.__doc__)
if title:
title = utils.parse_rst(title, 'view', _('view:') + view)
if body:
body = utils.parse_rst(body, 'view', _('view:') + view)
for key in metadata:
metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view)
kwargs.update({
'name': view,
'summary': title,
'body': body,
'meta': metadata,
})
return super(ViewDetailView, self).get_context_data(**kwargs)
示例2: get_context_data
# 需要导入模块: from django.contrib.admindocs import utils [as 别名]
# 或者: from django.contrib.admindocs.utils import parse_docstring [as 别名]
def get_context_data(self, **kwargs):
view = self.kwargs['view']
view_func = self._get_view_func(view)
if view_func is None:
raise Http404
title, body, metadata = utils.parse_docstring(view_func.__doc__)
if title:
title = utils.parse_rst(title, 'view', _('view:') + view)
if body:
body = utils.parse_rst(body, 'view', _('view:') + view)
for key in metadata:
metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view)
kwargs.update({
'name': view,
'summary': title,
'body': body,
'meta': metadata,
})
return super(ViewDetailView, self).get_context_data(**kwargs)
示例3: doc_functions
# 需要导入模块: from django.contrib.admindocs import utils [as 别名]
# 或者: from django.contrib.admindocs.utils import parse_docstring [as 别名]
def doc_functions(request):
group_list = []
for group_name, functions in AVAILABLE_API_FUNCTIONS.items():
function_list = []
for name, function in functions.items():
heading, body, metadata = parse_docstring(function.__doc__)
body = trim_docstring(body)
function_list.append({
'name': name,
'description': build_function_description(function),
'docstring': trim_docstring(
'{0}\n\n{1}'.format(heading, body)
),
})
function_list.sort(key=itemgetter('name'))
group_list.append({
'name': group_name,
'function_list': function_list
})
group_list.sort(key=itemgetter('name'))
return TemplateResponse(request, 'api/list_functions.html', {
'group_list': group_list
})
示例4: view_detail
# 需要导入模块: from django.contrib.admindocs import utils [as 别名]
# 或者: from django.contrib.admindocs.utils import parse_docstring [as 别名]
def view_detail(request, view):
if not utils.docutils_is_available:
return missing_docutils_page(request)
mod, func = urlresolvers.get_mod_func(view)
try:
view_func = getattr(import_module(mod), func)
except (ImportError, AttributeError):
raise Http404
title, body, metadata = utils.parse_docstring(view_func.__doc__)
if title:
title = utils.parse_rst(title, 'view', _('view:') + view)
if body:
body = utils.parse_rst(body, 'view', _('view:') + view)
for key in metadata:
metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view)
return render_to_response('admin_doc/view_detail.html', {
'root_path': urlresolvers.reverse('admin:index'),
'name': view,
'summary': title,
'body': body,
'meta': metadata,
}, context_instance=RequestContext(request))
示例5: get_context_data
# 需要导入模块: from django.contrib.admindocs import utils [as 别名]
# 或者: from django.contrib.admindocs.utils import parse_docstring [as 别名]
def get_context_data(self, **kwargs):
view = self.kwargs['view']
urlconf = get_urlconf()
if get_resolver(urlconf)._is_callback(view):
mod, func = get_mod_func(view)
view_func = getattr(import_module(mod), func)
else:
raise Http404
title, body, metadata = utils.parse_docstring(view_func.__doc__)
if title:
title = utils.parse_rst(title, 'view', _('view:') + view)
if body:
body = utils.parse_rst(body, 'view', _('view:') + view)
for key in metadata:
metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view)
kwargs.update({
'name': view,
'summary': title,
'body': body,
'meta': metadata,
})
return super(ViewDetailView, self).get_context_data(**kwargs)