diff --git a/readthedocs/embed/tests/data/sphinx/glossary/page-glossary.html b/readthedocs/embed/tests/data/sphinx/glossary/page-glossary.html new file mode 100644 index 00000000000..d8363e65f62 --- /dev/null +++ b/readthedocs/embed/tests/data/sphinx/glossary/page-glossary.html @@ -0,0 +1,192 @@ +
+ +

Glossary

+
+
builder
+
+

+ A class (inheriting from Builder) that + takes + parsed documents and performs an action on them. Normally, builders + translate the documents to an output format, but it is also possible to + use builders that e.g. check for broken links in the documentation, or + build coverage information. +

+

+ See Builders for an + overview over Sphinx\u2019s built-in + builders. +

+
+
configuration directory
+
+

+ The directory containing conf.py. By default, this is the + same as + the source + directory, but can be set differently with the -c + command-line option. +

+
+
directive +
+
+

+ A reStructuredText markup element that allows marking a block of content + with special meaning. Directives are supplied not only by docutils, but + Sphinx and custom extensions can add their own. The basic directive + syntax looks like this: +

+
+
+
.. directivename:: argument ...
+   :option: value
+
+   Content of the directive.
+
+
+
+

+ See Directives for more information. +

+
+
document name
+
+

+ Since reST source files can have different extensions (some people like + .txt, some like .rst \u2013 the extension can be + configured with + source_suffix) + and different OSes have different path + separators, Sphinx abstracts them: document names are always + relative to the source directory, the extension is stripped, and + path separators are converted to slashes. All values, parameters and such + referring to \u201cdocuments\u201d expect such document names. +

+

+ Examples for document names are index, library/zipfile, or + reference/datamodel/types. Note that + there is no leading or trailing + slash. +

+
+
domain
+
+

+ A domain is a collection of markup (reStructuredText directives + and roles) to + describe and link to objects belonging + together, e.g. elements of a programming language. Directive and role + names in a domain have names like domain:name, e.g. py:function. +

+

+ Having domains means that there are no naming problems when one set of + documentation wants to refer to e.g. C++ and Python classes. It also + means that extensions that support the documentation of whole new + languages are much easier to write. +

+

+ For more information, refer to Domains. +

+
+
environment
+
+

+ A structure where information about all documents under the root is saved, + and used for cross-referencing. The environment is pickled after the + parsing stage, so that successive runs only need to read and parse new and + changed documents. +

+
+
extension +
+
+

+ A custom role, directive or + other aspect of Sphinx that + allows users to modify any aspect of the build process within Sphinx. +

+

+ For more information, refer to Extensions. +

+
+
master document
+
+

+ The document that contains the root toctree directive. +

+
+
object
+
+

+ The basic building block of Sphinx documentation. Every \u201cobject + directive\u201d (e.g. function or object) creates + such a + block; and most objects can be cross-referenced to. +

+
+
RemoveInSphinxXXXWarning
+
+

+ The feature which is warned will be removed in Sphinx-XXX version. + It usually caused from Sphinx extensions which is using deprecated. + See also Deprecation + Warnings. +

+
+
role
+
+

+ A reStructuredText markup element that allows marking a piece of text. + Like directives, roles are extensible. The basic syntax looks like this: + :rolename:`content`. See Inline markup for details. +

+
+
source directory
+
+

+ The directory which, including its subdirectories, contains all source + files for one Sphinx project. +

+
+
reStructuredText
+
+

+ An easy-to-read, what-you-see-is-what-you-get plaintext markup syntax and + parser system. +

+
+
+
diff --git a/readthedocs/embed/tests/data/sphinx/glossary/page-term-RemoveInSphinxXXXWarning.html b/readthedocs/embed/tests/data/sphinx/glossary/page-term-RemoveInSphinxXXXWarning.html new file mode 100644 index 00000000000..fa723104787 --- /dev/null +++ b/readthedocs/embed/tests/data/sphinx/glossary/page-term-RemoveInSphinxXXXWarning.html @@ -0,0 +1,9 @@ +
+

+ The feature which is warned will be removed in Sphinx-XXX version. + It usually caused from Sphinx extensions which is using deprecated. + See also Deprecation + Warnings. +

