Skip to content

Commit

Permalink
Rename SupportingMatter to OutOfLineFlowables
Browse files Browse the repository at this point in the history
  • Loading branch information
brechtm committed Nov 3, 2020
1 parent bbebef0 commit abfdc32
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 85 deletions.
8 changes: 4 additions & 4 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ New Features:
page break can be forced before any flowable.
* Enumerated list items with a hidden label ('hide' style attribute) are no
longer counted in the numbering.
* It's now possible to add arbitrary sections to the front/back matter by
adding a container with the 'supporting-matter' class and a name to reference
it by in the document template configuration, e.g. in the list of front
matter flowables (to be documented).
* It's now possible to add arbitrary reStructuredText content to the front/back
matter or elsewhere by adding a ``.. container::`` with the 'out-of-line'
class and a ``:name:`` to reference it by in the document template
configuration, e.g. in the list of front matter flowables (to be documented).
* Selectors in style sheet files (.rts) now support boolean and 'None' values.
For example, you can select StaticGroupedFlowables based on whether they have
any children or not: e.g ``TableCell(empty=true)`` selects empty table cells.
Expand Down
4 changes: 2 additions & 2 deletions src/rinoh/flowable.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
'FlowableWidth', 'HorizontalAlignment', 'Break',
'DummyFlowable', 'AnchorFlowable', 'WarnFlowable',
'SetMetadataFlowable', 'SetUserStringFlowable',
'SetSupportingMatter',
'SetOutOfLineFlowables',
'GroupedFlowables', 'StaticGroupedFlowables',
'LabeledFlowable', 'GroupedLabeledFlowables',
'Float', 'PageBreak']
Expand Down Expand Up @@ -415,7 +415,7 @@ def build_document(self, flowable_target):
doc.set_string(UserStrings, self.label, self.content)


class SetSupportingMatter(DummyFlowable):
class SetOutOfLineFlowables(DummyFlowable):
def __init__(self, names, flowables, parent=None):
super().__init__(parent=parent)
self.names = names
Expand Down
12 changes: 6 additions & 6 deletions src/rinoh/frontend/rst/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,20 +750,20 @@ def build_flowable(self):
class Container(DocutilsGroupingNode):
@property
def set_id(self):
return 'supporting-matter' not in self['classes']
return 'out-of-line' not in self['classes']

def build_flowable(self, style=None, **kwargs):
classes = self.get('classes')
if 'literal-block-wrapper' in classes:
return rt.CodeBlockWithCaption(self.children_flowables(),
style=style or self.style, **kwargs)
if 'supporting-matter' in classes:
if 'out-of-line' in classes:
names = self['names']
if not names:
raise MissingName('supporting-matter container is missing a'
' :name: to reference it by')
return rt.SetSupportingMatter(names, self.children_flowables(),
**kwargs)
raise MissingName('out-of-line container is missing a :name:'
' to reference it by')
return rt.SetOutOfLineFlowables(names, self.children_flowables(),
**kwargs)
return super().build_flowable(style, **kwargs)


Expand Down
4 changes: 2 additions & 2 deletions src/rinoh/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'TableOfContentsSection', 'TableOfContentsStyle', 'TableOfContents',
'ListOfStyle',
'TableOfContentsEntry', 'Admonition', 'AdmonitionStyle',
'HorizontalRule', 'HorizontalRuleStyle', 'SupportingMatter']
'HorizontalRule', 'HorizontalRuleStyle', 'OutOfLineFlowables']


class SectionTitles(StringCollection):
Expand Down Expand Up @@ -473,7 +473,7 @@ def render(self, container, descender, state, **kwargs):
return width, 0, 0


