def fieldset_renderer(widget, data): fs_attrs = { 'id': cssid(widget, 'fieldset'), 'class_': cssclasses(widget, data) } rendered = data.rendered if widget.attrs['legend']: rendered = data.tag('legend', widget.attrs['legend']) + rendered return data.tag('fieldset', rendered, **fs_attrs) factory.register( 'fieldset', extractors=factory.extractors('compound'), edit_renderers=factory.edit_renderers('compound') + [fieldset_renderer], display_renderers=factory.display_renderers('compound') + \ [fieldset_renderer]) factory.doc['blueprint']['fieldset'] = """\ Renders a fieldset around the prior rendered output. """ factory.defaults['fieldset.legend'] = False factory.defaults['fieldset.class'] = None @managedprops('action', 'method', 'enctype', *css_managed_props) def form_edit_renderer(widget, data): form_attrs = { 'action': widget.attrs['action'],
def _doc_property(self, wpname): blueprint_name, prop = wpname.split('.') table = """ +----------+---------+-------------+ | name | default | description | +==========+=========+=============+ | replace | replace | replace | +----------+---------+-------------+ """ table = self._rest2node(table) row = table.children[0].children[0].children[4].children[0] row[0].children = [] row[1].children = [] row[2].children = [] row[0].append(nodes.paragraph(text=prop)) default = factory.defaults.get(wpname, _marker) if default is not _marker: row[1].append(nodes.literal(text=repr(default))) else: default = factory.defaults.get(prop, _marker) if default is not _marker: row[1].append(nodes.literal(text=repr(default))) row[1].append(nodes.emphasis(text=' global')) else: row[1].append(nodes.emphasis(text='required/ not set')) doc = factory.doc['props'].get(wpname, factory.doc['props'].get(prop, _marker)) if doc is not _marker: row[2].append(self._rest2node(doc)) else: row[2].append(nodes.paragraph('(not documented)')) # this does not log. bullshit. no idea how to make sphinx log print "YAFOWIL property '%s' is not documented!" % wpname ul = nodes.bullet_list() used = [] def add_chain_for_property(chain): for el in chain: if prop not in getattr(el, '__yafowil_managed_props__', []): #if getattr(el, '__yafowil_managed_props__', True): #print ('YAFOWIL callable %s has no ' % el, # 'managed props decorator!') continue li = nodes.list_item() if hasattr(el, 'func_name'): # function name = el.func_name else: # class name = el.__class__.__name__ if name in used: continue used.append(name) li.append(nodes.paragraph(text=name)) ul.append(li) add_chain_for_property(factory.extractors(blueprint_name)) add_chain_for_property(factory.edit_renderers(blueprint_name)) add_chain_for_property(factory.display_renderers(blueprint_name)) add_chain_for_property(factory.builders(blueprint_name)) add_chain_for_property(factory.preprocessors(blueprint_name)) if not used: print "YAFOWIL property '%s' is not handled by managed props!" % \ wpname if (len(ul)): row[2].append(nodes.strong(text='Used by:')) row[2].append(ul) return row
@managedprops('id', *css_managed_props) def table_renderer(widget, data): attrs = { 'id': widget.attrs.get('id'), 'class_': cssclasses(widget, data), } return data.tag('table', data.rendered, **attrs) factory.register( 'table', extractors=factory.extractors('compound'), edit_renderers=factory.edit_renderers('compound') + [table_renderer], display_renderers=factory.display_renderers('compound') + [table_renderer]) factory.doc['blueprint']['table'] = """\ ``<table>`` compound widget for table creation. """ def thead_renderer(widget, data): return data.tag('thead', data.rendered) factory.register( 'thead', extractors=factory.extractors('compound'), edit_renderers=factory.edit_renderers('compound') + [thead_renderer], display_renderers=factory.display_renderers('compound') + [thead_renderer])
def _doc_property(self, wpname): blueprint_name, prop = wpname.split('.') table = """ +----------+---------+-------------+ | name | default | description | +==========+=========+=============+ | replace | replace | replace | +----------+---------+-------------+ """ table = self._rest2node(table) row = table.children[0].children[0].children[4].children[0] row[0].children = [] row[1].children = [] row[2].children = [] row[0].append(nodes.paragraph(text=prop)) default = factory.defaults.get(wpname, _marker) if default is not _marker: row[1].append(nodes.literal(text=repr(default))) else: default = factory.defaults.get(prop, _marker) if default is not _marker: row[1].append(nodes.literal(text=repr(default))) row[1].append(nodes.emphasis(text=' global')) else: row[1].append(nodes.emphasis(text='required/ not set')) doc = factory.doc['props'].get(wpname, factory.doc['props'].get(prop, _marker)) if doc is not _marker: row[2].append(self._rest2node(doc)) else: row[2].append(nodes.paragraph('(not documented)')) # this does not log. bullshit. no idea how to make sphinx log print("YAFOWIL property '%s' is not documented!" % wpname) ul = nodes.bullet_list() used = [] def add_chain_for_property(chain): for el in chain: if prop not in getattr(el, '__yafowil_managed_props__', []): #if getattr(el, '__yafowil_managed_props__', True): #print ('YAFOWIL callable %s has no ' % el, # 'managed props decorator!') continue li = nodes.list_item() if hasattr(el, 'func_name'): # function name = el.func_name else: # class name = el.__class__.__name__ if name in used: continue used.append(name) li.append(nodes.paragraph(text=name)) ul.append(li) add_chain_for_property(factory.extractors(blueprint_name)) add_chain_for_property(factory.edit_renderers(blueprint_name)) add_chain_for_property(factory.display_renderers(blueprint_name)) add_chain_for_property(factory.builders(blueprint_name)) add_chain_for_property(factory.preprocessors(blueprint_name)) if not used: print("YAFOWIL property '%s' is not handled by managed props!" % \ wpname) if (len(ul)): row[2].append(nodes.strong(text='Used by:')) row[2].append(ul) return row