+
diff --git a/readthedocs/embed/tests/data/sphinx/glossary/page-term-builder.html b/readthedocs/embed/tests/data/sphinx/glossary/page-term-builder.html new file mode 100644 index 00000000000..9d55cb6051e --- /dev/null +++ b/readthedocs/embed/tests/data/sphinx/glossary/page-term-builder.html @@ -0,0 +1,17 @@ +
+

+ A class (inheriting from Builder) that + takes + parsed documents and performs an action on them. Normally, builders + translate the documents to an output format, but it is also possible to + use builders that e.g. check for broken links in the documentation, or + build coverage information. +

+

+ See Builders for an + overview over Sphinx\u2019s built-in + builders. +

+
diff --git a/readthedocs/embed/tests/data/sphinx/glossary/page-term-configuration-directory.html b/readthedocs/embed/tests/data/sphinx/glossary/page-term-configuration-directory.html new file mode 100644 index 00000000000..3b6e4097b3a --- /dev/null +++ b/readthedocs/embed/tests/data/sphinx/glossary/page-term-configuration-directory.html @@ -0,0 +1,10 @@ +
+

+ The directory containing conf.py. By default, this is the + same as + the source + directory, but can be set differently with the -c + command-line option. +

+
diff --git a/readthedocs/embed/tests/data/sphinx/glossary/page-term-directive.html b/readthedocs/embed/tests/data/sphinx/glossary/page-term-directive.html new file mode 100644 index 00000000000..24ffad6dd78 --- /dev/null +++ b/readthedocs/embed/tests/data/sphinx/glossary/page-term-directive.html @@ -0,0 +1,21 @@ +
+

+ A reStructuredText markup element that allows marking a block of content + with special meaning. Directives are supplied not only by docutils, but + Sphinx and custom extensions can add their own. The basic directive + syntax looks like this: +

+
+
+
.. directivename:: argument ...
+   :option: value
+
+   Content of the directive.
+
+
+
+

+ See Directives for more information. +

+
diff --git a/readthedocs/embed/tests/data/sphinx/glossary/page-term-document-name.html b/readthedocs/embed/tests/data/sphinx/glossary/page-term-document-name.html new file mode 100644 index 00000000000..45745c36dd2 --- /dev/null +++ b/readthedocs/embed/tests/data/sphinx/glossary/page-term-document-name.html @@ -0,0 +1,24 @@ +
+

+ Since reST source files can have different extensions (some people like + .txt, some like .rst \u2013 the extension can be + configured with + source_suffix) + and different OSes have different path + separators, Sphinx abstracts them: document names are always + relative to the source directory, the extension is stripped, and + path separators are converted to slashes. All values, parameters and such + referring to \u201cdocuments\u201d expect such document names. +

+

+ Examples for document names are index, library/zipfile, or + reference/datamodel/types. Note that + there is no leading or trailing + slash. +

+
diff --git a/readthedocs/embed/tests/data/sphinx/glossary/page-term-domain.html b/readthedocs/embed/tests/data/sphinx/glossary/page-term-domain.html new file mode 100644 index 00000000000..b67bc51b7e7 --- /dev/null +++ b/readthedocs/embed/tests/data/sphinx/glossary/page-term-domain.html @@ -0,0 +1,23 @@ +
+

+ A domain is a collection of markup (reStructuredText directives + and roles) to + describe and link to objects belonging + together, e.g. elements of a programming language. Directive and role + names in a domain have names like domain:name, e.g. py:function. +

+

+ Having domains means that there are no naming problems when one set of + documentation wants to refer to e.g. C++ and Python classes. It also + means that extensions that support the documentation of whole new + languages are much easier to write. +

+

+ For more information, refer to Domains. +

+
diff --git a/readthedocs/embed/tests/data/sphinx/glossary/page-term-environment.html b/readthedocs/embed/tests/data/sphinx/glossary/page-term-environment.html new file mode 100644 index 00000000000..3db153b4fdb --- /dev/null +++ b/readthedocs/embed/tests/data/sphinx/glossary/page-term-environment.html @@ -0,0 +1,8 @@ +
+

+ A structure where information about all documents under the root is saved, + and used for cross-referencing. The environment is pickled after the + parsing stage, so that successive runs only need to read and parse new and + changed documents. +

+
diff --git a/readthedocs/embed/tests/data/sphinx/glossary/page-term-extension.html b/readthedocs/embed/tests/data/sphinx/glossary/page-term-extension.html new file mode 100644 index 00000000000..25cef9bdb7c --- /dev/null +++ b/readthedocs/embed/tests/data/sphinx/glossary/page-term-extension.html @@ -0,0 +1,12 @@ +
+

