def with_header(header=None):
 def wrap(func):
  @functools.wraps(func)
  def wrapped(cls, remaining_attrs):
   result = list(func(cls, remaining_attrs))
   if result:
    (yield u'')
    (yield u'.. raw:: html')
    (yield u'')
    (yield u'    <hr>')
    (yield u'')
    if header:
     (yield (header + u':'))
     (yield u'')
    for row in result:
     (yield row)
  return wrapped
 return wrap

def with_header ( header = None ) : def wrap ( func ) : @ functools . wraps ( func ) def wrapped ( cls , remaining_attrs ) : result = list ( func ( cls , remaining_attrs ) ) if result : ( yield u'' ) ( yield u'.. raw:: html' ) ( yield u'' ) ( yield u'    <hr>' ) ( yield u'' ) if header : ( yield ( header + u':' ) ) ( yield u'' ) for row in result : ( yield row ) return wrapped return wrap
decorator that adds a section header if theres a any output the decorated function should yield output lines; if there are any the header gets added .