コード例 #1
0
def test_select_groupedflowables():
    empty = StaticGroupedFlowables([])
    not_empty = StaticGroupedFlowables([empty])

    empty_selector = StaticGroupedFlowables.like(empty=True)
    not_empty_selector = StaticGroupedFlowables.like(empty=False)

    assert empty_selector.match(empty, stylesheet, document)
    assert not_empty_selector.match(not_empty, stylesheet, document)

    assert not empty_selector.match(not_empty, stylesheet, document)
    assert not not_empty_selector.match(empty, stylesheet, document)
コード例 #2
0
 def write_doc(self, docname, doctree, docnames, targetname):
     rinoh_tree = from_doctree(doctree, sphinx_builder=self)
     template_cfg = self.template_from_config(logger)
     rinoh_document = template_cfg.document(rinoh_tree)
     extra_indices = StaticGroupedFlowables(self.generate_indices(docnames))
     # TODO: use out-of-line flowables?
     rinoh_document.insert('back_matter', extra_indices, 0)
     self.set_document_metadata(rinoh_document, doctree)
     outfilename = path.join(self.outdir, os_path(targetname))
     ensuredir(path.dirname(outfilename))
     rinoh_document.render(outfilename)
コード例 #3
0
ファイル: __main__.py プロジェクト: wxtim/rinohtype
 def typeface_section(typeface, distribution):
     group_style = GroupedFlowablesStyle(space_below=10 * PT)
     title_style = ParagraphStyle(keep_with_next=True,
                                  tab_stops='100% RIGHT',
                                  border_bottom='0.5pt, #000',
                                  padding_bottom=1 * PT,
                                  space_below=2 * PT)
     title = Paragraph('{}\t[{}]'.format(typeface.name, distribution),
                       style=title_style)
     return StaticGroupedFlowables(
         [title] +
         [font_paragraph(typeface, font) for font in typeface.fonts()],
         style=group_style)
コード例 #4
0
ファイル: __init__.py プロジェクト: ChrisJrWilliams/rinohtype
 def write_doc(self, docname, doctree, docnames, targetname):
     config = self.config
     rinoh_tree = from_doctree(doctree['source'],
                               doctree,
                               source_root=Path(self.srcdir),
                               sphinx_builder=self)
     template_cfg = template_from_config(config, self.confdir,
                                         logger.warning)
     rinoh_document = template_cfg.document(rinoh_tree)
     extra_indices = StaticGroupedFlowables(self.generate_indices(docnames))
     rinoh_document.insert('back_matter', extra_indices, 0)
     set_document_metadata(rinoh_document, config, doctree)
     outfilename = path.join(self.outdir, os_path(targetname))
     ensuredir(path.dirname(outfilename))
     rinoh_document.render(outfilename)
コード例 #5
0
ファイル: __init__.py プロジェクト: foster999/rinohtype
    def construct_rinohtype_document(self, document_data):
        doc = document_data.pop('doc')
        toctree_only = document_data.pop('toctree_only', False)
        template = document_data.pop('template', 'book')
        domain_indices = document_data.pop('domain_indices', True)

        doctree, docnames = self.assemble_doctree(doc, toctree_only)
        self.preprocess_tree(doctree)
        self.post_process_images(doctree)
        rinoh_tree = from_doctree(doctree, sphinx_builder=self)
        rinoh_template = self.template_configuration(template, logger)
        rinoh_document = rinoh_template.document(rinoh_tree)
        extra_indices = StaticGroupedFlowables(
            self.generate_indices(docnames, domain_indices))
        # TODO: use out-of-line flowables?
        rinoh_document.insert('back_matter', extra_indices, 0)
        self.set_document_metadata(rinoh_document, document_data)
        return rinoh_document
コード例 #6
0
ファイル: __init__.py プロジェクト: z00sts/rinohtype
 def write_doc(self, docname, doctree, docnames, targetname):
     config = self.config
     parser = ReStructuredTextReader()
     rinoh_tree = parser.from_doctree(doctree['source'], doctree)
     template_cfg = template_from_config(config, self.confdir, self.warn)
     rinoh_document = template_cfg.document(rinoh_tree)
     extra_indices = StaticGroupedFlowables(self.generate_indices(docnames))
     rinoh_document.insert('back_matter', extra_indices, 0)
     rinoh_logo = config.rinoh_logo
     if rinoh_logo:
         rinoh_document.metadata['logo'] = rinoh_logo
     rinoh_document.metadata['title'] = doctree.settings.title
     rinoh_document.metadata['subtitle'] = ('Release {}'
                                            .format(config.release))
     rinoh_document.metadata['author'] = doctree.settings.author
     outfilename = path.join(self.outdir, os_path(targetname))
     ensuredir(path.dirname(outfilename))
     rinoh_document.render(outfilename)
