diff --git a/CHANGES.rst b/CHANGES.rst index 9fc972556..c415dea64 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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. diff --git a/src/rinoh/flowable.py b/src/rinoh/flowable.py index 2bd6a9d69..32962e2a8 100644 --- a/src/rinoh/flowable.py +++ b/src/rinoh/flowable.py @@ -38,7 +38,7 @@ 'FlowableWidth', 'HorizontalAlignment', 'Break', 'DummyFlowable', 'AnchorFlowable', 'WarnFlowable', 'SetMetadataFlowable', 'SetUserStringFlowable', - 'SetSupportingMatter', + 'SetOutOfLineFlowables', 'GroupedFlowables', 'StaticGroupedFlowables', 'LabeledFlowable', 'GroupedLabeledFlowables', 'Float', 'PageBreak'] @@ -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 diff --git a/src/rinoh/frontend/rst/nodes.py b/src/rinoh/frontend/rst/nodes.py index ce5856b03..ccce19a1a 100644 --- a/src/rinoh/frontend/rst/nodes.py +++ b/src/rinoh/frontend/rst/nodes.py @@ -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) diff --git a/src/rinoh/structure.py b/src/rinoh/structure.py index eb42f0935..dd6a93f8d 100644 --- a/src/rinoh/structure.py +++ b/src/rinoh/structure.py @@ -33,7 +33,7 @@ 'TableOfContentsSection', 'TableOfContentsStyle', 'TableOfContents', 'ListOfStyle', 'TableOfContentsEntry', 'Admonition', 'AdmonitionStyle', - 'HorizontalRule', 'HorizontalRuleStyle', 'SupportingMatter'] + 'HorizontalRule', 'HorizontalRuleStyle', 'OutOfLineFlowables'] class SectionTitles(StringCollection): @@ -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, diff --git a/src/rinoh/styleds.py b/src/rinoh/styleds.py index f18392326..5d84267b2 100644 --- a/src/rinoh/styleds.py +++ b/src/rinoh/styleds.py @@ -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 @@ -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 diff --git a/tests_regression/roots/supportingmatter.pdf b/tests_regression/roots/outoflineflowables.pdf similarity index 84% rename from tests_regression/roots/supportingmatter.pdf rename to tests_regression/roots/outoflineflowables.pdf index 30879ffd3..87262a238 100644 Binary files a/tests_regression/roots/supportingmatter.pdf and b/tests_regression/roots/outoflineflowables.pdf differ diff --git a/tests_regression/roots/supportingmatter.stylelog b/tests_regression/roots/outoflineflowables.stylelog similarity index 73% rename from tests_regression/roots/supportingmatter.stylelog rename to tests_regression/roots/outoflineflowables.stylelog index 814d3fef5..afb6bb220 100644 --- a/tests_regression/roots/supportingmatter.stylelog +++ b/tests_regression/roots/outoflineflowables.stylelog @@ -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 - > (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 + > (0,0,0,0,2) body + MixedStyledText('For mommy') + SingleStyledText('For mommy') #### DownExpandingContainer('footer') StaticGroupedFlowables() Footer(' i') @@ -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') @@ -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 - > (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 - 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 - 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 - 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 + > (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 + 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 + 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 + SingleStyledText('into the despair') #### DownExpandingContainer('footer') StaticGroupedFlowables() Footer(' v') @@ -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 + StaticGroupedFlowables() /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-29/outoflineflowables/index.rst:0 StaticGroupedFlowables(id='%intro') None:None - Section(id='%intro#introduction') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-150/supportingmatter/intro.rst:2
+ Section(id='%intro#introduction') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-29/outoflineflowables/intro.rst:2
> (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('This is the introduction.') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-29/outoflineflowables/intro.rst:12 > (0,0,0,0,2) body MixedStyledText('This is the introduction.') SingleStyledText('This is the introduction.') @@ -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 + (continued) StaticGroupedFlowables() /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-29/outoflineflowables/index.rst:0 #### UpExpandingContainer('header') StaticGroupedFlowables() Header('Supporting Matter, Release ') @@ -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 + (continued) StaticGroupedFlowables() /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-29/outoflineflowables/index.rst:0 StaticGroupedFlowables(id='%conclusion') None:None - Section(id='%conclusion#conclusion') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-150/supportingmatter/conclusion.rst:2
+ Section(id='%conclusion#conclusion') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-29/outoflineflowables/conclusion.rst:2
> (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('Concluding words go here.') /private/var/folders/cm/h_fnh5lx0b5b1b6wvnlc7qlw0000gn/T/pytest-of-brechtm/pytest-29/outoflineflowables/conclusion.rst:4 > (0,0,0,0,2) body MixedStyledText('Concluding words go here.') SingleStyledText('Concluding words go here.') diff --git a/tests_regression/roots/test-supportingmatter/conclusion.rst b/tests_regression/roots/test-outoflineflowables/conclusion.rst similarity index 100% rename from tests_regression/roots/test-supportingmatter/conclusion.rst rename to tests_regression/roots/test-outoflineflowables/conclusion.rst diff --git a/tests_regression/roots/test-supportingmatter/conf.py b/tests_regression/roots/test-outoflineflowables/conf.py similarity index 96% rename from tests_regression/roots/test-supportingmatter/conf.py rename to tests_regression/roots/test-outoflineflowables/conf.py index 6eddd1784..2d49aeb12 100644 --- a/tests_regression/roots/test-supportingmatter/conf.py +++ b/tests_regression/roots/test-outoflineflowables/conf.py @@ -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 )] diff --git a/tests_regression/roots/test-supportingmatter/index.rst b/tests_regression/roots/test-outoflineflowables/index.rst similarity index 54% rename from tests_regression/roots/test-supportingmatter/index.rst rename to tests_regression/roots/test-outoflineflowables/index.rst index 14c56e955..15911c17c 100644 --- a/tests_regression/roots/test-supportingmatter/index.rst +++ b/tests_regression/roots/test-outoflineflowables/index.rst @@ -1,7 +1,7 @@ -Supporting Matter -================= +Out-of-line Flowables +===================== -.. container:: supporting-matter +.. container:: out-of-line :name: dedication For mommy diff --git a/tests_regression/roots/test-supportingmatter/intro.rst b/tests_regression/roots/test-outoflineflowables/intro.rst similarity index 82% rename from tests_regression/roots/test-supportingmatter/intro.rst rename to tests_regression/roots/test-outoflineflowables/intro.rst index 231bcedb7..48538ca81 100644 --- a/tests_regression/roots/test-supportingmatter/intro.rst +++ b/tests_regression/roots/test-outoflineflowables/intro.rst @@ -1,7 +1,7 @@ Introduction ============ -.. container:: supporting-matter +.. container:: out-of-line :name: epigraph | Gloomy eventide diff --git a/tests_regression/roots/test-supportingmatter/stylesheet.rts b/tests_regression/roots/test-outoflineflowables/stylesheet.rts similarity index 85% rename from tests_regression/roots/test-supportingmatter/stylesheet.rts rename to tests_regression/roots/test-outoflineflowables/stylesheet.rts index 43294bd05..74734b00c 100644 --- a/tests_regression/roots/test-supportingmatter/stylesheet.rts +++ b/tests_regression/roots/test-outoflineflowables/stylesheet.rts @@ -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 diff --git a/tests_regression/roots/test-supportingmatter/template.rtt b/tests_regression/roots/test-outoflineflowables/template.rtt similarity index 79% rename from tests_regression/roots/test-supportingmatter/template.rtt rename to tests_regression/roots/test-outoflineflowables/template.rtt index adb52dfa9..b3e3c75f2 100644 --- a/tests_regression/roots/test-supportingmatter/template.rtt +++ b/tests_regression/roots/test-outoflineflowables/template.rtt @@ -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')]), ] diff --git a/tests_regression/test_sphinx_projects.py b/tests_regression/test_sphinx_projects.py index 44289becb..337bd1996 100644 --- a/tests_regression/test_sphinx_projects.py +++ b/tests_regression/test_sphinx_projects.py @@ -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()