+ A custom role, directive or + other aspect of Sphinx that + allows users to modify any aspect of the build process within Sphinx. +

+

+ For more information, refer to Extensions. +

+
diff --git a/readthedocs/embed/tests/data/sphinx/glossary/page-term-master-document.html b/readthedocs/embed/tests/data/sphinx/glossary/page-term-master-document.html new file mode 100644 index 00000000000..e56aeb36589 --- /dev/null +++ b/readthedocs/embed/tests/data/sphinx/glossary/page-term-master-document.html @@ -0,0 +1,7 @@ +
+

+ The document that contains the root toctree directive. +

+
diff --git a/readthedocs/embed/tests/data/sphinx/glossary/page-term-object.html b/readthedocs/embed/tests/data/sphinx/glossary/page-term-object.html new file mode 100644 index 00000000000..af88e5c8b49 --- /dev/null +++ b/readthedocs/embed/tests/data/sphinx/glossary/page-term-object.html @@ -0,0 +1,12 @@ +
+

+ The basic building block of Sphinx documentation. Every \u201cobject + directive\u201d (e.g. function or object) creates + such a + block; and most objects can be cross-referenced to. +

+
diff --git a/readthedocs/embed/tests/data/sphinx/glossary/page-term-reStructuredText.html b/readthedocs/embed/tests/data/sphinx/glossary/page-term-reStructuredText.html new file mode 100644 index 00000000000..58701e11c0d --- /dev/null +++ b/readthedocs/embed/tests/data/sphinx/glossary/page-term-reStructuredText.html @@ -0,0 +1,6 @@ +
+

+ An easy-to-read, what-you-see-is-what-you-get plaintext markup syntax and + parser system. +

+
diff --git a/readthedocs/embed/tests/data/sphinx/glossary/page-term-role.html b/readthedocs/embed/tests/data/sphinx/glossary/page-term-role.html new file mode 100644 index 00000000000..1011220adac --- /dev/null +++ b/readthedocs/embed/tests/data/sphinx/glossary/page-term-role.html @@ -0,0 +1,9 @@ +
+

+ A reStructuredText markup element that allows marking a piece of text. + Like directives, roles are extensible. The basic syntax looks like this: + :rolename:`content`. See Inline markup for details. +

+
diff --git a/readthedocs/embed/tests/data/sphinx/glossary/page-term-source-directory.html b/readthedocs/embed/tests/data/sphinx/glossary/page-term-source-directory.html new file mode 100644 index 00000000000..6e946de7648 --- /dev/null +++ b/readthedocs/embed/tests/data/sphinx/glossary/page-term-source-directory.html @@ -0,0 +1,6 @@ +
+

+ The directory which, including its subdirectories, contains all source + files for one Sphinx project. +

+
diff --git a/readthedocs/embed/tests/data/sphinx/glossary/page.html b/readthedocs/embed/tests/data/sphinx/glossary/page.html new file mode 100644 index 00000000000..c65cf997223 --- /dev/null +++ b/readthedocs/embed/tests/data/sphinx/glossary/page.html @@ -0,0 +1,192 @@ +
+ +

Glossary

+
+
builder
+
+

+ A class (inheriting from Builder) that + takes + parsed documents and performs an action on them. Normally, builders + translate the documents to an output format, but it is also possible to + use builders that e.g. check for broken links in the documentation, or + build coverage information. +

+

+ See Builders for an + overview over Sphinx\u2019s built-in + builders. +

+
+
configuration directory
+
+

+ The directory containing conf.py. By default, this is the + same as + the source + directory, but can be set differently with the -c + command-line option. +

+
+
directive +
+
+

+ A reStructuredText markup element that allows marking a block of content + with special meaning. Directives are supplied not only by docutils, but + Sphinx and custom extensions can add their own. The basic directive + syntax looks like this: +

+
+
+
.. directivename:: argument ...
+   :option: value
+
+   Content of the directive.
+
+
+
+

+ See Directives for more information. +

+
+
document name
+
+

+ Since reST source files can have different extensions (some people like + .txt, some like .rst \u2013 the extension can be + configured with + source_suffix) + and different OSes have different path + separators, Sphinx abstracts them: document names are always + relative to the source directory, the extension is stripped, and + path separators are converted to slashes. All values, parameters and such + referring to \u201cdocuments\u201d expect such document names. +