class SupportingMatter(GroupedFlowables):
class OutOfLineFlowables(GroupedFlowables):
def __init__(self, name, align=None, width=None, id=None, style=None,
parent=None):
super().__init__(align=align, width=width, id=id, style=style,
Expand Down
4 changes: 2 additions & 2 deletions src/rinoh/styleds.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .flowable import GroupedFlowables, StaticGroupedFlowables
from .flowable import LabeledFlowable, GroupedLabeledFlowables
from .flowable import DummyFlowable, AnchorFlowable, WarnFlowable
from .flowable import SetMetadataFlowable, SetSupportingMatter
from .flowable import SetMetadataFlowable, SetOutOfLineFlowables
from .highlight import CodeBlock, Token
from .index import IndexSection, Index, IndexLabel, IndexEntry
from .index import InlineIndexTarget, IndexTarget
Expand All @@ -27,7 +27,7 @@
from .structure import ListOfEntry
from .structure import Admonition
from .structure import TableOfContents, TableOfContentsEntry
from .structure import SupportingMatter
from .structure import OutOfLineFlowables
from .table import TableWithCaption, Table, TableSection, TableHead, TableBody
from .table import TableRow, TableCell, TableCellBackground, TableCellBorder
from .table import ListOfTables, ListOfTablesSection
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@
StaticGroupedFlowables()
#### DownExpandingContainer('floats')
StaticGroupedFlowables()
#### FlowablesContainer('chapter title')
Paragraph('Dedication', style='front matter section title')
> (0,0,1,0,2) front matter section title
(0,0,0,0,2) body
Field('Dedication')
SingleStyledText('Dedication')
#### ChainedContainer('column1')
StaticGroupedFlowables()
SupportingMatter(id='dedication')
Paragraph('For mommy') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-150/supportingmatter/index.rst:7 <paragraph>
> (0,0,0,0,2) body
MixedStyledText('For mommy')
SingleStyledText('For mommy')
Section(id='dedication')
> (0,0,0,1,2) dedication section
(0,0,0,1,2) chapter
OutOfLineFlowables()
Paragraph('For mommy') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-29/outoflineflowables/index.rst:7 <paragraph>
> (0,0,0,0,2) body
MixedStyledText('For mommy')
SingleStyledText('For mommy')
#### DownExpandingContainer('footer')
StaticGroupedFlowables()
Footer(' i')
Expand Down Expand Up @@ -69,38 +78,36 @@
> (0,0,0,0,2) table of contents
TableOfContentsEntry('1 Introduction 1')
> (0,0,0,1,2) toc level 1
MixedStyledText('1 Introduction 1')
ReferenceField('1')
x (0,0,0,1,3) toc linked reference
> (0,0,0,1,1) linked reference
SingleStyledText('1')
Tab(' ')
ReferenceField('Introduction')
x (0,0,0,1,3) toc linked reference
> (0,0,0,1,1) linked reference
SingleStyledText('Introduction')
Tab(' ')
ReferenceField('1')
x (0,0,0,1,3) toc linked reference
> (0,0,0,1,1) linked reference
SingleStyledText('1')
ReferenceField('1')
x (0,0,0,1,3) toc linked reference
> (0,0,0,1,1) linked reference
SingleStyledText('1')
Tab(' ')
ReferenceField('Introduction')
x (0,0,0,1,3) toc linked reference
> (0,0,0,1,1) linked reference
SingleStyledText('Introduction')
Tab(' ')
ReferenceField('1')
x (0,0,0,1,3) toc linked reference
> (0,0,0,1,1) linked reference
SingleStyledText('1')
TableOfContentsEntry('2 Conclusion 3')
> (0,0,0,1,2) toc level 1
MixedStyledText('2 Conclusion 3')
ReferenceField('2')
x (0,0,0,1,3) toc linked reference
> (0,0,0,1,1) linked reference
SingleStyledText('2')
Tab(' ')
ReferenceField('Conclusion')
x (0,0,0,1,3) toc linked reference
> (0,0,0,1,1) linked reference
SingleStyledText('Conclusion')
Tab(' ')
ReferenceField('3')
x (0,0,0,1,3) toc linked reference
> (0,0,0,1,1) linked reference
SingleStyledText('3')
ReferenceField('2')
x (0,0,0,1,3) toc linked reference
> (0,0,0,1,1) linked reference
SingleStyledText('2')
Tab(' ')
ReferenceField('Conclusion')
x (0,0,0,1,3) toc linked reference
> (0,0,0,1,1) linked reference
SingleStyledText('Conclusion')
Tab(' ')
ReferenceField('3')
x (0,0,0,1,3) toc linked reference
> (0,0,0,1,1) linked reference
SingleStyledText('3')
#### DownExpandingContainer('footer')
StaticGroupedFlowables()
Footer(' iii')
Expand Down Expand Up @@ -132,23 +139,25 @@
StaticGroupedFlowables()
#### ChainedContainer('column1')
(continued) StaticGroupedFlowables()
SupportingMatter(id='epigraph')
> (0,0,0,1,2) epigraph
Paragraph('Epigraph', style='title')
> (0,0,1,0,2) title
(0,0,0,0,2) body
SingleStyledText('Epigraph')
Paragraph('Gloomy eventide\nbefore evil syma...', style='line block') None:None <line_block>
> (0,0,1,0,2) line block
(0,0,0,0,2) body
MixedStyledText('Gloomy eventide') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-150/supportingmatter/index.rst:0 <line>
SingleStyledText('Gloomy eventide')
Newline('\n')
MixedStyledText('before evil symantics writes') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-150/supportingmatter/index.rst:0 <line>
SingleStyledText('before evil symantics writes')
Newline('\n')
MixedStyledText('into the despair') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-150/supportingmatter/index.rst:0 <line>
SingleStyledText('into the despair')
Section()
> (0,0,0,1,2) chapter
OutOfLineFlowables()
> (0,0,0,1,2) epigraph
Paragraph('Epigraph', style='title')
> (0,0,1,0,2) title
(0,0,0,0,2) body
SingleStyledText('Epigraph')
Paragraph('Gloomy eventide\nbefore evil syma...', style='line block') None:None <line_block>
> (0,0,1,0,2) line block
(0,0,0,0,2) body
MixedStyledText('Gloomy eventide') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-29/outoflineflowables/intro.rst:0 <line>
SingleStyledText('Gloomy eventide')
Newline('\n')
MixedStyledText('before evil symantics writes') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-29/outoflineflowables/intro.rst:0 <line>
SingleStyledText('before evil symantics writes')
Newline('\n')
MixedStyledText('into the despair') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-29/outoflineflowables/intro.rst:0 <line>
SingleStyledText('into the despair')
#### DownExpandingContainer('footer')
StaticGroupedFlowables()
Footer(' v')
Expand Down Expand Up @@ -184,11 +193,11 @@
#### ChainedContainer('column1')
StaticGroupedFlowables()
DocumentTree()
StaticGroupedFlowables() /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-150/supportingmatter/index.rst:0 <compound>
StaticGroupedFlowables() /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-29/outoflineflowables/index.rst:0 <compound>
StaticGroupedFlowables(id='%intro') None:None <start_of_file>
Section(id='%intro#introduction') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-150/supportingmatter/intro.rst:2 <section>
Section(id='%intro#introduction') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-29/outoflineflowables/intro.rst:2 <section>
> (0,0,0,1,2) chapter
Paragraph('This is the introduction.') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-150/supportingmatter/intro.rst:4 <paragraph>
Paragraph('This is the introduction.') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-29/outoflineflowables/intro.rst:12 <paragraph>
> (0,0,0,0,2) body
MixedStyledText('This is the introduction.')
SingleStyledText('This is the introduction.')
Expand All @@ -210,7 +219,7 @@
#### ChainedContainer('column1')
(continued) StaticGroupedFlowables()
(continued) DocumentTree()
(continued) StaticGroupedFlowables() /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-150/supportingmatter/index.rst:0 <compound>
(continued) StaticGroupedFlowables() /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-29/outoflineflowables/index.rst:0 <compound>
#### UpExpandingContainer('header')
StaticGroupedFlowables()
Header('Supporting Matter, Release ')
Expand Down Expand Up @@ -265,11 +274,11 @@
#### ChainedContainer('column1')
(continued) StaticGroupedFlowables()
(continued) DocumentTree()
(continued) StaticGroupedFlowables() /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-150/supportingmatter/index.rst:0 <compound>
(continued) StaticGroupedFlowables() /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-29/outoflineflowables/index.rst:0 <compound>
StaticGroupedFlowables(id='%conclusion') None:None <start_of_file>
Section(id='%conclusion#conclusion') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-150/supportingmatter/conclusion.rst:2 <section>
Section(id='%conclusion#conclusion') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-29/outoflineflowables/conclusion.rst:2 <section>
> (0,0,0,1,2) chapter
Paragraph('Concluding words go here.') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-150/supportingmatter/conclusion.rst:4 <paragraph>
Paragraph('Concluding words go here.') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-29/outoflineflowables/conclusion.rst:4 <paragraph>
> (0,0,0,0,2) body
MixedStyledText('Concluding words go here.')
SingleStyledText('Concluding words go here.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

rinoh_documents = [(
master_doc, # top-level file (index.rst)
'supportingmatter', # output (target.pdf)
'outoflineflowables', # output (target.pdf)
project, # document title
author, # document author
)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Supporting Matter
=================
Out-of-line Flowables
=====================

.. container:: supporting-matter
.. container:: out-of-line
:name: dedication

For mommy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Introduction
============

.. container:: supporting-matter
.. container:: out-of-line
:name: epigraph

| Gloomy eventide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ page_break = right
[table of contents section]
page_break = right

[epigraph : SupportingMatter(id='epigraph')]
[epigraph : OutOfLineFlowables(name='epigraph')]
title = 'Epigraph'
page_break = right
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ end_at_page = left
flowables = [
Section([Heading(SingleStyledText('Dedication'),
style='unnumbered'),
SupportingMatter('dedication')],
OutOfLineFlowables('dedication')],
id='dedication'),
TableOfContentsSection(),
ListOfFiguresSection(),
ListOfTablesSection(),
Section([SupportingMatter('epigraph')]),
Section([OutOfLineFlowables('epigraph')]),
]
4 changes: 2 additions & 2 deletions tests_regression/test_sphinx_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_subdir(app, verify):
verify()


@pytest.mark.sphinx(buildername='rinoh', testroot='supportingmatter')
def test_supportingmatter(app, verify):
@pytest.mark.sphinx(buildername='rinoh', testroot='outoflineflowables')
def test_outoflineflowables(app, verify):
app.build()
verify()

0 comments on commit abfdc32

Please sign in to comment.