class ListTable(OutputTable): def __init__(self, imported_table, widths=None, indent=0): self.table = imported_table self.indent = indent if widths is not None: self.widths = [str(i) for i in widths] else: self.widths = None self.r = RstCloth() self._render_table() self.output = self.r.data def _render_table(self): b = '_all' rows = [] _fields = [] if self.table.header is not None: _fields.append(('header-rows', '1')) rows.append(self.table.header[0]) idx = 0 else: idx = 1 if self.widths is not None: _fields.append(('widths', ' '.join(self.widths))) rows.extend(self.table.rows) self.r.directive('list-table', fields=_fields, indent=self.indent, block=b) self.r.newline(block=b) for row in rows: r = row[idx] self.r.li(r[0], bullet='* -', indent=self.indent + 3, wrap=False, block=b) self.r.newline(block=b) for cell in r[1:]: self.r.li(cell, bullet=' -', indent=self.indent + 3, wrap=False, block=b) self.r.newline(block=b) idx += 1
class ListTable(OutputTable): def __init__(self, imported_table, widths=None, indent=0): self.table = imported_table self.indent = indent if widths is not None: self.widths = [ str(i) for i in widths ] else: self.widths = None self.r = RstCloth() self._render_table() self.output = self.r.data def _render_table(self): b = '_all' rows = [] _fields = [] if self.table.header is not None: _fields.append(('header-rows', '1')) rows.append(self.table.header[0]) idx = 0 else: idx = 1 if self.widths is not None: _fields.append(('widths', ' '.join(self.widths))) rows.extend(self.table.rows) self.r.directive('list-table', fields=_fields, indent=self.indent, block=b) self.r.newline(block=b) for row in rows: r = row[idx] self.r.li(r[0], bullet='* -', indent=self.indent + 3, wrap=False, block=b) self.r.newline(block=b) for cell in r[1:]: self.r.li(cell, bullet=' -', indent=self.indent + 3, wrap=False, block=b) self.r.newline(block=b) idx += 1
def build_page(data, conf): fn = os.path.join(conf.paths.projectroot, conf.paths.includes, 'metadata.yaml') if not os.path.exists(fn): return None else: iconf = BuildConfiguration(fn) r = RstCloth() r.title(iconf.title) r.newline() r.directive('default-domain', iconf.domain) r.newline() if 'introduction' in iconf: r.content(iconf.introduction) r.newline() r.directive(name='contents', arg='Included Files', fields=[ ('backlinks', 'none'), ('class', 'long-toc'), ('depth', 1), ('local', ''), ]) r.newline() data = data.items() data.sort() for _, record in data: page_name = r.pre(record['name']) r.heading(text=page_name, char='-', indent=0) r.newline() r.heading('Meta', char='~', indent=0) r.newline() if record['num_clients'] == 0: r.content('{0} is not included in any files.'.format(page_name)) r.newline() add_content(r, record) elif record['num_clients'] == 1: if record['yaml_only']: r.content('{0} is only included in yaml files.'.format(page_name)) r.newline() else: link = r.role('doc', record['clients'][0]) r.content('{0} is only included in {1}.'.format(page_name, link)) r.newline() add_meta(r, page_name, record) add_content(r, record) else: r.content('{0} is included in **{1}** files.'.format(page_name, record['num_clients']), wrap=False) r.newline() add_meta(r, page_name, record) if record['yaml_only'] is False: clients = [ p for p in record['clients'] if not p.startswith('/includes') ] if len(clients) == 1: client_link = r.role('doc', clients[0]) inc_str = '{0} is the only file that includes {1} that is not also an include.' r.content(inc_str.format(client_link, page_name)) r.newline() else: r.heading('Client Pages', char='~', indent=0) r.newline() for pg in clients: client_link = r.role('doc', pg) r.li(client_link, wrap=False) r.newline() add_include_example(r, page_name, record['path']) add_content(r, record) return r
def build_page(data, conf): fn = os.path.join(conf.paths.projectroot, conf.paths.includes, 'metadata.yaml') if not os.path.exists(fn): return None else: iconf = BuildConfiguration(fn) r = RstCloth() r.title(iconf.title) r.newline() r.directive('default-domain', iconf.domain) r.newline() if 'introduction' in iconf: r.content(iconf.introduction) r.newline() r.directive(name='contents', arg='Included Files', fields=[ ('backlinks', 'none'), ('class', 'long-toc'), ('depth', 1), ('local', ''), ]) r.newline() data = data.items() data.sort() for _, record in data: page_name = r.pre(record['name']) r.heading(text=page_name, char='-', indent=0) r.newline() r.heading('Meta', char='~', indent=0) r.newline() if record['num_clients'] == 0: r.content('{0} is not included in any files.'.format(page_name)) r.newline() add_content(r, record) elif record['num_clients'] == 1: if record['yaml_only']: r.content( '{0} is only included in yaml files.'.format(page_name)) r.newline() else: link = r.role('doc', record['clients'][0]) r.content('{0} is only included in {1}.'.format( page_name, link)) r.newline() add_meta(r, page_name, record) add_content(r, record) else: r.content('{0} is included in **{1}** files.'.format( page_name, record['num_clients']), wrap=False) r.newline() add_meta(r, page_name, record) if record['yaml_only'] is False: clients = [ p for p in record['clients'] if not p.startswith('/includes') ] if len(clients) == 1: client_link = r.role('doc', clients[0]) inc_str = '{0} is the only file that includes {1} that is not also an include.' r.content(inc_str.format(client_link, page_name)) r.newline() else: r.heading('Client Pages', char='~', indent=0) r.newline() for pg in clients: client_link = r.role('doc', pg) r.li(client_link, wrap=False) r.newline() add_include_example(r, page_name, record['path']) add_content(r, record) return r
def build_page(data, conf): fn = os.path.join(conf.paths.projectroot, conf.paths.includes, "metadata.yaml") if not os.path.exists(fn): return None else: iconf = BuildConfiguration(fn) r = RstCloth() r.title(iconf.title) r.newline() r.directive("default-domain", iconf.domain) r.newline() if "introduction" in iconf: r.content(iconf.introduction) r.newline() r.directive( name="contents", arg="Included Files", fields=[("backlinks", "none"), ("class", "long-toc"), ("depth", 1), ("local", "")], ) r.newline() data = data.items() data.sort() for _, record in data: page_name = r.pre(record["name"]) r.heading(text=page_name, char="-", indent=0) r.newline() r.heading("Meta", char="~", indent=0) r.newline() if record["num_clients"] == 0: r.content("{0} is not included in any files.".format(page_name)) r.newline() add_content(r, record) elif record["num_clients"] == 1: if record["yaml_only"]: r.content("{0} is only included in yaml files.".format(page_name)) r.newline() else: link = r.role("doc", record["clients"][0]) r.content("{0} is only included in {1}.".format(page_name, link)) r.newline() add_meta(r, page_name, record) add_content(r, record) else: r.content("{0} is included in **{1}** files.".format(page_name, record["num_clients"]), wrap=False) r.newline() add_meta(r, page_name, record) if record["yaml_only"] is False: clients = [p for p in record["clients"] if not p.startswith("/includes")] if len(clients) == 1: client_link = r.role("doc", clients[0]) inc_str = "{0} is the only file that includes {1} that is not also an include." r.content(inc_str.format(client_link, page_name)) r.newline() else: r.heading("Client Pages", char="~", indent=0) r.newline() for pg in clients: client_link = r.role("doc", pg) r.li(client_link, wrap=False) r.newline() add_include_example(r, page_name, record["path"]) add_content(r, record) return r