+

+ Examples for document names are index, library/zipfile, or + reference/datamodel/types. Note that + there is no leading or trailing + slash. +

+
+
domain
+
+

+ A domain is a collection of markup (reStructuredText directives + and roles) to + describe and link to objects belonging + together, e.g. elements of a programming language. Directive and role + names in a domain have names like domain:name, e.g. py:function. +

+

+ Having domains means that there are no naming problems when one set of + documentation wants to refer to e.g. C++ and Python classes. It also + means that extensions that support the documentation of whole new + languages are much easier to write. +

+

+ For more information, refer to Domains. +

+
+
environment
+
+

+ A structure where information about all documents under the root is saved, + and used for cross-referencing. The environment is pickled after the + parsing stage, so that successive runs only need to read and parse new and + changed documents. +

+
+
extension +
+
+

+ A custom role, directive or + other aspect of Sphinx that + allows users to modify any aspect of the build process within Sphinx. +

+

+ For more information, refer to Extensions. +

+
+
master document
+
+

+ The document that contains the root toctree directive. +

+
+
object
+
+

+ The basic building block of Sphinx documentation. Every \u201cobject + directive\u201d (e.g. function or object) creates + such a + block; and most objects can be cross-referenced to. +

+
+
RemoveInSphinxXXXWarning
+
+

+ The feature which is warned will be removed in Sphinx-XXX version. + It usually caused from Sphinx extensions which is using deprecated. + See also Deprecation + Warnings. +

+
+
role
+
+

+ A reStructuredText markup element that allows marking a piece of text. + Like directives, roles are extensible. The basic syntax looks like this: + :rolename:`content`. See Inline markup for details. +

+
+
source directory
+
+

+ The directory which, including its subdirectories, contains all source + files for one Sphinx project. +

+
+
reStructuredText
+
+

+ An easy-to-read, what-you-see-is-what-you-get plaintext markup syntax and + parser system. +

+
+
+
diff --git a/readthedocs/embed/tests/data/sphinx/glossary/page.json b/readthedocs/embed/tests/data/sphinx/glossary/page.json new file mode 100644 index 00000000000..fb566b5b827 --- /dev/null +++ b/readthedocs/embed/tests/data/sphinx/glossary/page.json @@ -0,0 +1,8 @@ +{ + "body": "", + "title": "Glossary", + "sourcename": "glossary.rst.txt", + "current_page_name": "glossary", + "toc": "\n", + "page_source_suffix": ".rst" +} diff --git a/readthedocs/embed/tests/test_api.py b/readthedocs/embed/tests/test_api.py index ade6fc68777..83073a12852 100644 --- a/readthedocs/embed/tests/test_api.py +++ b/readthedocs/embed/tests/test_api.py @@ -193,6 +193,64 @@ def test_embed_sphinx_bibtex(self, storage_mock, section): assert response.data == expected + @pytest.mark.parametrize( + 'section', + [ + 'glossary', + 'term-builder', + 'term-configuration-directory', + 'term-directive', + 'term-document-name', + 'term-domain', + 'term-environment', + 'term-extension', + 'term-master-document', + 'term-object', + 'term-RemoveInSphinxXXXWarning', + 'term-role', + 'term-source-directory', + 'term-reStructuredText', + ] + ) + @mock.patch('readthedocs.embed.views.build_media_storage') + def test_embed_sphinx_glossary(self, storage_mock, section): + # TODO: render definition lists as a definition list with one element. + json_file = data_path / 'sphinx/glossary/page.json' + html_file = data_path / 'sphinx/glossary/page.html' + + self._patch_sphinx_json_file( + storage_mock=storage_mock, + json_file=json_file, + html_file=html_file, + ) + + response = do_embed( + project=self.project, + version=self.version, + section=section, + path='index.html', + ) + + section_content = self._get_html_content( + data_path / f'sphinx/glossary/page-{section}.html' + ) + + expected = { + 'content': section_content, + 'headers': [ + {'Glossary': '#'}, + ], + 'url': 'http://project.readthedocs.io/en/latest/index.html', + 'meta': { + 'project': 'project', + 'version': 'latest', + 'doc': None, + 'section': section, + }, + } + + assert response.data == expected + @mock.patch('readthedocs.embed.views.build_media_storage') def test_embed_mkdocs(self, storage_mock): json_file = data_path / 'mkdocs/latest/index.json'