コード例 #7
0
 def write_doc(self, docname, doctree, docnames, targetname):
     config = self.config
     suffix, = config.source_suffix
     source_path = os.path.join(self.srcdir, docname + suffix)
     parser = ReStructuredTextReader()
     rinoh_tree = parser.from_doctree(source_path, doctree)
     rinoh_document_template = config.rinoh_document_template
     template = (DocumentTemplate.from_string(rinoh_document_template)
                 if isinstance(rinoh_document_template, str) else
                 rinoh_document_template)
     if isinstance(self.config.rinoh_stylesheet, str):
         stylesheet = StyleSheet.from_string(self.config.rinoh_stylesheet)
     elif self.config.rinoh_stylesheet is None:
         stylesheet = template.Configuration.stylesheet.default_value
     else:
         stylesheet = self.config.rinoh_stylesheet
     if config.pygments_style is not None:
         stylesheet = pygments_style_to_stylesheet(config.pygments_style,
                                                   stylesheet)
     paper_size = config.rinoh_paper_size
     base_config = template.Configuration(paper_size=paper_size,
                                          stylesheet=stylesheet)
     if config.rinoh_template_configuration is not None:
         template_configuration = config.rinoh_template_configuration
         if template_configuration.base is None:
             template_configuration.base = base_config
     else:
         template_configuration = base_config
     rinoh_document = template(rinoh_tree,
                               configuration=template_configuration,
                               backend=pdf)
     extra_indices = StaticGroupedFlowables(self.generate_indices(docnames))
     rinoh_document.insert('indices', extra_indices, 0)
     rinoh_logo = config.rinoh_logo
     if rinoh_logo:
         rinoh_document.metadata['logo'] = rinoh_logo
     rinoh_document.metadata['title'] = doctree.settings.title
     rinoh_document.metadata['subtitle'] = ('Release {}'.format(
         config.release))
     rinoh_document.metadata['author'] = doctree.settings.author
     outfilename = path.join(self.outdir, os_path(targetname))
     ensuredir(path.dirname(outfilename))
     rinoh_document.render(outfilename)
コード例 #8
0
ファイル: __init__.py プロジェクト: CantemoInternal/rinohtype
 def write_doc(self, docname, doctree, docnames, targetname):
     config = self.config
     rinoh_tree = from_doctree(doctree['source'],
                               doctree,
                               sphinx_builder=self)
     template_cfg = template_from_config(config, self.confdir,
                                         logger.warning)
     rinoh_document = template_cfg.document(rinoh_tree)
     extra_indices = StaticGroupedFlowables(self.generate_indices(docnames))
     rinoh_document.insert('back_matter', extra_indices, 0)
     rinoh_logo = config.rinoh_logo
     if rinoh_logo:
         rinoh_document.metadata['logo'] = rinoh_logo
     rinoh_document.metadata['title'] = doctree.settings.title
     rinoh_document.metadata['subtitle'] = ('Release {}'.format(
         config.release))
     rinoh_document.metadata['author'] = doctree.settings.author
     date = config.today or format_date(config.today_fmt or _('%b %d, %Y'),
                                        language=config.language)
     rinoh_document.metadata['date'] = date
     outfilename = path.join(self.outdir, os_path(targetname))
     ensuredir(path.dirname(outfilename))
     rinoh_document.render(outfilename)
コード例 #9
0
ファイル: test_style.py プロジェクト: wxtim/rinohtype
emphasized2 = SingleStyledText('emphasized 2', style='emphasis2')
paragraph = Paragraph('A paragraph with ' + emphasized + ' text.')
paragraph2 = Paragraph('A second paragraph with ' + emphasized2 + ' text.',
                       style='paragraph2')
emphasized3 = SingleStyledText('emphasized 3', style='emphasis2')
paragraph3 = Paragraph('A third paragraph with ' + emphasized3 + ' text.',
                       style='paragraph3')
paragraph4 = Paragraph('A fourth paragraph.', style='paragraph4')
paragraph5 = Paragraph(
    'A paragraph for which no style is present in the '
    'style sheet',
    style='missing')
paragraph6 = Paragraph('A sixth paragraph with ' + highlighted + ' text.')
paragraph7 = Paragraph('A seventh paragraph with ' + highlighted2 + ' text.',
                       style='paragraph7')
grouped1 = StaticGroupedFlowables([paragraph6, paragraph7], style='grouped1')

doctree = DocumentTree(
    [paragraph, paragraph2, paragraph3, paragraph4, paragraph5, grouped1])

document = Document(doctree, ssheet2, EN)
container = FakeContainer(document)


def test_style():
    style = ssheet1['emphasized text']
    assert style.font_width == FontWidth.NORMAL
    assert style.font_slant == FontSlant.ITALIC
    assert style.font_size == Var('font-size')

    style = ssheet1['emphasized text 2']
コード例 #10
0
 def parse(self):
     content = [element.parse() for element in self.getchildren()]
     note = Note(StaticGroupedFlowables(content), id=None)
     return NoteMarkerWithNote(note)
コード例 #11
0
 def parse(self):
     return StaticGroupedFlowables(
         [item.process() for item in self.getchildren()], style=self.style)