Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def menu2rst(self, ar, mnu, level=1):
"""Used by :meth:`show_menu`."""
if not isinstance(mnu, Menu):
return str(mnu.label)
has_submenus = False
for i in mnu.items:
if isinstance(i, Menu):
has_submenus = True
items = [self.menu2rst(ar, mi, level + 1) for mi in mnu.items]
if has_submenus:
s = rstgen.ul(items).strip() + '\n'
if mnu.label is not None:
s = str(mnu.label) + ' :\n\n' + s
else:
s = ', '.join(items)
if mnu.label is not None:
s = str(mnu.label) + ' : ' + s
return s
field=title, model=model_ref(fld.model)))
s += '\n\n'
s += rstgen.header(level, _("%s (field)") % title)
if len(self.content) > 1:
s += '\n'.join(self.content[1:])
s += '\n\n'
return s
if isinstance(cls, Plugin):
s = ''
title = str(cls.verbose_name)
s += "\n.. index::\n single: "
s += str(_('%s (app)') % title)
s += '\n\n.. _' + name + ':\n'
s += '\n'
s += rstgen.header(level, _("%s (app)") % title)
return s
if not isinstance(cls, type):
raise Exception("%s is not an actor." % self.content[0])
if issubclass(cls, models.Model):
model = cls
s = ''
name = model_name(model).lower()
title = force_text(model._meta.verbose_name)
s += "\n.. index::\n single: "
s += str(_('%(model)s (model in %(app)s)') % dict(
model=title, app=model._meta.app_label))
s += '\n\n'