def test_other(self): c = Converter('Man', file='diff.man') c.translate() text = c.html.render() text = c.change_special_symbols(text) doc = tags.html(lang='en') doc = add_head(doc) doc_body = tags.body() row = tags.div(cls='row') row = add_row(row, 'GCC(1)', '', 'GCC(1)') doc_body.add(row) with doc_body: paragraph = tags.p() paragraph.add(tags.br()) paragraph.add('\n\\f(CW c c-header cpp-output\\fP') paragraph.add(tags.br()) paragraph.add(tags.br()) def_list = tags.dl() def_termin = tags.dt() def_termin.add('\n') def_termin.add('\\fB-x none\\fR') def_def = tags.dd(cls='indent') def_def.add('\nstandard_output.') def_list.add(def_termin) def_list.add(def_def) row = tags.div(cls='row') row = add_row(row, '', '2018-07-20', 'GCC(1)') doc_body.add(row) doc.add(doc_body) doc = c.change_special_symbols(doc.render()) self.assertEqual(doc, text)
def _create_description(self, label, value, unit=None, tolerance=None): label = self._create_label(label, unit) dt = tags.dt(raw(label)) value = self._format_value(value, unit, tolerance) dd = tags.dd(value) return [dt, dd]
def test_file_structure(self): c = Converter('Man', file='structured_file.man') c.translate() text = c.html.render() text = c.change_special_symbols(text) doc = tags.html(lang='en') doc = add_head(doc) doc_body = tags.body() row = tags.div(cls='row') row = add_row(row, 'BASH(1)', '', 'BASH(1)') doc_body.add(row) with doc_body: tags.h2('NAME') content = tags.div(cls='content') paragraph = tags.p() paragraph += '\ngrep, egrep, fgrep, rgrep' content.add(paragraph) content.add(tags.h4('Simple Commands')) content2 = tags.div(cls='content') content2.add(tags.br()) paragraph = tags.p() paragraph += '\nA \\fIsimple command\\fP' content2.add(paragraph) def_list = tags.dl() def_termin = tags.dt() def_termin.add('\nInterpret') def_list.add(def_termin) def_list.add(tags.dd(cls='indent')) content2.add(def_list) def_list = tags.dl() def_termin = tags.dt(cls='short') def_termin.add((tags.b('%%'))) def_list.add(def_termin) def_def = tags.dd(cls='indent') def_def.add('\nA literal') def_list.add(def_def) content2.add(def_list) content.add(content2) row = tags.div(cls='row') row = add_row(row, 'GNU Bash 4.4', '2016-08-26', 'BASH(1)') doc_body.add(row) doc.add(doc_body) doc = c.change_special_symbols(doc.render()) self.assertEqual(doc, text)
def add_indent_paragraph(self, line): line = self.select_quotes(self.remove_operator(line)) if len(line) > 1: self.indent = int(line[1]) self.paragraph = None if self.div_subheader: par = self.div_subheader.add(tags.dl()) elif self.div_header: par = self.div_header.add(tags.dl()) else: par = self.body.add(tags.dl()) if len(line[0]) < self.indent: self.paragraph = par.add(tags.dt(cls='short')) else: self.paragraph = par.add(tags.dt()) if not self.process_line(line[0]): self.add_roman(line[0]) self.paragraph = par.add(tags.dd(cls='indent'))
def add_hanging_paragraph(self, line): x = self.remove_operator(line) if x: self.indent = int(x) self.paragraph = None if self.div_subheader: par = self.div_subheader.add(tags.dl()) elif self.div_header: par = self.div_header.add(tags.dl()) else: par = self.body.add(tags.dl()) next_line = next(self.iterator) if len(self.remove_operator(next_line)) < self.indent: self.paragraph = par.add(tags.dt(cls='short')) else: self.paragraph = par.add(tags.dt()) if not self.process_line(next_line): self.add_roman(next_line) self.paragraph = par.add(tags.dd(cls='indent'))
def position_pretablehtml(): pretablehtml = div() with pretablehtml: # hide / show hidden rows with filtercontainerdiv(style='margin-bottom: 4px;'): datefilter = filterdiv('positiondate-external-filter-startdate', 'In Position On') with datefilter: input(type='text', id='effective-date', name='effective-date') button('Today', id='todays-date-button') # make dom repository for Editor wizard standalone form with div(style='display: none;'): dd(**{'data-editor-field': 'position_id'}) dd(**{'data-editor-field': 'effective'}) dd(**{'data-editor-field': 'members'}) return pretablehtml.render()
def dump_dict(dl, d): for key, value in d.items(): dl.add(t.dt(key)) dl.add(t.dd(dump_single_val(value)))
return ul else: return str(value) def dump_dict(dl, d): for key, value in d.items(): dl.add(t.dt(key)) dl.add(t.dd(dump_single_val(value))) for item in allobjs: div = t.div(cls="entry") div.add(t.a("{", name=item.ptr)) dl = t.dl() dl.add(t.dt("Inferred name:")) dl.add(t.dd(str(item.name()))) dl.add(t.dt("Backrefs:")) refs = t.dd() for backref in item.backlinks: refs.add(text_or_ptr(backref.ptr)) refs.add(", ") dl.add(refs) dump_dict(dl, item.item) div.add(dl) doc.add(div) print("Writing to memorymap.html...") with open("memorymap.html", "w") as f: f.write(doc.render(pretty=False))