Titlecase looks nicer sometimes in detailed mode
Instead of having lowercase sections it can be quite nice to at least have titled sections (which seems to be more of the normal way rst sections are written). Change-Id: I6754937a7d0d837de9166b3246659711e262be6c
This commit is contained in:
parent
f92ce6a38b
commit
710f88e3b1
@ -36,12 +36,15 @@ def _simple_list(mgr):
|
||||
ext.entry_point.module_name)
|
||||
|
||||
|
||||
def _detailed_list(mgr, over='', under='-'):
|
||||
def _detailed_list(mgr, over='', under='-', titlecase=False):
|
||||
for name in sorted(mgr.names()):
|
||||
ext = mgr[name]
|
||||
if over:
|
||||
yield (over * len(ext.name), ext.entry_point.module_name)
|
||||
yield (ext.name, ext.entry_point.module_name)
|
||||
if titlecase:
|
||||
yield (ext.name.title(), ext.entry_point.module_name)
|
||||
else:
|
||||
yield (ext.name, ext.entry_point.module_name)
|
||||
if under:
|
||||
yield (under * len(ext.name), ext.entry_point.module_name)
|
||||
yield ('\n', ext.entry_point.module_name)
|
||||
@ -61,6 +64,7 @@ class ListPluginsDirective(rst.Directive):
|
||||
option_spec = {
|
||||
'class': directives.class_option,
|
||||
'detailed': directives.flag,
|
||||
'titlecase': directives.flag,
|
||||
'overline-style': directives.single_char_or_unicode,
|
||||
'underline-style': directives.single_char_or_unicode,
|
||||
}
|
||||
@ -86,9 +90,12 @@ class ListPluginsDirective(rst.Directive):
|
||||
|
||||
result = ViewList()
|
||||
|
||||
titlecase = 'titlecase' in self.options
|
||||
|
||||
if 'detailed' in self.options:
|
||||
data = _detailed_list(
|
||||
mgr, over=overline_style, under=underline_style)
|
||||
mgr, over=overline_style, under=underline_style,
|
||||
titlecase=titlecase)
|
||||
else:
|
||||
data = _simple_list(mgr)
|
||||
for text, source in data:
|
||||
|
Loading…
Reference in New Issue
Block a user