restbuilder-0.3/0000755000175000017500000000000014016722131013555 5ustar carstencarstenrestbuilder-0.3/CONTRIBUTORS.txt0000644000175000017500000000024614016722131016255 0ustar carstencarstenFreek Dijkstra (macfreek) G. Nicholas d'Andrea (gnidan) Jeffrey Lo (jeffrey_lo) Matthew Planchard (mplanchard) Nicola Musatti (nmusatti) Jack Burridge (jackburridge) restbuilder-0.3/CHANGES.rst0000644000175000017500000000257414016722131015367 0ustar carstencarstenChangelog ========= restbuilder 0.3 (28 February 2021) ---------------------------------- * Now requires Sphinx 1.4 or higher (drop support for 1.0-1.3) * Now requires Python 2.7, or Python 3.5 or higher (drop support for 3.0-3.4) Note: Python 2.7 and 3.5 are end of life and will no longer be actively supported. * Fix indentation for multi-line lists (Ned Batchelder) * Fix versionadd directive for Sphinx >= 3.0 (Ned Batchelder) * Preliminary support for tables (Jack Burridge) * Add test suite (Jack Burridge) * Add tox script and Github workflow to easily run tests restbuilder 0.2 (7 June 2018) -------------------------------- * Code moved to https://gitub.com/sphinx-contrib/restbuilder * Python 3 compatible (Nicola Musatti) * Adhere to rst_indent-specified indentation (Matthew Planchard) * Fixed issue where links were converted to plaintext (Matthew Planchard) restbuilder 0.1 (25 August 2013) -------------------------------- * Code submitted to sphinx-contrib https://bitbucket.org/birkenfeld/sphinx-contrib * Released as sphinxcontrib-restbuilder * Added basic documentation * Unsupported/unknown tags are not printed, but send to log facility. restbuilder (no version) (28 April 2012) ----------------------------------------- * First release as port of a documentation generator in the NBT package https://github.com/twoolie/NBT/commit/eefbd26c422a0e5f3c89e84fabcfb951a11722b0 restbuilder-0.3/MANIFEST.in0000644000175000017500000000015514016722131015314 0ustar carstencarsteninclude README.rst include LICENSE.txt include CHANGES.rst include CONTRIBUTING.rst include CONTRIBUTORS.txt restbuilder-0.3/setup.py0000644000175000017500000000335414016722131015274 0ustar carstencarsten# -*- coding: utf-8 -*- from setuptools import setup, find_packages long_desc = ''' Sphinx_ extension to build reST (reStructuredText_) files. This extension is in particular useful to use in combination with the autodoc extension to automatically generate documentation for use by any rst parser (such as the GitHub wiki). In itself, the extension is fairly straightforward -- it takes the parsed reST file from Sphinx_ and outputs it as reST. .. _Sphinx: http://sphinx-doc.org/ .. _reStructuredText: http://docutils.sourceforge.net/rst.html ''' requires = ['Sphinx>=1.4'] setup( name='sphinxcontrib-restbuilder', version='0.3', url='https://github.com/sphinx-contrib/restbuilder', download_url='http://pypi.python.org/pypi/sphinxcontrib-restbuilder', license='BSD 2-Clause', author='Freek Dijkstra', author_email='freek@macfreek.nl', description='Sphinx extension to output reST files.', long_description=long_desc, zip_safe=False, classifiers=[ 'Development Status :: 4 - Beta', 'Environment :: Console', 'Framework :: Sphinx :: Extension', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 3', 'Topic :: Documentation :: Sphinx', 'Topic :: Software Development :: Documentation', 'Topic :: Text Processing :: Markup :: reStructuredText', ], platforms='any', python_requires='>=2.7, !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*', packages=find_packages(exclude=['tests']), include_package_data=True, install_requires=requires, namespace_packages=['sphinxcontrib'], ) restbuilder-0.3/tests/0000755000175000017500000000000014016722131014717 5ustar carstencarstenrestbuilder-0.3/tests/test_rst_list.py0000644000175000017500000000224414016722131020175 0ustar carstencarstenfrom tests.utils import run_parse_test import pytest def test_bullet_list(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['bullet-list']) def test_ordered_list(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['ordered-list']) def test_nested_list(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['nested-list']) def test_multiline_list(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['multiline-list']) @pytest.mark.skip(reason="work in progress") def test_ordered_list_properties(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['ordered-list-properties']) @pytest.mark.skip(reason="work in progress") def test_bullet_list_consecutive(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['bullet-list-consecutive']) def test_definition_list(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['definition-list']) restbuilder-0.3/tests/test_rst_hyperlinks.py0000644000175000017500000000210614016722131021407 0ustar carstencarstenfrom tests.utils import run_parse_test def test_hyperlink_targets(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['hyperlink-targets']) def test_external_hyperlinks(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['external-hyperlinks']) def test_internal_hyperlinks(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['internal-hyperlinks']) def test_nonexisting_target(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['nonexistent-target']) def test_ref(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'sphinx-roles', ['ref']) def test_cross_ref(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'sphinx-roles/ref', ['index', 'doc1']) def test_doc_role(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'sphinx-roles/doc', ['index', 'doc1', 'doc2']) restbuilder-0.3/tests/test_rst_headings.py0000644000175000017500000000025514016722131021004 0ustar carstencarstenfrom tests.utils import run_parse_test def test_headings(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['headings']) restbuilder-0.3/tests/__init__.py0000644000175000017500000000000014016722131017016 0ustar carstencarstenrestbuilder-0.3/tests/utils.py0000644000175000017500000001027114016722131016432 0ustar carstencarstenfrom os.path import join try: from itertools import zip_longest except ImportError: # Python 2.7 support. from itertools import izip_longest as zip_longest import io import docutils from docutils.frontend import OptionParser from docutils.nodes import Text, Element, system_message from docutils.parsers.rst import Parser from docutils.utils import new_document from docutils.core import publish_from_doctree from sphinx.application import Sphinx # sphinx.util.docutils requires Sphinx 1.5 and up. try: from sphinx.util.docutils import docutils_namespace except ImportError: # Attempt to support Sphinx 1.4 and thus the old Debian Stretch (oldstable) from copy import copy from contextlib import contextmanager from docutils.parsers.rst import directives, roles @contextmanager def docutils_namespace(): """Create namespace for reST parsers.""" try: _directives = copy(directives._directives) _roles = copy(roles._roles) yield finally: directives._directives = _directives roles._roles = _roles def build_sphinx(src_dir, output_dir, files=None, config={}): doctrees_dir = join(output_dir, '.doctrees') filenames = [] force_all = True default_config = { 'extensions': ['sphinxcontrib.restbuilder'], 'master_doc': 'index', } default_config.update(config) config = default_config if files: force_all = False filenames = [join(src_dir, file + '.rst') for file in files] config['master_doc'] = files[0] with docutils_namespace(): app = Sphinx( src_dir, None, output_dir, doctrees_dir, 'rst', confoverrides=config, verbosity=0, ) app.build(force_all=force_all, filenames=filenames) def assert_node_equal(output, expected): assert type(output) == type(expected) if isinstance(output, Text): output_text = output.replace('\r\n', ' ') output_text = output_text.replace('\n', ' ') expected_text = expected.replace('\r\n', ' ') expected_text = expected_text.replace('\n', ' ') assert output_text == expected_text elif isinstance(output, system_message): assert len(output.children) == len(expected.children) # Don't check specifics of system_messages (warnings) # E.g. the line number may be off elif isinstance(output, Element): assert len(output.children) == len(expected.children) assert output.attributes == expected.attributes else: raise AssertionError def assert_doc_equal(output_doc, expected_doc): """ Can be used to compare two documents, ignoring any whitespace changes """ for output, expected in zip_longest( output_doc.traverse(include_self=False), expected_doc.traverse(include_self=False) ): assert_node_equal(output, expected) def parse_doc(dir, file): parser = Parser() with io.open(join(dir, file + '.rst'), encoding='utf-8') as fh: doc = new_document( file, OptionParser( components=(docutils.parsers.rst.Parser,) ).get_default_values(), ) parser.parse( fh.read(), doc, ) return doc def run_parse_test(src_dir, expected_dir, output_dir, subdir, files): src_dir = join(src_dir, subdir) expected_dir = join(expected_dir, subdir) output_dir = join(output_dir, subdir) build_sphinx(src_dir, output_dir, files) for file in files: output_doc = parse_doc(output_dir, file) expected_doc = parse_doc(expected_dir, file) try: assert_doc_equal(output_doc, expected_doc) except AssertionError: # output XML version of doctree for easier debugging with open(join(output_dir, file + '.output.xml'), 'wb') as fw: fw.write(publish_from_doctree(output_doc, writer_name='xml')) with open(join(output_dir, file + '.expected.xml'), 'wb') as fw: fw.write(publish_from_doctree(expected_doc, writer_name='xml')) raise if __name__ == '__main__': pass restbuilder-0.3/tests/conftest.py0000644000175000017500000000073714016722131017125 0ustar carstencarstenfrom os.path import dirname, realpath, join import shutil import pytest @pytest.fixture def src_dir(): return join( dirname(realpath(__file__)), 'datasets' ) @pytest.fixture def expected_dir(): return join( dirname(realpath(__file__)), 'expected' ) @pytest.fixture(scope="session") def output_dir(): out_dir = realpath(join(dirname(realpath(__file__)), '..', 'output')) shutil.rmtree(out_dir, ignore_errors=True) return out_dir restbuilder-0.3/tests/test_rst_code_blocks.py0000644000175000017500000000225714016722131021475 0ustar carstencarstenfrom tests.utils import run_parse_test import pytest import sphinx @pytest.mark.skipif(sphinx.version_info < (2, 0), reason="Sphinx 1.x does not support code blocks without language") def test_code_block(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'sphinx-directives', ['code-block']) def test_code_block_language(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'sphinx-directives', ['code-block-language']) def test_code_block_linenos(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'sphinx-directives', ['code-block-linenos']) def test_code(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'directives', ['code']) def test_code_language(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'directives', ['code-language']) @pytest.mark.skipif(sphinx.version_info < (2, 0), reason="Sphinx 1.x renders line numbers inline.") def test_code_number_lines(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'directives', ['code-number-lines']) restbuilder-0.3/tests/test_sphinx_versionmodified.py0000644000175000017500000000076214016722131023114 0ustar carstencarstenfrom tests.utils import run_parse_test def test_versionadded(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'sphinx-directives', ['versionadded']) def test_versionchanged(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'sphinx-directives', ['versionchanged']) def test_deprecated(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'sphinx-directives', ['deprecated']) restbuilder-0.3/tests/test_rst_toctree.py0000644000175000017500000000031414016722131020663 0ustar carstencarstenfrom tests.utils import run_parse_test def test_toctree(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'sphinx-directives/toctree', ['index', 'doc1', 'doc2']) restbuilder-0.3/tests/test_rst_formatting.py0000644000175000017500000000172214016722131021374 0ustar carstencarstenfrom tests.utils import run_parse_test import pytest import sphinx def test_bold(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['bold']) def test_italic(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['italic']) def test_literal(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['literal']) def test_subscript(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['subscript']) def test_superscript(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['superscript']) @pytest.mark.skipif(sphinx.version_info < (1, 6), reason="Smart quotes were introduces in Sphinx 1.6") def test_smart_quotes(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['smart-quotes']) restbuilder-0.3/tests/test_rst_blocks.py0000644000175000017500000000071314016722131020476 0ustar carstencarstenfrom tests.utils import run_parse_test def test_paragraph(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['paragraph']) def test_indentation(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['indentation']) def test_literal_block(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['literal-block']) restbuilder-0.3/tests/datasets/0000755000175000017500000000000014016722131016527 5ustar carstencarstenrestbuilder-0.3/tests/datasets/directives/0000755000175000017500000000000014016722131020670 5ustar carstencarstenrestbuilder-0.3/tests/datasets/directives/code-number-lines.rst0000644000175000017500000000015214016722131024730 0ustar carstencarsten.. code:: python :number-lines: def foo(): bar() See also sphinx-directives/code-block.rst restbuilder-0.3/tests/datasets/directives/index.rst0000644000175000017500000000022014016722131022523 0ustar carstencarsten:orphan: This directory contains tests of general reStructuredText directives. See https://docutils.sourceforge.io/docs/ref/rst/directives.htmlrestbuilder-0.3/tests/datasets/directives/code.rst0000644000175000017500000000012114016722131022326 0ustar carstencarsten.. code:: def foo(): bar() See also sphinx-directives/code-block.rst restbuilder-0.3/tests/datasets/directives/code-language.rst0000644000175000017500000000021314016722131024111 0ustar carstencarsten.. code:: python def foo(): bar() .. code:: c++ class Foo { int i; }; See also sphinx-directives/code-block.rst restbuilder-0.3/tests/datasets/common/0000755000175000017500000000000014016722131020017 5ustar carstencarstenrestbuilder-0.3/tests/datasets/common/bullet-list.rst0000644000175000017500000000010214016722131023002 0ustar carstencarsten:orphan: First list: - one - two Another list: * three * four restbuilder-0.3/tests/datasets/common/multiline-list.rst0000644000175000017500000000660314016722131023531 0ustar carstencarsten:orphan: * List with long lines. * Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent at ante id ante interdum porttitor. Cras mollis urna scelerisque, tincidunt diam sit amet, vulputate ante. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. * ``Longline`` is a cute name for this sentence. Vestibulum cursus dui ut ex consequat, sed ultrices justo accumsan. Donec pretium iaculis neque. Sed iaculis tortor ac odio facilisis, mattis semper neque venenatis. Sed eu neque non tellus iaculis blandit eu ac tellus. Fusce eu erat justo. 1. Mauris vel ante tellus. Suspendisse potenti. Sed dictum augue metus, sed ullamcorper nisi suscipit eu. Ut non arcu ullamcorper, volutpat lectus vitae, molestie odio. 2. Mauris vel ante tellus. Suspendisse potenti. Sed dictum augue metus, sed ullamcorper nisi suscipit eu. Ut non arcu ullamcorper, volutpat lectus vitae, molestie odio. 3. Mauris vel ante tellus. Suspendisse potenti. Sed dictum augue metus, sed ullamcorper nisi suscipit eu. Ut non arcu ullamcorper, volutpat lectus vitae, molestie odio. 4. Mauris vel ante tellus. Suspendisse potenti. Sed dictum augue metus, sed ullamcorper nisi suscipit eu. Ut non arcu ullamcorper, volutpat lectus vitae, molestie odio. 5. Mauris vel ante tellus. Suspendisse potenti. Sed dictum augue metus, sed ullamcorper nisi suscipit eu. Ut non arcu ullamcorper, volutpat lectus vitae, molestie odio. 6. Mauris vel ante tellus. Suspendisse potenti. Sed dictum augue metus, sed ullamcorper nisi suscipit eu. Ut non arcu ullamcorper, volutpat lectus vitae, molestie odio. 7. Mauris vel ante tellus. Suspendisse potenti. Sed dictum augue metus, sed ullamcorper nisi suscipit eu. Ut non arcu ullamcorper, volutpat lectus vitae, molestie odio. 8. Mauris vel ante tellus. Suspendisse potenti. Sed dictum augue metus, sed ullamcorper nisi suscipit eu. Ut non arcu ullamcorper, volutpat lectus vitae, molestie odio. 9. Mauris vel ante tellus. Suspendisse potenti. Sed dictum augue metus, sed ullamcorper nisi suscipit eu. Ut non arcu ullamcorper, volutpat lectus vitae, molestie odio. 10. Mauris vel ante tellus. Suspendisse potenti. Sed dictum augue metus, sed ullamcorper nisi suscipit eu. Ut non arcu ullamcorper, volutpat lectus vitae, molestie odio. * Morbi a est quis diam auctor pretium eu a quam. Integer auctor, ex pulvinar tempor pretium, lacus erat bibendum arcu, nec aliquam dolor purus id massa. 1. Mauris risus enim, cursus quis euismod nec, elementum ut nibh. Sed sollicitudin, lorem ut tempor bibendum, justo massa facilisis mauris, id fringilla massa lectus eu urna. * Donec arcu diam, egestas nec eros a, porta mattis lectus. Vestibulum justo orci, rutrum eget metus vitae, molestie suscipit odio. 1. Morbi a est quis diam auctor pretium eu a quam. Integer auctor, ex pulvinar tempor pretium, lacus erat bibendum arcu, nec aliquam dolor purus id massa. * Mauris risus enim, cursus quis euismod nec, elementum ut nibh. Sed sollicitudin, lorem ut tempor bibendum, justo massa facilisis mauris, id fringilla massa lectus eu urna. 1. Donec arcu diam, egestas nec eros a, porta mattis lectus. Vestibulum justo orci, rutrum eget metus vitae, molestie suscipit odio. restbuilder-0.3/tests/datasets/common/list-table.rst0000644000175000017500000000016014016722131022606 0ustar carstencarsten:orphan: .. list-table:: :header-rows: 1 * - key - value * - 1 - 2 * - 3 - 4restbuilder-0.3/tests/datasets/common/grid-table.rst0000644000175000017500000000007414016722131022564 0ustar carstencarsten:orphan: +---+---+ | a | b | +===+===+ | c | d | +---+---+ restbuilder-0.3/tests/datasets/common/literal-block.rst0000644000175000017500000000037214016722131023277 0ustar carstencarsten:orphan: Basic literal block: :: # Some code block for a in [5,4,3,2,1]: # this is program code, shown as-is print(a) print("it's...") Partial minimized form: :: Literal block Fully minimized form:: Literal block restbuilder-0.3/tests/datasets/common/headings.rst0000644000175000017500000000034014016722131022330 0ustar carstencarsten:orphan: Headline ======== Text immediately following. Subheader --------- Blank line before paragraph. Another paragraph. Subsubheader ____________ Subheader 2 ----------- Another Chapter =============== End of file.restbuilder-0.3/tests/datasets/common/smart-quotes.rst0000644000175000017500000000072414016722131023220 0ustar carstencarsten:orphan: This is a line with a quote, isn't it? This is a line with a smart quote, isn’t it? This is a 'word' between single quotes. This is a "word" between double quotes. This is a ‘word’ between smart single quotes. This is a “word” between smart double quotes. A plain ellipsis … Three dots is an ellipsis ... Even three dots with spaces in between them . . . Two dashes -- that makes a en-dash: – Two dashes --- that makes a em-dash: — restbuilder-0.3/tests/datasets/common/italic.rst0000644000175000017500000000003314016722131022012 0ustar carstencarsten:orphan: This is *italic*.restbuilder-0.3/tests/datasets/common/bold.rst0000644000175000017500000000003314016722131021465 0ustar carstencarsten:orphan: This is **bold**.restbuilder-0.3/tests/datasets/common/definition-list.rst0000644000175000017500000000043714016722131023656 0ustar carstencarsten:orphan: Definition lists: what Definition lists associate a term with a definition. how The term is a one-line phrase, and the definition is one or more paragraphs or body elements, indented relative to the term. Blank lines are not allowed between term and definition.restbuilder-0.3/tests/datasets/common/ordered-list.rst0000644000175000017500000000017614016722131023152 0ustar carstencarsten:orphan: 1. This is a numbered list. 2. It has two items too. #. This is a continuation of the list. #. It is numbered too. restbuilder-0.3/tests/datasets/common/paragraph.rst0000644000175000017500000000077114016722131022523 0ustar carstencarsten:orphan: Single line Two short lines. Lines continued \ with backslash. Single line with multiple spaces. A long line that goes on and on and on and on and on and really is so lang that it will be wrapped at some point. Well, at least it should really be wrapped by now, because really, this is a long sentence, eh? A line with a very long word is abcdefghijklmoqprstuvwxyzabcdefghijklmoqprstuvwxyzabcdefghijklmoqprstuvwxyzabcdefghijklmoqprstuvwxyzabcdefghijklmoqprstuvwxyz. Long or what? restbuilder-0.3/tests/datasets/common/bullet-list-consecutive.rst0000644000175000017500000000004614016722131025336 0ustar carstencarsten:orphan: - one - two * three * four restbuilder-0.3/tests/datasets/common/index.rst0000644000175000017500000000022014016722131021652 0ustar carstencarsten:orphan: This directory contains test of common reStructuredText markup. See https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.htmlrestbuilder-0.3/tests/datasets/common/indentation.rst0000644000175000017500000000072714016722131023073 0ustar carstencarsten:orphan: Not indented Four spaces Single tab Two indented lines after each other A long line that goes on and on and on and on and on and really is so lang that it will be wrapped at some point. Well, at least it should really be wrapped by now, because really, this is a long sentence, isn’t it? Four spaces Eight spaces Twelve spaces Eight spaces Four spaces Indented Not indented Three spaces restbuilder-0.3/tests/datasets/common/external-hyperlinks.rst0000644000175000017500000000064014016722131024561 0ustar carstencarsten:orphan: Embedded external hyperlinks, like `Python `_. Indirect external hyperlinks, like Larch_ or Python_. `Write to me`_ with your questions. .. _Write to me: jdoe@example.com .. _Larch: https://en.wikipedia.org/wiki/Larch Anonymous hyperlinks, like `the web site of my favorite programming language`__. .. __: http://www.python.org Direct hyperlinks, like http://www.python.org. restbuilder-0.3/tests/datasets/common/subscript.rst0000644000175000017500000000004414016722131022565 0ustar carstencarsten:orphan: This is :sub:`subscript`. restbuilder-0.3/tests/datasets/common/ordered-list-properties.rst0000644000175000017500000000055214016722131025342 0ustar carstencarsten:orphan: 3. This is a numbered list. 4. It started with item 3. 5. Five 6. Six 7. Seven 8. Eight 9. Nine 10. Ten 11. Eleven 12. Twelve 13. Thirteen C) Third letter of the alphabet D) Fourth letter of the alphabet E) Fifth letter of the alphabet I. Roman numerals II. Roman numerals III. Roman numerals IV. Roman numerals (a) one (b) two (c) three restbuilder-0.3/tests/datasets/common/internal-hyperlinks.rst0000644000175000017500000000063014016722131024552 0ustar carstencarsten:orphan: Clicking on this internal hyperlink will take us to the target_ below. .. _target: The hyperlink target above points to this paragraph. Titles are targets, too ======================= Implict references, even with spaces, like `Titles are targets, too`_. Untitled references target_ and `target`_ should be the same. This link_ refers to a file called ``underscore_``. .. _link: underscore\_ restbuilder-0.3/tests/datasets/common/nonexistent-target.rst0000644000175000017500000000005414016722131024412 0ustar carstencarsten:orphan: Pointer to a nonexisting_ target. restbuilder-0.3/tests/datasets/common/simple-table.rst0000644000175000017500000000011014016722131023117 0ustar carstencarsten:orphan: == == == a1 a2 a3 == == == b1 b2 b3 c1 c2 c3 d1 d2 d3 == == ==restbuilder-0.3/tests/datasets/common/nested-list.rst0000644000175000017500000000032314016722131023002 0ustar carstencarsten:orphan: * first item * second item * first sub item * second sub item * third sub item * third item * forth item 1. Item 1 initial text. * Item 1a. * Item 1b. 2. * Item 2a. * Item 2b. restbuilder-0.3/tests/datasets/common/superscript.rst0000644000175000017500000000004614016722131023134 0ustar carstencarsten:orphan: This is :sup:`superscript`. restbuilder-0.3/tests/datasets/common/literal.rst0000644000175000017500000000003614016722131022204 0ustar carstencarsten:orphan: This is ``literal``.restbuilder-0.3/tests/datasets/common/hyperlink-targets.rst0000644000175000017500000000116714016722131024232 0ustar carstencarsten:orphan: .. _target: The hyperlink target above points to this paragraph. Internal hyperlink targets may be chained. Multiple adjacent internal hyperlink targets all point to the same element: .. _target1: .. _target2: The targets target1 and target2 are synonyms; they both point to this paragraph. .. _one: two_ .. _two: three_ .. _three: Indirect hyperlink targets have a hyperlink reference in their link blocks. In the following example, target one indirectly references whatever target two references, and target two references target three, an internal hyperlink target. In effect, all three reference the same thing. restbuilder-0.3/tests/datasets/sphinx-roles/0000755000175000017500000000000014016722131021162 5ustar carstencarstenrestbuilder-0.3/tests/datasets/sphinx-roles/ref.rst0000644000175000017500000000050214016722131022465 0ustar carstencarstenRead more in :ref:`section-w2zn7enu`. .. _section-w2zn7enu: Section Title ============= Text body. See the examples in :ref:`section-example-1` and :ref:`section-example-2`. .. _section-example-1: Example ------- First section with equal name. .. _section-example-2: Example ------- Second section with equal name. restbuilder-0.3/tests/datasets/sphinx-roles/doc/0000755000175000017500000000000014016722131021727 5ustar carstencarstenrestbuilder-0.3/tests/datasets/sphinx-roles/doc/doc2.rst0000644000175000017500000000004314016722131023305 0ustar carstencarstenDoc 2 ===== Jump to :doc:`doc1`. restbuilder-0.3/tests/datasets/sphinx-roles/doc/index.rst0000644000175000017500000000007014016722131023565 0ustar carstencarstenroot ==== * :doc:`doc1`. * :doc:`This is Doc 2 `.restbuilder-0.3/tests/datasets/sphinx-roles/doc/doc1.rst0000644000175000017500000000004214016722131023303 0ustar carstencarstenDoc 1 ===== Jump to :doc:`doc2`. restbuilder-0.3/tests/datasets/sphinx-roles/index.rst0000644000175000017500000000023514016722131023023 0ustar carstencarsten:orphan: This directory contains tests of Sphinx-specific reStructuredText roles. See https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.htmlrestbuilder-0.3/tests/datasets/sphinx-roles/ref/0000755000175000017500000000000014016722131021736 5ustar carstencarstenrestbuilder-0.3/tests/datasets/sphinx-roles/ref/index.rst0000644000175000017500000000006114016722131023574 0ustar carstencarstenroot ==== Read more in :ref:`section-znu5w4ex`. restbuilder-0.3/tests/datasets/sphinx-roles/ref/doc1.rst0000644000175000017500000000007614016722131023321 0ustar carstencarsten.. _section-znu5w4ex: Section Title ============= Text body. restbuilder-0.3/tests/datasets/roles/0000755000175000017500000000000014016722131017653 5ustar carstencarstenrestbuilder-0.3/tests/datasets/roles/index.rst0000644000175000017500000000020614016722131021512 0ustar carstencarsten:orphan: This directory contains tests of general reStructuredText roles. See https://docutils.sourceforge.io/docs/ref/rst/roles.htmlrestbuilder-0.3/tests/datasets/sphinx-directives/0000755000175000017500000000000014016722131022177 5ustar carstencarstenrestbuilder-0.3/tests/datasets/sphinx-directives/code-block-linenos.rst0000644000175000017500000000013614016722131026400 0ustar carstencarsten.. code-block:: python :linenos: def foo(): bar() See also directives/code.rst restbuilder-0.3/tests/datasets/sphinx-directives/versionadded.rst0000644000175000017500000000011514016722131025375 0ustar carstencarsten.. versionadded:: 0.3.1 .. versionadded:: 1.7.0 The spam methods is new. restbuilder-0.3/tests/datasets/sphinx-directives/code-block.rst0000644000175000017500000000011214016722131024725 0ustar carstencarsten.. code-block:: def foo(): bar() See also directives/code.rst restbuilder-0.3/tests/datasets/sphinx-directives/code-block-language.rst0000644000175000017500000000021714016722131026514 0ustar carstencarstenSome Python Code: .. code-block:: python def foo(): bar() Some C++ code: .. code-block:: c++ class Foo { int i; }; restbuilder-0.3/tests/datasets/sphinx-directives/toctree/0000755000175000017500000000000014016722131023644 5ustar carstencarstenrestbuilder-0.3/tests/datasets/sphinx-directives/toctree/doc2.rst0000644000175000017500000000004014016722131025217 0ustar carstencarstenDoc 2 ===== This is document 2.restbuilder-0.3/tests/datasets/sphinx-directives/toctree/index.rst0000644000175000017500000000007014016722131025502 0ustar carstencarstenroot ==== .. toctree:: doc1 This is Doc 2 restbuilder-0.3/tests/datasets/sphinx-directives/toctree/doc1.rst0000644000175000017500000000004114016722131025217 0ustar carstencarstenDoc 1 ===== This is document 1. restbuilder-0.3/tests/datasets/sphinx-directives/versionchanged.rst0000644000175000017500000000014414016722131025727 0ustar carstencarsten.. versionchanged:: 0.3.1 .. versionchanged:: 2.5.0 The spam parameter is turned on by default. restbuilder-0.3/tests/datasets/sphinx-directives/deprecated.rst0000644000175000017500000000012714016722131025031 0ustar carstencarsten.. deprecated:: 0.3.1 .. deprecated:: 2.5.0 Common sense is deprecated altogether. restbuilder-0.3/tests/datasets/sphinx-directives/index.rst0000644000175000017500000000024714016722131024043 0ustar carstencarsten:orphan: This directory contains tests of Sphinx-specific reStructuredText directives. See https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.htmlrestbuilder-0.3/tests/datasets/index.rst0000644000175000017500000000061514016722131020372 0ustar carstencarsten:orphan: This folder contains test sources. It is catagorized in directories: * `common` - tests of common reStructuredText markup. * `directives` - tests of general reStructuredText directives. * `roles` - tests of general reStructuredText roles. * `sphinx-directives` - tests of Sphinx-specific reStructuredText directives. * `sphinx-roles` - tests of Sphinx-specific reStructuredText roles. restbuilder-0.3/tests/expected/0000755000175000017500000000000014016722131016520 5ustar carstencarstenrestbuilder-0.3/tests/expected/directives/0000755000175000017500000000000014016722131020661 5ustar carstencarstenrestbuilder-0.3/tests/expected/directives/code-number-lines.rst0000644000175000017500000000015214016722131024721 0ustar carstencarsten.. code:: python :number-lines: def foo(): bar() See also sphinx-directives/code-block.rst restbuilder-0.3/tests/expected/directives/index.rst0000644000175000017500000000020614016722131022520 0ustar carstencarstenThis directory contains tests of general reStructuredText directives. See https://docutils.sourceforge.io/docs/ref/rst/directives.htmlrestbuilder-0.3/tests/expected/directives/code.rst0000644000175000017500000000012114016722131022317 0ustar carstencarsten.. code:: def foo(): bar() See also sphinx-directives/code-block.rst restbuilder-0.3/tests/expected/directives/code-language.rst0000644000175000017500000000021314016722131024102 0ustar carstencarsten.. code:: python def foo(): bar() .. code:: c++ class Foo { int i; }; See also sphinx-directives/code-block.rst restbuilder-0.3/tests/expected/common/0000755000175000017500000000000014016722131020010 5ustar carstencarstenrestbuilder-0.3/tests/expected/common/bullet-list.rst0000644000175000017500000000007014016722131022777 0ustar carstencarstenFirst list: * one * two Another list: * three * four restbuilder-0.3/tests/expected/common/multiline-list.rst0000644000175000017500000000665714016722131023533 0ustar carstencarsten* List with long lines. * Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent at ante id ante interdum porttitor. Cras mollis urna scelerisque, tincidunt diam sit amet, vulputate ante. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. * ``Longline`` is a cute name for this sentence. Vestibulum cursus dui ut ex consequat, sed ultrices justo accumsan. Donec pretium iaculis neque. Sed iaculis tortor ac odio facilisis, mattis semper neque venenatis. Sed eu neque non tellus iaculis blandit eu ac tellus. Fusce eu erat justo. 1. Mauris vel ante tellus. Suspendisse potenti. Sed dictum augue metus, sed ullamcorper nisi suscipit eu. Ut non arcu ullamcorper, volutpat lectus vitae, molestie odio. 2. Mauris vel ante tellus. Suspendisse potenti. Sed dictum augue metus, sed ullamcorper nisi suscipit eu. Ut non arcu ullamcorper, volutpat lectus vitae, molestie odio. 3. Mauris vel ante tellus. Suspendisse potenti. Sed dictum augue metus, sed ullamcorper nisi suscipit eu. Ut non arcu ullamcorper, volutpat lectus vitae, molestie odio. 4. Mauris vel ante tellus. Suspendisse potenti. Sed dictum augue metus, sed ullamcorper nisi suscipit eu. Ut non arcu ullamcorper, volutpat lectus vitae, molestie odio. 5. Mauris vel ante tellus. Suspendisse potenti. Sed dictum augue metus, sed ullamcorper nisi suscipit eu. Ut non arcu ullamcorper, volutpat lectus vitae, molestie odio. 6. Mauris vel ante tellus. Suspendisse potenti. Sed dictum augue metus, sed ullamcorper nisi suscipit eu. Ut non arcu ullamcorper, volutpat lectus vitae, molestie odio. 7. Mauris vel ante tellus. Suspendisse potenti. Sed dictum augue metus, sed ullamcorper nisi suscipit eu. Ut non arcu ullamcorper, volutpat lectus vitae, molestie odio. 8. Mauris vel ante tellus. Suspendisse potenti. Sed dictum augue metus, sed ullamcorper nisi suscipit eu. Ut non arcu ullamcorper, volutpat lectus vitae, molestie odio. 9. Mauris vel ante tellus. Suspendisse potenti. Sed dictum augue metus, sed ullamcorper nisi suscipit eu. Ut non arcu ullamcorper, volutpat lectus vitae, molestie odio. 10. Mauris vel ante tellus. Suspendisse potenti. Sed dictum augue metus, sed ullamcorper nisi suscipit eu. Ut non arcu ullamcorper, volutpat lectus vitae, molestie odio. * Morbi a est quis diam auctor pretium eu a quam. Integer auctor, ex pulvinar tempor pretium, lacus erat bibendum arcu, nec aliquam dolor purus id massa. 1. Mauris risus enim, cursus quis euismod nec, elementum ut nibh. Sed sollicitudin, lorem ut tempor bibendum, justo massa facilisis mauris, id fringilla massa lectus eu urna. * Donec arcu diam, egestas nec eros a, porta mattis lectus. Vestibulum justo orci, rutrum eget metus vitae, molestie suscipit odio. 1. Morbi a est quis diam auctor pretium eu a quam. Integer auctor, ex pulvinar tempor pretium, lacus erat bibendum arcu, nec aliquam dolor purus id massa. * Mauris risus enim, cursus quis euismod nec, elementum ut nibh. Sed sollicitudin, lorem ut tempor bibendum, justo massa facilisis mauris, id fringilla massa lectus eu urna. 1. Donec arcu diam, egestas nec eros a, porta mattis lectus. Vestibulum justo orci, rutrum eget metus vitae, molestie suscipit odio. restbuilder-0.3/tests/expected/common/list-table.rst0000644000175000017500000000136414016722131022606 0ustar carstencarsten+----------------------------------------------------+----------------------------------------------------+ | key | value | +====================================================+====================================================+ | 1 | 2 | +----------------------------------------------------+----------------------------------------------------+ | 3 | 4 | +----------------------------------------------------+----------------------------------------------------+ restbuilder-0.3/tests/expected/common/grid-table.rst0000644000175000017500000000010614016722131022551 0ustar carstencarsten+-----+-----+ | a | b | +=====+=====+ | c | d | +-----+-----+ restbuilder-0.3/tests/expected/common/literal-block.rst0000644000175000017500000000036014016722131023265 0ustar carstencarstenBasic literal block: :: # Some code block for a in [5,4,3,2,1]: # this is program code, shown as-is print(a) print("it's...") Partial minimized form: :: Literal block Fully minimized form:: Literal block restbuilder-0.3/tests/expected/common/headings.rst0000644000175000017500000000032614016722131022325 0ustar carstencarstenHeadline ======== Text immediately following. Subheader --------- Blank line before paragraph. Another paragraph. Subsubheader ____________ Subheader 2 ----------- Another Chapter =============== End of file.restbuilder-0.3/tests/expected/common/smart-quotes.rst0000644000175000017500000000072314016722131023210 0ustar carstencarstenThis is a line with a quote, isn’t it? This is a line with a smart quote, isn’t it? This is a ‘word’ between single quotes. This is a “word” between double quotes. This is a ‘word’ between smart single quotes. This is a “word” between smart double quotes. A plain ellipsis … Three dots is an ellipsis … Even three dots with spaces in between them … Two dashes – that makes a en-dash: – Two dashes — that makes a em-dash: — restbuilder-0.3/tests/expected/common/italic.rst0000644000175000017500000000002214016722131022001 0ustar carstencarstenThis is *italic*. restbuilder-0.3/tests/expected/common/bold.rst0000644000175000017500000000002214016722131021454 0ustar carstencarstenThis is **bold**. restbuilder-0.3/tests/expected/common/definition-list.rst0000644000175000017500000000042514016722131023644 0ustar carstencarstenDefinition lists: what Definition lists associate a term with a definition. how The term is a one-line phrase, and the definition is one or more paragraphs or body elements, indented relative to the term. Blank lines are not allowed between term and definition.restbuilder-0.3/tests/expected/common/ordered-list.rst0000644000175000017500000000016314016722131023137 0ustar carstencarsten1. This is a numbered list. 2. It has two items too. 3. This is a continuation of the list. 4. It is numbered too. restbuilder-0.3/tests/expected/common/paragraph.rst0000644000175000017500000000075514016722131022516 0ustar carstencarstenSingle line Two short lines. Lines continued with backslash. Single line with multiple spaces. A long line that goes on and on and on and on and on and really is so lang that it will be wrapped at some point. Well, at least it should really be wrapped by now, because really, this is a long sentence, eh? A line with a very long word is abcdefghijklmoqprstuvwxyzabcdefghijklmoqprstuvwxyzabcdefghijklmoqprstuvwxyzabcdefghijklmoqprstuvwxyzabcdefghijklmoqprstuvwxyz. Long or what? restbuilder-0.3/tests/expected/common/bullet-list-consecutive.rst0000644000175000017500000000003414016722131025324 0ustar carstencarsten- one - two * three * four restbuilder-0.3/tests/expected/common/index.rst0000644000175000017500000000020614016722131021647 0ustar carstencarstenThis directory contains test of common reStructuredText markup. See https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.htmlrestbuilder-0.3/tests/expected/common/indentation.rst0000644000175000017500000000074214016722131023061 0ustar carstencarstenNot indented Four spaces Single tab Two indented lines after each other A long line that goes on and on and on and on and on and really is so lang that it will be wrapped at some point. Well, at least it should really be wrapped by now, because really, this is a long sentence, isn’t it? Four spaces Eight spaces Twelve spaces Eight spaces Four spaces Indented Not indented Three spaces restbuilder-0.3/tests/expected/common/external-hyperlinks.rst0000644000175000017500000000063414016722131024555 0ustar carstencarstenEmbedded external hyperlinks, like `Python `_. Indirect external hyperlinks, like `Larch `_ or `Python `_. `Write to me `_ with your questions. Anonymous hyperlinks, like `the web site of my favorite programming language `__. Direct hyperlinks, like http://www.python.org. restbuilder-0.3/tests/expected/common/subscript.rst0000644000175000017500000000003214016722131022553 0ustar carstencarstenThis is :sub:`subscript`. restbuilder-0.3/tests/expected/common/ordered-list-properties.rst0000644000175000017500000000054014016722131025330 0ustar carstencarsten3. This is a numbered list. 4. It started with item 3. 5. Five 6. Six 7. Seven 8. Eight 9. Nine 10. Ten 11. Eleven 12. Twelve 13. Thirteen C) Third letter of the alphabet D) Fourth letter of the alphabet E) Fifth letter of the alphabet I. Roman numerals II. Roman numerals III. Roman numerals IV. Roman numerals (a) one (b) two (c) three restbuilder-0.3/tests/expected/common/internal-hyperlinks.rst0000644000175000017500000000061414016722131024545 0ustar carstencarstenClicking on this internal hyperlink will take us to the `target`_ below. .. _target: The hyperlink target above points to this paragraph. Titles are targets, too ======================= Implict references, even with spaces, like `Titles are targets, too`_. Untitled references `target`_ and `target`_ should be the same. This `link `_ refers to a file called ``underscore_``. restbuilder-0.3/tests/expected/common/nonexistent-target.rst0000644000175000017500000000004214016722131024400 0ustar carstencarstenPointer to a nonexisting_ target. restbuilder-0.3/tests/expected/common/simple-table.rst0000644000175000017500000000023114016722131023114 0ustar carstencarsten+----+----+----+ | a1 | a2 | a3 | +====+====+====+ | b1 | b2 | b3 | +----+----+----+ | c1 | c2 | c3 | +----+----+----+ | d1 | d2 | d3 | +----+----+----+ restbuilder-0.3/tests/expected/common/nested-list.rst0000644000175000017500000000031114016722131022770 0ustar carstencarsten* first item * second item * first sub item * second sub item * third sub item * third item * forth item 1. Item 1 initial text. * Item 1a. * Item 1b. 2. * Item 2a. * Item 2b. restbuilder-0.3/tests/expected/common/superscript.rst0000644000175000017500000000003414016722131023122 0ustar carstencarstenThis is :sup:`superscript`. restbuilder-0.3/tests/expected/common/literal.rst0000644000175000017500000000002414016722131022172 0ustar carstencarstenThis is ``literal``.restbuilder-0.3/tests/expected/common/hyperlink-targets.rst0000644000175000017500000000115714016722131024222 0ustar carstencarsten.. _target: The hyperlink target above points to this paragraph. Internal hyperlink targets may be chained. Multiple adjacent internal hyperlink targets all point to the same element: .. _target1: .. _target2: The targets target1 and target2 are synonyms; they both point to this paragraph. .. _one: three_ .. _two: three_ .. _three: Indirect hyperlink targets have a hyperlink reference in their link blocks. In the following example, target one indirectly references whatever target two references, and target two references target three, an internal hyperlink target. In effect, all three reference the same thing. restbuilder-0.3/tests/expected/sphinx-roles/0000755000175000017500000000000014016722131021153 5ustar carstencarstenrestbuilder-0.3/tests/expected/sphinx-roles/ref.rst0000644000175000017500000000054014016722131022460 0ustar carstencarstenRead more in `Section Title <#section-w2zn7enu>`_. .. _section-w2zn7enu: Section Title ============= Text body. See the examples in `Example <#section-example-1>`_ and `Example <#section-example-2>`_. .. _section-example-1: Example ------- First section with equal name. .. _section-example-2: Example ------- Second section with equal name. restbuilder-0.3/tests/expected/sphinx-roles/doc/0000755000175000017500000000000014016722131021720 5ustar carstencarstenrestbuilder-0.3/tests/expected/sphinx-roles/doc/doc2.rst0000644000175000017500000000005214016722131023276 0ustar carstencarstenDoc 2 ***** Jump to `Doc 1 `_. restbuilder-0.3/tests/expected/sphinx-roles/doc/index.rst0000644000175000017500000000010114016722131023551 0ustar carstencarstenroot **** * `Doc 1 `_. * `This is Doc 2 `_. restbuilder-0.3/tests/expected/sphinx-roles/doc/doc1.rst0000644000175000017500000000005214016722131023275 0ustar carstencarstenDoc 1 ***** Jump to `Doc 2 `_. restbuilder-0.3/tests/expected/sphinx-roles/index.rst0000644000175000017500000000022314016722131023011 0ustar carstencarstenThis directory contains tests of Sphinx-specific reStructuredText roles. See https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.htmlrestbuilder-0.3/tests/expected/sphinx-roles/ref/0000755000175000017500000000000014016722131021727 5ustar carstencarstenrestbuilder-0.3/tests/expected/sphinx-roles/ref/index.rst0000644000175000017500000000010614016722131023565 0ustar carstencarstenroot **** Read more in `Section Title `_. restbuilder-0.3/tests/expected/sphinx-roles/ref/doc1.rst0000644000175000017500000000007614016722131023312 0ustar carstencarsten.. _section-znu5w4ex: Section Title ============= Text body. restbuilder-0.3/tests/expected/roles/0000755000175000017500000000000014016722131017644 5ustar carstencarstenrestbuilder-0.3/tests/expected/roles/index.rst0000644000175000017500000000017414016722131021507 0ustar carstencarstenThis directory contains tests of general reStructuredText roles. See https://docutils.sourceforge.io/docs/ref/rst/roles.htmlrestbuilder-0.3/tests/expected/sphinx-directives/0000755000175000017500000000000014016722131022170 5ustar carstencarstenrestbuilder-0.3/tests/expected/sphinx-directives/code-block-linenos.rst0000644000175000017500000000013514016722131026370 0ustar carstencarsten.. code:: python :number-lines: def foo(): bar() See also directives/code.rst restbuilder-0.3/tests/expected/sphinx-directives/versionadded.rst0000644000175000017500000000010614016722131025366 0ustar carstencarstenNew in version 0.3.1. New in version 1.7.0: The spam methods is new. restbuilder-0.3/tests/expected/sphinx-directives/code-block.rst0000644000175000017500000000010414016722131024717 0ustar carstencarsten.. code:: def foo(): bar() See also directives/code.rst restbuilder-0.3/tests/expected/sphinx-directives/code-block-language.rst0000644000175000017500000000020314016722131026500 0ustar carstencarstenSome Python Code: .. code:: python def foo(): bar() Some C++ code: .. code:: c++ class Foo { int i; }; restbuilder-0.3/tests/expected/sphinx-directives/toctree/0000755000175000017500000000000014016722131023635 5ustar carstencarstenrestbuilder-0.3/tests/expected/sphinx-directives/toctree/doc2.rst0000644000175000017500000000004114016722131025211 0ustar carstencarstenDoc 2 ***** This is document 2. restbuilder-0.3/tests/expected/sphinx-directives/toctree/index.rst0000644000175000017500000000007714016722131025502 0ustar carstencarstenroot **** * `Doc 1 `_ * `This is Doc 2 `_ restbuilder-0.3/tests/expected/sphinx-directives/toctree/doc1.rst0000644000175000017500000000004114016722131025210 0ustar carstencarstenDoc 1 ***** This is document 1. restbuilder-0.3/tests/expected/sphinx-directives/versionchanged.rst0000644000175000017500000000014114016722131025715 0ustar carstencarstenChanged in version 0.3.1. Changed in version 2.5.0: The spam parameter is turned on by default. restbuilder-0.3/tests/expected/sphinx-directives/deprecated.rst0000644000175000017500000000015014016722131025016 0ustar carstencarstenDeprecated since version 0.3.1. Deprecated since version 2.5.0: Common sense is deprecated altogether. restbuilder-0.3/tests/expected/sphinx-directives/index.rst0000644000175000017500000000023514016722131024031 0ustar carstencarstenThis directory contains tests of Sphinx-specific reStructuredText directives. See https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.htmlrestbuilder-0.3/tests/expected/index.rst0000644000175000017500000000061414016722131020362 0ustar carstencarstenThis folder contains expected test results. It is catagorized in directories: * `common` - tests of common reStructuredText markup. * `directives` - tests of general reStructuredText directives. * `roles` - tests of general reStructuredText roles. * `sphinx-directives` - tests of Sphinx-specific reStructuredText directives. * `sphinx-roles` - tests of Sphinx-specific reStructuredText roles. restbuilder-0.3/tests/test_rst_table.py0000644000175000017500000000071114016722131020306 0ustar carstencarstenfrom tests.utils import run_parse_test def test_simple_table(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['simple-table']) def test_grid_table(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['grid-table']) def test_list_table(src_dir, expected_dir, output_dir): run_parse_test(src_dir, expected_dir, output_dir, 'common', ['list-table']) restbuilder-0.3/README.rst0000644000175000017500000000430614016722131015247 0ustar carstencarsten.. -*- restructuredtext -*- ======================= README for reST Builder ======================= Sphinx_ extension to build reST (reStructuredText_) files. This extension is in particular useful to use in combination with the autodoc extension to automatically generate documentation for use by any rst parser (such as the GitHub wiki). In itself, the extension is fairly straightforward -- it takes the parsed reST file from Sphinx_ and outputs it as reST. Requirements ============ * Sphinx_ 1.4 or later * Python 3.5 or later Installing ========== Using pip --------- :: pip install sphinxcontrib-restbuilder Manual ------ :: git clone https://github.com/sphinx-contrib/restbuilder.git cd restbuilder python setup.py install If you want to try reST builder without using the setuptools installer, you can put the reST builder in an extension subdirectory, and adjust ``sys.path`` to tell Sphinx where to look for it: - Add the extensions directory to the path in ``conf.py``. E.g.:: sys.path.append(os.path.abspath('exts')) Usage ===== - Set the builder as a extension in ``conf.py``:: extensions = ['sphinxcontrib.restbuilder'] - Run sphinx-build with target ``rst``:: sphinx-build -b rst -c . build/rst Configuration ============= The following four configuration variables are defined by sphinxcontrib.restbuilder: :literal:`rst_file_suffix` This is the file name suffix for generated reST files. The default is ``".rst"``. :literal:`rst_link_suffix` Suffix for generated links to reST files. The default is whatever `rst_file_suffix` is set to. :literal:`rst_file_transform` Function to translate a docname to a filename. By default, returns `docname` + :literal:`rst_file_suffix`. :literal:`rst_link_transform`: Function to translate a docname to a (partial) URI. By default, returns `docname` + :literal:`rst_link_suffix`. Further Reading =============== .. _Sphinx: http://sphinx-doc.org/ .. _`sphinx-contrib`: http://bitbucket.org/birkenfeld/sphinx-contrib .. _reStructuredText: http://docutils.sourceforge.net/rst.html Feedback ======== The reST builder is in a preliminary state. It's not (yet) widely used, so any feedback is particularly welcome. restbuilder-0.3/LICENSE.txt0000644000175000017500000000242414016722131015402 0ustar carstencarstenCopyright (c) 2012-2021 by Freek Dijkstra and contributors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. restbuilder-0.3/CONTRIBUTING.rst0000644000175000017500000001022114016722131016212 0ustar carstencarstenThank you for contributing! =========================== Thank you for considering a contribution to Sphinx reStructuredText builder/writer, and for reading this document. Use issues for bug reports, feature requests, or any sort of feedback that you may have. If you are able to spend the time to create a pull request, that is most appreciated. Testing your code ================= * Run `pytest`_ to run all tests using your default Python version and Sphinx version. * Run `pytest -k testName` to only run the test called testName. * For testing, Sphinx is run for each test in the `tests/datasets` directory, and the output is written to the `output` directory. The result is then compared to the expected output in `tests/expected`. * Rather than a byte-by-byte comparison, `output` and `tests/expected` are compared after reading the file with docutils (which contains a basic reStructuredText parser), to allow for slight variations in layout. * If a test fails, the XML version of the parsed documents is written to the `output` directory. `test-file.expected.xml` for `test-file.rst` in `tests/expected`, and `test-file.output.xml` for `test-file.rst` in `output`. * Optionally run `pytest -v -r A -W d` for a very verbose output, including stdout and stderr for all tests (note that some tests like nonexistent-target.rst are expected to give a warning), and including all Python warnings. * To test with multiple Python version and Sphinx versions, run `tox`_. * Run `tox -e python3.9-sphinx3.4` to run tox with a specific Python and Sphinx version. * Each commit to master, and each pull request to the master branch is tested with a few different tests. See the actions tab for the results of each run, or click on the checkmark (✔ or ✘) listed with each commit. .. _pytest: https://www.pytest.org/ .. _tox: https://tox.readthedocs.io/ Supported versions ================== * See `.github/workflows/tests.yml` for a list of which version are tested for by GitHub after each pull request. * See `tox.ini` for a list of which version are tested for by `tox`. These two files should be kept in sync. * As a rule of thumb, this project supports all Sphinx versions starting from the one that came with the previous stable Debian distribution (`oldstable/sphinx-doc`_) till the most recent version. It supports all Python versions starting with the one that came with the previous stable Debian distribution (`oldstable/python3`_). * Python 2 is no longer supported, and no test is run for it. We will consider small pull requests to add Python 2.7 support, if you really want to spend this effort. .. _`oldstable/sphinx-doc`: https://packages.debian.org/oldstable/sphinx-doc .. _`oldstable/python`: https://packages.debian.org/oldstable/python3 Publishing versions =================== The code is available on the Python package index at https://pypi.org/project/sphinxcontrib-restbuilder/. This section is only relevant for administrators. Creating a release ------------------ Change the following files:: CHANGES.rst CONTRIBUTORS.txt (Add new contributors, if any) setup.py (Change version constant) Commit the changes, add a tag, and upload the changes:: git add CHANGES.rst CONTRIBUTORS.txt setup.py git commit -m "Bump version number to x.y.z" git tag -a version-x.y.z HEAD git push --tags Publish a release at GitHub --------------------------- * Go to https://github.com/sphinx-contrib/restbuilder/releases * Click the "Draft a new release" button * Select the tag, and add a Release title (e.g. Sphinx Restbuilder x.y) and release notes. I usually only list the most important changes, with optional link to CHANGES.rst for more details. Publish a release at PyPI ------------------------- Follow the process described at https://packaging.python.org/tutorials/distributing-packages/. Install requirements:: pip install --upgrade pip pip install setuptools wheel twine Create both a source (.tar.gz) and wheel (.whl) distribution:: python setup.py sdist python setup.py bdist_wheel --universal Upload all that was created to PyPI:: ls dist/ twine upload dist/* restbuilder-0.3/sphinxcontrib/0000755000175000017500000000000014016722131016447 5ustar carstencarstenrestbuilder-0.3/sphinxcontrib/restbuilder.py0000644000175000017500000000240714016722131021350 0ustar carstencarsten# -*- coding: utf-8 -*- """ sphinxcontrib.restbuilder ========================= Sphinx extension to output reST files. .. moduleauthor:: Freek Dijkstra :copyright: Copyright 2012-2021 by Freek Dijkstra and contributors. :license: BSD, see LICENSE.txt for details. """ from __future__ import (print_function, unicode_literals, absolute_import) from sphinx.builders import Builder from sphinx.writers.text import STDINDENT from .builders.rst import RstBuilder from .writers.rst import RstWriter def setup(app): app.require_sphinx('1.0') app.add_builder(RstBuilder) app.add_config_value('rst_file_suffix', ".rst", False) """This is the file name suffix for reST files""" app.add_config_value('rst_link_suffix', None, False) """The is the suffix used in internal links. By default, takes the same value as rst_file_suffix""" app.add_config_value('rst_file_transform', None, False) """Function to translate a docname to a filename. By default, returns docname + rst_file_suffix.""" app.add_config_value('rst_link_transform', None, False) """Function to translate a docname to a (partial) URI. By default, returns docname + rst_link_suffix.""" app.add_config_value('rst_indent', STDINDENT, False) restbuilder-0.3/sphinxcontrib/__init__.py0000644000175000017500000000055614016722131020566 0ustar carstencarsten# -*- coding: utf-8 -*- """ sphinxcontrib ~~~~~~~~~~~~~ This package is a namespace package that contains all extensions distributed in the ``sphinx-contrib`` distribution. :copyright: Copyright 2007-2009 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. """ __import__('pkg_resources').declare_namespace(__name__) restbuilder-0.3/sphinxcontrib/writers/0000755000175000017500000000000014016722131020146 5ustar carstencarstenrestbuilder-0.3/sphinxcontrib/writers/__init__.py0000644000175000017500000000016214016722131022256 0ustar carstencarsten# -*- coding: utf-8 -*- """ sphinxcontrib.writers ~~~~~~~~~~~~~~~~~~~~~ Custom docutils writers. """ restbuilder-0.3/sphinxcontrib/writers/rst.py0000644000175000017500000006255114016722131021341 0ustar carstencarsten# -*- coding: utf-8 -*- """ sphinxcontrib.writers.rst ~~~~~~~~~~~~~~~~~~~~~~~~~ Custom docutils writer for ReStructuredText. :copyright: Copyright 2012-2021 by Freek Dijkstra and contributors. :license: BSD, see LICENSE.txt for details. """ from __future__ import (print_function, unicode_literals, absolute_import) import os import sys import textwrap import logging from docutils import nodes, writers from sphinx import addnodes from sphinx.locale import admonitionlabels, _ from sphinx.writers.text import TextTranslator, MAXWIDTH, STDINDENT class RstWriter(writers.Writer): supported = ('text',) settings_spec = ('No options here.', '', ()) settings_defaults = {} output = None def __init__(self, builder): writers.Writer.__init__(self) self.builder = builder def translate(self): visitor = RstTranslator(self.document, self.builder) self.document.walkabout(visitor) self.output = visitor.body class RstTranslator(TextTranslator): sectionchars = '*=-~"+`' def __init__(self, document, builder): TextTranslator.__init__(self, document, builder) newlines = builder.config.text_newlines if newlines == 'windows': self.nl = '\r\n' elif newlines == 'native': self.nl = os.linesep else: self.nl = '\n' self.sectionchars = builder.config.text_sectionchars self.states = [[]] self.stateindent = [0] self.list_counter = [] self.list_formatter = [] self.sectionlevel = 0 self.table = None if self.builder.config.rst_indent: self.indent = self.builder.config.rst_indent else: self.indent = STDINDENT self.wrapper = textwrap.TextWrapper(width=MAXWIDTH, break_long_words=False, break_on_hyphens=False) def log_unknown(self, type, node): logger = logging.getLogger("sphinxcontrib.writers.rst") if len(logger.handlers) == 0: # Logging is not yet configured. Configure it. logging.basicConfig(level=logging.INFO, stream=sys.stderr, format='%(levelname)-8s %(message)s') logger = logging.getLogger("sphinxcontrib.writers.rst") logger.warning("%s(%s) unsupported formatting" % (type, node)) def wrap(self, text, width=MAXWIDTH): self.wrapper.width = width return self.wrapper.wrap(text) def add_text(self, text): self.states[-1].append((-1, text)) def new_state(self, indent=STDINDENT): self.states.append([]) self.stateindent.append(indent) def end_state(self, wrap=True, end=[''], first=None): content = self.states.pop() width = max(MAXWIDTH//3, MAXWIDTH - sum(self.stateindent)) indent = self.stateindent.pop() result = [] toformat = [] def do_format(): if not toformat: return if wrap: res = self.wrap(''.join(toformat), width=width) else: res = ''.join(toformat).splitlines() if end: res += end result.append((indent, res)) for itemindent, item in content: if itemindent == -1: toformat.append(item) else: do_format() result.append((indent + itemindent, item)) toformat = [] do_format() if first is not None and result: itemindent, item = result[0] if item: result.insert(0, (itemindent - indent, [first + item[0]])) result[1] = (itemindent, item[1:]) self.states[-1].extend(result) def visit_document(self, node): self.new_state(0) def depart_document(self, node): self.end_state() self.body = self.nl.join(line and (' '*indent + line) for indent, lines in self.states[0] for line in lines) # TODO: add header/footer? def visit_highlightlang(self, node): raise nodes.SkipNode def visit_section(self, node): self._title_char = self.sectionchars[self.sectionlevel] self.sectionlevel += 1 def depart_section(self, node): self.sectionlevel -= 1 def visit_topic(self, node): self.new_state(0) def depart_topic(self, node): self.end_state() visit_sidebar = visit_topic depart_sidebar = depart_topic def visit_rubric(self, node): self.new_state(0) self.add_text('-[ ') def depart_rubric(self, node): self.add_text(' ]-') self.end_state() def visit_compound(self, node): # self.log_unknown("compount", node) pass def depart_compound(self, node): pass def visit_glossary(self, node): # self.log_unknown("glossary", node) pass def depart_glossary(self, node): pass def visit_title(self, node): if isinstance(node.parent, nodes.Admonition): self.add_text(node.astext()+': ') raise nodes.SkipNode self.new_state(0) def depart_title(self, node): if isinstance(node.parent, nodes.section): char = self._title_char else: char = '^' text = ''.join(x[1] for x in self.states.pop() if x[0] == -1) self.stateindent.pop() self.states[-1].append((0, ['', text, '%s' % (char * len(text)), ''])) def visit_subtitle(self, node): # self.log_unknown("subtitle", node) pass def depart_subtitle(self, node): pass def visit_attribution(self, node): self.add_text('-- ') def depart_attribution(self, node): pass def visit_desc(self, node): self.new_state(0) def depart_desc(self, node): self.end_state() def visit_desc_signature(self, node): if node.parent['objtype'] in ('class', 'exception', 'method', 'function'): self.add_text('**') else: self.add_text('``') def depart_desc_signature(self, node): if node.parent['objtype'] in ('class', 'exception', 'method', 'function'): self.add_text('**') else: self.add_text('``') def visit_desc_name(self, node): # self.log_unknown("desc_name", node) pass def depart_desc_name(self, node): pass def visit_desc_addname(self, node): # self.log_unknown("desc_addname", node) pass def depart_desc_addname(self, node): pass def visit_desc_type(self, node): # self.log_unknown("desc_type", node) pass def depart_desc_type(self, node): pass def visit_desc_returns(self, node): self.add_text(' -> ') def depart_desc_returns(self, node): pass def visit_desc_parameterlist(self, node): self.add_text('(') self.first_param = 1 def depart_desc_parameterlist(self, node): self.add_text(')') def visit_desc_parameter(self, node): if not self.first_param: self.add_text(', ') else: self.first_param = 0 self.add_text(node.astext()) raise nodes.SkipNode def visit_desc_optional(self, node): self.add_text('[') def depart_desc_optional(self, node): self.add_text(']') def visit_desc_annotation(self, node): content = node.astext() if len(content) > MAXWIDTH: h = int(MAXWIDTH/3) content = content[:h] + " ... " + content[-h:] self.add_text(content) raise nodes.SkipNode def depart_desc_annotation(self, node): pass def visit_refcount(self, node): pass def depart_refcount(self, node): pass def visit_desc_content(self, node): self.new_state(self.indent) def depart_desc_content(self, node): self.end_state() def visit_figure(self, node): self.new_state(self.indent) def depart_figure(self, node): self.end_state() def visit_caption(self, node): # self.log_unknown("caption", node) pass def depart_caption(self, node): pass def visit_productionlist(self, node): self.new_state(self.indent) names = [] for production in node: names.append(production['tokenname']) maxlen = max(len(name) for name in names) for production in node: if production['tokenname']: self.add_text(production['tokenname'].ljust(maxlen) + ' ::=') lastname = production['tokenname'] else: self.add_text('%s ' % (' '*len(lastname))) self.add_text(production.astext() + self.nl) self.end_state(wrap=False) raise nodes.SkipNode def visit_seealso(self, node): self.new_state(self.indent) def depart_seealso(self, node): self.end_state(first='') def visit_footnote(self, node): self._footnote = node.children[0].astext().strip() self.new_state(len(self._footnote) + self.indent) def depart_footnote(self, node): self.end_state(first='[%s] ' % self._footnote) def visit_citation(self, node): if len(node) and isinstance(node[0], nodes.label): self._citlabel = node[0].astext() else: self._citlabel = '' self.new_state(len(self._citlabel) + self.indent) def depart_citation(self, node): self.end_state(first='[%s] ' % self._citlabel) def visit_label(self, node): raise nodes.SkipNode # TODO: option list could use some better styling def visit_option_list(self, node): # self.log_unknown("option_list", node) pass def depart_option_list(self, node): pass def visit_option_list_item(self, node): self.new_state(0) def depart_option_list_item(self, node): self.end_state() def visit_option_group(self, node): self._firstoption = True def depart_option_group(self, node): self.add_text(' ') def visit_option(self, node): if self._firstoption: self._firstoption = False else: self.add_text(', ') def depart_option(self, node): pass def visit_option_string(self, node): # self.log_unknown("option_string", node) pass def depart_option_string(self, node): pass def visit_option_argument(self, node): self.add_text(node['delimiter']) def depart_option_argument(self, node): pass def visit_description(self, node): # self.log_unknown("description", node) pass def depart_description(self, node): pass def visit_tabular_col_spec(self, node): raise nodes.SkipNode def visit_colspec(self, node): self.table[0].append(node['colwidth']) raise nodes.SkipNode def visit_tgroup(self, node): # self.log_unknown("tgroup", node) pass def depart_tgroup(self, node): pass def visit_thead(self, node): # self.log_unknown("thead", node) pass def depart_thead(self, node): pass def visit_tbody(self, node): self.table.append('sep') def depart_tbody(self, node): pass def visit_row(self, node): self.table.append([]) def depart_row(self, node): pass def visit_entry(self, node): if 'morerows' in node or 'morecols' in node: raise NotImplementedError('Column or row spanning cells are ' 'not implemented.') self.new_state(0) def depart_entry(self, node): text = self.nl.join(self.nl.join(x[1]) for x in self.states.pop()) self.stateindent.pop() self.table[-1].append(text) def visit_table(self, node): if self.table: raise NotImplementedError('Nested tables are not supported.') self.new_state(0) self.table = [[]] def depart_table(self, node): lines = self.table[1:] fmted_rows = [] colwidths = self.table[0] realwidths = colwidths[:] separator = 0 # don't allow paragraphs in table cells for now for line in lines: if line == 'sep': separator = len(fmted_rows) else: cells = [] for i, cell in enumerate(line): par = self.wrap(cell, width=colwidths[i]) if par: maxwidth = max(list(map(len, par))) else: maxwidth = 0 realwidths[i] = max(realwidths[i], maxwidth) cells.append(par) fmted_rows.append(cells) def writesep(char='-'): out = ['+'] for width in realwidths: out.append(char * (width+2)) out.append('+') self.add_text(''.join(out) + self.nl) def writerow(row): lines = list(zip(*row)) for line in lines: out = ['|'] for i, cell in enumerate(line): if cell: out.append(' ' + cell.ljust(realwidths[i]+1)) else: out.append(' ' * (realwidths[i] + 2)) out.append('|') self.add_text(''.join(out) + self.nl) for i, row in enumerate(fmted_rows): if separator and i == separator: writesep('=') else: writesep('-') writerow(row) writesep('-') self.table = None self.end_state(wrap=False) def visit_acks(self, node): self.new_state(0) self.add_text(', '.join(n.astext() for n in node.children[0].children) + '.') self.end_state() raise nodes.SkipNode def visit_image(self, node): self.new_state(0) if 'uri' in node: self.add_text(_('.. image:: %s') % node['uri']) elif 'target' in node.attributes: self.add_text(_('.. image: %s') % node['target']) elif 'alt' in node.attributes: self.add_text(_('[image: %s]') % node['alt']) else: self.add_text(_('[image]')) self.end_state(wrap=False) raise nodes.SkipNode def visit_transition(self, node): indent = sum(self.stateindent) self.new_state(0) self.add_text('=' * (MAXWIDTH - indent)) self.end_state() raise nodes.SkipNode def visit_bullet_list(self, node): def bullet_list_format(counter): return '*' self.list_counter.append(-1) # TODO: just 0 is fine. self.list_formatter.append(bullet_list_format) def depart_bullet_list(self, node): self.list_counter.pop() self.list_formatter.pop() def visit_enumerated_list(self, node): def enumerated_list_format(counter): return str(counter) + '.' self.list_counter.append(0) self.list_formatter.append(enumerated_list_format) def depart_enumerated_list(self, node): self.list_counter.pop() self.list_formatter.pop() def visit_list_item(self, node): self.list_counter[-1] += 1 bullet_formatter = self.list_formatter[-1] bullet = bullet_formatter(self.list_counter[-1]) indent = max(self.indent, len(bullet) + 1) self.new_state(indent) def depart_list_item(self, node): # formatting to make the string `self.stateindent[-1]` chars long. format = '%%-%ds' % (self.stateindent[-1]) bullet_formatter = self.list_formatter[-1] bullet = format % bullet_formatter(self.list_counter[-1]) self.end_state(first=bullet, end=None) def visit_definition_list(self, node): pass def depart_definition_list(self, node): pass def visit_definition_list_item(self, node): self._li_has_classifier = len(node) >= 2 and \ isinstance(node[1], nodes.classifier) def depart_definition_list_item(self, node): pass def visit_term(self, node): self.new_state(0) def depart_term(self, node): if not self._li_has_classifier: self.end_state(end=None) def visit_termsep(self, node): self.add_text(', ') raise nodes.SkipNode def visit_classifier(self, node): self.add_text(' : ') def depart_classifier(self, node): self.end_state(end=None) def visit_definition(self, node): self.new_state(self.indent) def depart_definition(self, node): self.end_state() def visit_field_list(self, node): # self.log_unknown("field_list", node) pass def depart_field_list(self, node): pass def visit_field(self, node): self.new_state(0) def depart_field(self, node): self.end_state(end=None) def visit_field_name(self, node): self.add_text(':') def depart_field_name(self, node): self.add_text(':') content = node.astext() self.add_text((16-len(content))*' ') def visit_field_body(self, node): self.new_state(self.indent) def depart_field_body(self, node): self.end_state() def visit_centered(self, node): pass def depart_centered(self, node): pass def visit_hlist(self, node): # self.log_unknown("hlist", node) pass def depart_hlist(self, node): pass def visit_hlistcol(self, node): # self.log_unknown("hlistcol", node) pass def depart_hlistcol(self, node): pass def visit_admonition(self, node): self.new_state(0) def depart_admonition(self, node): self.end_state() def _visit_admonition(self, node): self.new_state(self.indent) def _make_depart_admonition(name): def depart_admonition(self, node): self.end_state(first=admonitionlabels[name] + ': ') return depart_admonition visit_attention = _visit_admonition depart_attention = _make_depart_admonition('attention') visit_caution = _visit_admonition depart_caution = _make_depart_admonition('caution') visit_danger = _visit_admonition depart_danger = _make_depart_admonition('danger') visit_error = _visit_admonition depart_error = _make_depart_admonition('error') visit_hint = _visit_admonition depart_hint = _make_depart_admonition('hint') visit_important = _visit_admonition depart_important = _make_depart_admonition('important') visit_note = _visit_admonition depart_note = _make_depart_admonition('note') visit_tip = _visit_admonition depart_tip = _make_depart_admonition('tip') visit_warning = _visit_admonition depart_warning = _make_depart_admonition('warning') def visit_versionmodified(self, node): self.new_state(0) def depart_versionmodified(self, node): self.end_state() def visit_literal_block(self, node): is_code_block = False # Support for Sphinx < 2.0, which defines classes['code', 'language'] if 'code' in node.get('classes', []): is_code_block = True if node.get('language', 'default') == 'default' and len(node['classes']) >= 2: node['language'] = node['classes'][1] # highlight_args is the only way to distinguish between :: and .. code:: in Sphinx 2 or higher. if node.get('highlight_args') != None: is_code_block = True if is_code_block: if node.get('language', 'default') == 'default': directive = ".. code::" else: directive = ".. code:: %s" % node['language'] if node.get('linenos'): indent = self.indent * ' ' directive += "%s%s:number-lines:" % (self.nl, indent) else: directive = "::" self.new_state(0) self.add_text(directive) self.end_state(wrap=False) self.new_state(self.indent) def depart_literal_block(self, node): self.end_state(wrap=False) def visit_doctest_block(self, node): self.new_state(0) def depart_doctest_block(self, node): self.end_state(wrap=False) def visit_line_block(self, node): self.new_state(0) def depart_line_block(self, node): self.end_state(wrap=False) def visit_line(self, node): # self.log_unknown("line", node) pass def depart_line(self, node): pass def visit_block_quote(self, node): self.new_state(self.indent) def depart_block_quote(self, node): self.end_state() def visit_compact_paragraph(self, node): pass def depart_compact_paragraph(self, node): pass def visit_paragraph(self, node): if not isinstance(node.parent, nodes.Admonition) or \ isinstance(node.parent, addnodes.seealso): self.new_state(0) def depart_paragraph(self, node): if not isinstance(node.parent, nodes.Admonition) or \ isinstance(node.parent, addnodes.seealso): self.end_state() def visit_target(self, node): if 'refid' in node: self.new_state(0) if node.get('ids'): self.add_text(self.nl.join( '.. _%s: %s_' % (id, node['refid']) for id in node['ids'] )) else: self.add_text('.. _'+node['refid']+':') def depart_target(self, node): if 'refid' in node: self.end_state(wrap=False) def visit_index(self, node): raise nodes.SkipNode def visit_substitution_definition(self, node): raise nodes.SkipNode def visit_pending_xref(self, node): pass def depart_pending_xref(self, node): pass def visit_reference(self, node): refname = node.get('name') refbody = node.astext() refuri = node.get('refuri') refid = node.get('refid') if node.get('anonymous'): underscore = '__' else: underscore = '_' if refuri and refuri.endswith('_'): refuri = refuri[:-1] + '\\_' if node.get('internal'): if refuri: self.add_text('`%s <%s>`%s' % (refbody, refuri, underscore)) elif refid: self.add_text('`%s <#%s>`%s' % (refbody, refid, underscore)) else: return else: if refuri and refname: self.add_text('`%s <%s>`%s' % (refname, refuri, underscore)) elif refuri: self.add_text('%s' % (refuri)) elif refname: self.add_text('`%s`%s' % (refname, underscore)) else: return raise nodes.SkipNode def depart_reference(self, node): pass def visit_download_reference(self, node): self.log_unknown("download_reference", node) pass def depart_download_reference(self, node): pass def visit_emphasis(self, node): self.add_text('*') def depart_emphasis(self, node): self.add_text('*') def visit_literal_emphasis(self, node): self.add_text('*') def depart_literal_emphasis(self, node): self.add_text('*') def visit_strong(self, node): self.add_text('**') def depart_strong(self, node): self.add_text('**') def visit_abbreviation(self, node): self.add_text('') def depart_abbreviation(self, node): if node.hasattr('explanation'): self.add_text(' (%s)' % node['explanation']) def visit_title_reference(self, node): # self.log_unknown("title_reference", node) self.add_text('*') def depart_title_reference(self, node): self.add_text('*') def visit_literal(self, node): self.add_text('``') def depart_literal(self, node): self.add_text('``') def visit_subscript(self, node): self.add_text(':sub:`') def depart_subscript(self, node): self.add_text('`') def visit_superscript(self, node): self.add_text(':sup:`') def depart_superscript(self, node): self.add_text('`') def visit_footnote_reference(self, node): self.add_text('[%s]' % node.astext()) raise nodes.SkipNode def visit_citation_reference(self, node): self.add_text('[%s]' % node.astext()) raise nodes.SkipNode def visit_Text(self, node): self.add_text(node.astext()) def depart_Text(self, node): pass def visit_generated(self, node): # self.log_unknown("generated", node) pass def depart_generated(self, node): pass def visit_inline(self, node): # self.log_unknown("inline", node) pass def depart_inline(self, node): pass def visit_problematic(self, node): pass def depart_problematic(self, node): pass def visit_system_message(self, node): self.new_state(0) self.add_text('' % node.astext()) self.end_state() raise nodes.SkipNode def visit_comment(self, node): raise nodes.SkipNode def visit_meta(self, node): # only valid for HTML raise nodes.SkipNode def visit_raw(self, node): if 'text' in node.get('format', '').split(): self.body.append(node.astext()) raise nodes.SkipNode def unknown_visit(self, node): raise NotImplementedError('Unknown node: ' + node.__class__.__name__) restbuilder-0.3/sphinxcontrib/builders/0000755000175000017500000000000014016722131020260 5ustar carstencarstenrestbuilder-0.3/sphinxcontrib/builders/__init__.py0000644000175000017500000000016514016722131022373 0ustar carstencarsten# -*- coding: utf-8 -*- """ sphinxcontrib.builders ~~~~~~~~~~~~~~~~~~~~~~ Custom docutils builders. """ restbuilder-0.3/sphinxcontrib/builders/rst.py0000644000175000017500000000731514016722131021450 0ustar carstencarsten# -*- coding: utf-8 -*- """ sphinxcontrib.builders.rst ~~~~~~~~~~~~~~~~~~~~~~~~~~ ReST Sphinx builder. :copyright: Copyright 2012-2021 by Freek Dijkstra and contributors. :license: BSD, see LICENSE.txt for details. """ from __future__ import (print_function, unicode_literals, absolute_import) import codecs from os import path from docutils.io import StringOutput from sphinx.builders import Builder from sphinx.util.osutil import ensuredir, SEP from ..writers.rst import RstWriter class RstBuilder(Builder): name = 'rst' format = 'rst' file_suffix = '.rst' link_suffix = None # defaults to file_suffix def init(self): """Load necessary templates and perform initialization.""" if self.config.rst_file_suffix is not None: self.file_suffix = self.config.rst_file_suffix if self.config.rst_link_suffix is not None: self.link_suffix = self.config.rst_link_suffix elif self.link_suffix is None: self.link_suffix = self.file_suffix # Function to convert the docname to a reST file name. def file_transform(docname): return docname + self.file_suffix # Function to convert the docname to a relative URI. def link_transform(docname): return docname + self.link_suffix if self.config.rst_file_transform is not None: self.file_transform = self.config.rst_file_transform else: self.file_transform = file_transform if self.config.rst_link_transform is not None: self.link_transform = self.config.rst_link_transform else: self.link_transform = link_transform def get_outdated_docs(self): """ Return an iterable of input files that are outdated. """ # This method is taken from TextBuilder.get_outdated_docs() # with minor changes to support :confval:`rst_file_transform`. for docname in self.env.found_docs: if docname not in self.env.all_docs: yield docname continue sourcename = path.join(self.env.srcdir, docname + self.file_suffix) targetname = path.join(self.outdir, self.file_transform(docname)) # print (sourcename, targetname) try: targetmtime = path.getmtime(targetname) except Exception: targetmtime = 0 try: srcmtime = path.getmtime(sourcename) if srcmtime > targetmtime: yield docname except EnvironmentError: # source doesn't exist anymore pass def get_target_uri(self, docname, typ=None): return self.link_transform(docname) def prepare_writing(self, docnames): self.writer = RstWriter(self) def write_doc(self, docname, doctree): # This method is taken from TextBuilder.write_doc() # with minor changes to support :confval:`rst_file_transform`. destination = StringOutput(encoding='utf-8') # print "write(%s,%s)" % (type(doctree), type(destination)) self.writer.write(doctree, destination) outfilename = path.join(self.outdir, self.file_transform(docname)) # print "write(%s,%s) -> %s" % (type(doctree), type(destination), outfilename) ensuredir(path.dirname(outfilename)) try: f = codecs.open(outfilename, 'w', 'utf-8') try: f.write(self.writer.output) finally: f.close() except (IOError, OSError) as err: self.warn("error writing file %s: %s" % (outfilename, err)) def finish(self): pass restbuilder-0.3/tox.ini0000644000175000017500000000351614016722131015075 0ustar carstencarsten[tox] ; If you change the test matrix, also change it in .github/workflows/tests.yml envlist = python2.7-sphinx{1.4,1.8} # Supported by Sphinx 1.0-1.8 python3.5-sphinx{1.4,2.0,3.4} # Supported by Sphinx 1.4-3.4 python3.6-sphinx{1.5,3.4} # Supported by Sphinx 1.5-4.x python3.7-sphinx{3.4} # Supported by Sphinx 1.8-4.x python3.8-sphinx{1.8,3.4} # Supported by Sphinx 1.8-4.x python3.9-sphinx{2.4,3.0,3.4} # Supported by Sphinx 2.4-4.x [testenv] basepython = python2.7: python2.7 python3.5: python3.5 python3.6: python3.6 python3.7: python3.7 python3.8: python3.8 python3.9: python3.9 python3.10: python3.10 deps = pytest sphinx1.4: Sphinx >= 1.4, < 1.5 # Supports Python 2.6, 2.7, 3.3, 3.4, 3.5 sphinx1.5: Sphinx >= 1.5, < 1.6 # Supports Python 2.7, 3.4, 3.5 sphinx1.6: Sphinx >= 1.6, < 1.7 # Supports Python 2.7, 3.4, 3.5, 3.6 sphinx1.7: Sphinx >= 1.7, < 1.8 # Supports Python 2.7, 3.4, 3.5, 3.6 sphinx1.8: Sphinx >= 1.8, < 2.0 # Supports Python 2.7, 3.4, 3.5, 3.6, 3.7, 3.8 sphinx2.0: Sphinx >= 2.0, < 2.1 # Supports Python 3.4, 3.5, 3.6, 3.7, 3.8 sphinx2.1: Sphinx >= 2.1, < 2.2 # Supports Python 3.5, 3.6, 3.7, 3.8 sphinx2.2: Sphinx >= 2.2, < 2.3 # Supports Python 3.5, 3.6, 3.7, 3.8 sphinx2.3: Sphinx >= 2.3, < 2.4 # Supports Python 3.5, 3.6, 3.7, 3.8 sphinx2.4: Sphinx >= 2.4, < 3.0 # Supports Python 3.5, 3.6, 3.7, 3.8, 3.9 sphinx3.0: Sphinx >= 3.0, < 3.1 # Supports Python 3.5, 3.6, 3.7, 3.8, 3.9 sphinx3.4: Sphinx >= 3.4, < 4.0 # Supports Python 3.5, 3.6, 3.7, 3.8, 3.9 sphinx4.0: Sphinx >= 4.0, < 4.1 # Supports Python 3.6, 3.7, 3.8, 3.9 commands = pytest -v [pytest] filterwarnings = ; suppress FutureWarning in Sphinx 1.0...2.2 about Node.traverse() ignore::FutureWarning:sphinx.util.nodes restbuilder-0.3/.gitignore0000644000175000017500000000013014016722131015537 0ustar carstencarstenbuild/ dist/ output/ sphinxcontrib/__pycache__ sphinxcontrib_restbuilder.egg-info .tox/