+
+
+
+
+
diff --git a/readthedocs/search/tests/data/mkdocs/in/material/index.html b/readthedocs/search/tests/data/mkdocs/in/material/index.html
new file mode 100644
index 00000000000..dd04820579c
--- /dev/null
+++ b/readthedocs/search/tests/data/mkdocs/in/material/index.html
@@ -0,0 +1,1504 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/readthedocs/search/tests/data/mkdocs/in/mkdocs-1.1/404.html b/readthedocs/search/tests/data/mkdocs/in/mkdocs-1.1/404.html
new file mode 100644
index 00000000000..cb12fa2543f
--- /dev/null
+++ b/readthedocs/search/tests/data/mkdocs/in/mkdocs-1.1/404.html
@@ -0,0 +1,200 @@
+
+
+
+
+
+
+
diff --git a/readthedocs/search/tests/data/mkdocs/in/mkdocs-1.1/configuration.html b/readthedocs/search/tests/data/mkdocs/in/mkdocs-1.1/configuration.html
new file mode 100644
index 00000000000..93e3475efe0
--- /dev/null
+++ b/readthedocs/search/tests/data/mkdocs/in/mkdocs-1.1/configuration.html
@@ -0,0 +1,325 @@
+
+
+
+
+
+
+
diff --git a/readthedocs/search/tests/data/mkdocs/in/mkdocs-1.1/index.html b/readthedocs/search/tests/data/mkdocs/in/mkdocs-1.1/index.html
new file mode 100644
index 00000000000..502d3d01ff6
--- /dev/null
+++ b/readthedocs/search/tests/data/mkdocs/in/mkdocs-1.1/index.html
@@ -0,0 +1,316 @@
+
+
+
+
+
+
+
+
+
+
+
+
MkDocs
+
Project documentation with Markdown.
+
+
+
+
Overview
+
+ MkDocs is a fast , simple and downright gorgeous static site
+ generator that's geared towards building project documentation.
+
+
+
Host anywhere
+
+ MkDocs builds completely static HTML sites that you can host on GitHub pages,
+ Amazon S3, or anywhere else you choose.
+
+
+
Great themes available
+
+ There's a stack of good looking themes available for MkDocs.
+
+
+
+
+
Installation
+
Install with a Package Manager
+
+ If your package manager does not have a recent "MkDocs" package, you can still
+ use your package manager to install "Python" and "pip".
+
+
$ python --version
+Python 3.8.2
+$ pip --version
+pip 20.0.2 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)
+
+
+
+
Note
+
If you would like manpages installed for MkDocs, the click-man tool can
+ generate and install them for you. Simply run the following two commands:
+
pip install click-man
+click-man --target path/to/man/pages mkdocs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ From here you can search these documents. Enter
+ your search terms below.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Keys
+ Action
+
+
+
+
+ ?
+ Open this help
+
+
+ n
+ Next page
+
+
+ p
+ Previous page
+
+
+ s
+ Search
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/readthedocs/search/tests/data/mkdocs/in/mkdocs-1.1/no-main-header.html b/readthedocs/search/tests/data/mkdocs/in/mkdocs-1.1/no-main-header.html
new file mode 100644
index 00000000000..613f09592e0
--- /dev/null
+++ b/readthedocs/search/tests/data/mkdocs/in/mkdocs-1.1/no-main-header.html
@@ -0,0 +1,183 @@
+
+
+
+
+
+
+
+
+
+
+
+
No main header - Read the Docs MkDocs Test
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
I don't start with a header.
+
+
I'm more content.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ From here you can search these documents. Enter
+ your search terms below.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Keys
+ Action
+
+
+
+
+ ?
+ Open this help
+
+
+ n
+ Next page
+
+
+ p
+ Previous page
+
+
+ s
+ Search
+
+
+
+
+
+
+
+
+
+
+
diff --git a/readthedocs/search/tests/data/mkdocs/in/mkdocs-1.1/no-title.html b/readthedocs/search/tests/data/mkdocs/in/mkdocs-1.1/no-title.html
new file mode 100644
index 00000000000..fc4413021b3
--- /dev/null
+++ b/readthedocs/search/tests/data/mkdocs/in/mkdocs-1.1/no-title.html
@@ -0,0 +1,185 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
No title - Read the Docs MkDocs Test
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
This file doesn't have a header,
+ but it does have a content.
+
+
Another paragraph
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ From here you can search these documents. Enter
+ your search terms below.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Keys
+ Action
+
+
+
+
+ ?
+ Open this help
+
+
+ n
+ Next page
+
+
+ p
+ Previous page
+
+
+ s
+ Search
+
+
+
+
+
+
+
+
+
+
+
diff --git a/readthedocs/search/tests/data/mkdocs/in/readthedocs-1.1/404.html b/readthedocs/search/tests/data/mkdocs/in/readthedocs-1.1/404.html
new file mode 100644
index 00000000000..e8eed888de6
--- /dev/null
+++ b/readthedocs/search/tests/data/mkdocs/in/readthedocs-1.1/404.html
@@ -0,0 +1,131 @@
+
+
+
+
+
+
+
+
+
+
+
+
Read the Docs MkDocs Test
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/readthedocs/search/tests/data/mkdocs/in/readthedocs-1.1/index.html b/readthedocs/search/tests/data/mkdocs/in/readthedocs-1.1/index.html
new file mode 100644
index 00000000000..5f610ec33b5
--- /dev/null
+++ b/readthedocs/search/tests/data/mkdocs/in/readthedocs-1.1/index.html
@@ -0,0 +1,175 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Read the Docs MkDocs Test
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Read the Docs MkDocs Test
+
+
+
+
+
+
+
+ Docs »
+
+
+
+ Read the Docs MkDocs Test Project
+
+
+
+
+
+
+
+
+
+
+
Read the Docs MkDocs Test Project
+
This is a test of MkDocs as it appears on Read the Docs .
+ Different versions of this documentation are build with different versions and themes of mkdocs.
+
Use the version selector menu in the lower right to change the version and theme of this documentation
+
+
Some content:
+
+
Another title
+
I'm another title
+
I'm a subtitle
+
Another content, mkdocs is great!
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/readthedocs/search/tests/data/mkdocs/in/readthedocs-1.1/versions.html b/readthedocs/search/tests/data/mkdocs/in/readthedocs-1.1/versions.html
new file mode 100644
index 00000000000..55a9b3be75c
--- /dev/null
+++ b/readthedocs/search/tests/data/mkdocs/in/readthedocs-1.1/versions.html
@@ -0,0 +1,151 @@
+
+
+
+
+
+
+
+
+
+
+
+
Versions & Themes - Read the Docs MkDocs Test
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Read the Docs MkDocs Test
+
+
+
+
+
+
+
+ Docs »
+
+
+
+ Versions & Themes
+
+
+
+
+
+
+
+
+
+
+
Versions & Themes
+
There are a number of versions and themes for mkdocs
+ each of which have slight nuances with how they affect Read the Docs.
+
You can use the version menu in the lower right to switch
+ between versions and theme for this documentation.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/readthedocs/search/tests/data/mkdocs/in/windmill/index.html b/readthedocs/search/tests/data/mkdocs/in/windmill/index.html
new file mode 100644
index 00000000000..e729b15b45a
--- /dev/null
+++ b/readthedocs/search/tests/data/mkdocs/in/windmill/index.html
@@ -0,0 +1,239 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Windmill MkDocs Theme
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Windmill theme
+
About
+
Windmill theme focuses on clean usable navigation for large documentation
+ projects. It retains the state of the menu of pages and folders across page
+ transitions, by keeping navigation to an iframe.
+
Within pages, it uses the default mkdocs theme, including syntax highlighting.
+
+
Installation
+
Install the Windmill theme using pip
:
+
pip install mkdocs-windmill
+
+
+
Usage
+
To use the Windmill theme installed via pip
, add this to your mkdocs.yml
:
+
theme: 'windmill'
+
+
+
If you cloned Windmill from GitHub:
+
theme:
+ name: null
+ custom_dir: '{INSTALL_DIR}/mkdocs_windmill'
+ # Copy settings from mkdocs_theme.yml, which is ignored by custom_dir themes.
+ static_templates: [404.html]
+ search_index_only: true
+ include_search_page: true
+
+
+
Note that it's important for there to exist a homepage, e.g. a top-level root element in mkdocs 1.0+:
+
nav:
+ - Home: index.md
+
+
+
+
+
+
+
+
+
+
+ Edit on GitHub
+
+ Documentation built with MkDocs using Windmill theme by Grist Labs.
+
+
+
+
+
diff --git a/readthedocs/search/tests/data/mkdocs/out/gitbook.json b/readthedocs/search/tests/data/mkdocs/out/gitbook.json
new file mode 100644
index 00000000000..c22e6b29f3c
--- /dev/null
+++ b/readthedocs/search/tests/data/mkdocs/out/gitbook.json
@@ -0,0 +1,34 @@
+[
+ {
+ "path": "index.html",
+ "title": "Mkdocs - GitBook Theme",
+ "sections": [
+ {
+ "id": "mkdocs-gitbook-theme",
+ "title": "Mkdocs - GitBook Theme",
+ "content": ""
+ },
+ {
+ "id": "installation",
+ "title": "Installation",
+ "content": "First, install the package via PyPI: pip install mkdocs-gitbook Then include the theme in your mkdocs.yml file: theme: name: gitbook"
+ },
+ {
+ "id": "motivation",
+ "title": "Motivation",
+ "content": "Gitbook was a static-site generator written in JavaScript. Mkdocs is a static-site generator written in Python. Gitbook is no longer a static-site generator, nor does it use git, nor is it free or open source!"
+ },
+ {
+ "id": "screenshot",
+ "title": "Screenshot",
+ "content": ""
+ },
+ {
+ "id": "license",
+ "title": "License",
+ "content": "SPDX-License-Identifier: Apache-2.0"
+ }
+ ],
+ "domain_data": {}
+ }
+]
diff --git a/readthedocs/search/tests/data/mkdocs/out/material.json b/readthedocs/search/tests/data/mkdocs/out/material.json
new file mode 100644
index 00000000000..5e71b97f64c
--- /dev/null
+++ b/readthedocs/search/tests/data/mkdocs/out/material.json
@@ -0,0 +1,34 @@
+[
+ {
+ "path": "index.html",
+ "title": "Overview",
+ "sections": [
+ {
+ "id": "",
+ "title": "Overview",
+ "content": "Network-wide ad blocking via your own Linux hardware The Pi-hole® is a DNS sinkhole that protects your devices from unwanted content, without installing any client-side software. Easy-to-install: our versatile installer walks you through the process, and takes less than ten minutes Robust: a command-line interface that is quality assured for interoperability Insightful: a beautiful responsive Web Interface dashboard to view and control your Pi-hole Free: open-source software which helps ensure you are the sole person in control of your privacy"
+ },
+ {
+ "id": "pi-hole-is-free-but-powered-by-your-support",
+ "title": "Pi-hole is free, but powered by your support",
+ "content": "There are many reoccurring costs involved with maintaining free, open-source, and privacy respecting software; expenses which our volunteer developers pitch in to cover out-of-pocket. This is just one example of how strongly we feel about our software, as well as the importance of keeping it maintained. Make no mistake: your support is absolutely vital to help keep us innovating!"
+ },
+ {
+ "id": "donations",
+ "title": "Donations",
+ "content": "Sending a donation using our links below is extremely helpful in offsetting a portion of our monthly expenses: Donate via PayPal or Stripe Bitcoin, Bitcoin Cash, Ethereum, Litecoin"
+ },
+ {
+ "id": "alternative-support",
+ "title": "Alternative support",
+ "content": "If you'd rather not donate (which is okay!), there are other ways you can help support us:"
+ },
+ {
+ "id": "contributing-via-github",
+ "title": "Contributing via GitHub",
+ "content": "We welcome everyone to contribute to issue reports, suggest new features, and create pull requests. If you have something to add - anything from a typo through to a whole new feature, we're happy to check it out! Just make sure to fill out our template when submitting your request; the questions that it asks will help the volunteers quickly understand what you're aiming to achieve. Last update: June 2, 2020"
+ }
+ ],
+ "domain_data": {}
+ }
+]
diff --git a/readthedocs/search/tests/data/mkdocs/out/mkdocs-1.1.json b/readthedocs/search/tests/data/mkdocs/out/mkdocs-1.1.json
new file mode 100644
index 00000000000..f30020312b0
--- /dev/null
+++ b/readthedocs/search/tests/data/mkdocs/out/mkdocs-1.1.json
@@ -0,0 +1,122 @@
+[
+ {
+ "path": "index.html",
+ "title": "MkDocs",
+ "sections": [
+ {
+ "id": "mkdocs",
+ "title": "MkDocs",
+ "content": "Project documentation with\u00a0Markdown."
+ },
+ {
+ "id": "overview",
+ "title": "Overview",
+ "content": "MkDocs is a fast, simple and downright gorgeous static site generator that's geared towards building project documentation."
+ },
+ {
+ "id": "installation",
+ "title": "Installation",
+ "content": ""
+ },
+ {
+ "id": "host-anywhere",
+ "title": "Host anywhere",
+ "content": "MkDocs builds completely static HTML sites that you can host on GitHub pages, Amazon S3, or anywhere else you choose."
+ },
+ {
+ "id": "great-themes-available",
+ "title": "Great themes available",
+ "content": "There's a stack of good looking themes available for MkDocs."
+ },
+ {
+ "id": "install-with-a-package-manager",
+ "title": "Install with a Package Manager",
+ "content": "If your package manager does not have a recent \"MkDocs\" package, you can still use your package manager to install \"Python\" and \"pip\". $ python --version Python 3.8.2 $ pip --version pip 20.0.2 from /usr/local/lib/python3.8/site-packages/pip (python 3.8) Note If you would like manpages installed for MkDocs, the click-man tool can generate and install them for you. Simply run the following two commands: pip install click-man click-man --target path/to/man/pages mkdocs"
+ }
+ ],
+ "domain_data": {}
+ },
+ {
+ "path": "404.html",
+ "title": "404",
+ "sections": [
+ {
+ "id": "404-page-not-found",
+ "title": "404",
+ "content": "Page not found"
+ }
+ ],
+ "domain_data": {}
+ },
+ {
+ "path": "configuration.html",
+ "title": "Configuration",
+ "sections": [
+ {
+ "id": "configuration",
+ "title": "Configuration",
+ "content": "Guide to all available configuration settings."
+ },
+ {
+ "id": "introduction",
+ "title": "Introduction",
+ "content": "Project settings are always configured by using a YAML configuration file in the project directory named mkdocs.yml. As a minimum this configuration file must contain the site_name setting. All other settings are optional."
+ },
+ {
+ "id": "preview-controls",
+ "title": "Preview controls",
+ "content": ""
+ },
+ {
+ "id": "site_description",
+ "title": "site_description",
+ "content": "Set the site description. This will add a meta tag to the generated HTML header. default: null"
+ },
+ {
+ "id": "site_author",
+ "title": "site_author",
+ "content": "Set the name of the author. This will add a meta tag to the generated HTML header."
+ },
+ {
+ "id": "use_directory_urls",
+ "title": "use_directory_urls",
+ "content": "This setting controls the style used for linking to pages within the documentation. Source file use_directory_urls: true use_directory_urls: false index.md / /index.html api-guide.md /api-guide/ /api-guide.html about/license.md /about/license/ /about/license.html"
+ },
+ {
+ "id": "lang",
+ "title": "lang",
+ "content": "A list of languages to use when building the search index as identified by their ISO 639-1 language codes. ar: Arabic da: Danish nl: Dutch en: English fi: Finnish fr: French de: German hu: Hungarian it: Italian ja: Japanese no: Norwegian pt: Portuguese ro: Romanian ru: Russian es: Spanish sv: Swedish th: Thai tr: Turkish vi: Vietnamese"
+ }
+ ],
+ "domain_data": {}
+ },
+ {
+ "path": "no-title.html",
+ "title": "No title - Read the Docs MkDocs Test",
+ "sections": [
+ {
+ "id": "",
+ "title": "No title - Read the Docs MkDocs Test",
+ "content": "This file doesn't have a header, but it does have a content. 1 2 3 Another paragraph"
+ }
+ ],
+ "domain_data": {}
+ },
+ {
+ "path": "no-main-header.html",
+ "title": "I'm the header",
+ "sections": [
+ {
+ "id": "",
+ "title": "I'm the header",
+ "content": "I don't start with a header."
+ },
+ {
+ "id": "im-the-header",
+ "title": "I'm the header",
+ "content": "I'm more content."
+ }
+ ],
+ "domain_data": {}
+ }
+]
diff --git a/readthedocs/search/tests/data/mkdocs/out/readthedocs-1.1.json b/readthedocs/search/tests/data/mkdocs/out/readthedocs-1.1.json
new file mode 100644
index 00000000000..51487a4475a
--- /dev/null
+++ b/readthedocs/search/tests/data/mkdocs/out/readthedocs-1.1.json
@@ -0,0 +1,53 @@
+[
+ {
+ "path": "index.html",
+ "title": "Read the Docs MkDocs Test Project",
+ "sections": [
+ {
+ "id": "read-the-docs-mkdocs-test-project",
+ "title": "Read the Docs MkDocs Test Project",
+ "content": "This is a test of MkDocs as it appears on Read the Docs. Different versions of this documentation are build with different versions and themes of mkdocs. Use the version selector menu in the lower right to change the version and theme of this documentation"
+ },
+ {
+ "id": "another-title",
+ "title": "Another title",
+ "content": "I'm another title"
+ },
+ {
+ "id": "sub-header",
+ "title": "Sub header",
+ "content": "Some content: a b c"
+ },
+ {
+ "id": "im-a-subtitle",
+ "title": "I'm a subtitle",
+ "content": "Another content, mkdocs is great!"
+ }
+ ],
+ "domain_data": {}
+ },
+ {
+ "path": "404.html",
+ "title": "404",
+ "sections": [
+ {
+ "id": "404-page-not-found",
+ "title": "404",
+ "content": "Page not found"
+ }
+ ],
+ "domain_data": {}
+ },
+ {
+ "path": "versions.html",
+ "title": "Versions & Themes",
+ "sections": [
+ {
+ "id": "versions-themes",
+ "title": "Versions & Themes",
+ "content": "There are a number of versions and themes for mkdocs each of which have slight nuances with how they affect Read the Docs. You can use the version menu in the lower right to switch between versions and theme for this documentation."
+ }
+ ],
+ "domain_data": {}
+ }
+]
diff --git a/readthedocs/search/tests/data/mkdocs/out/windmill.json b/readthedocs/search/tests/data/mkdocs/out/windmill.json
new file mode 100644
index 00000000000..8f0f6726064
--- /dev/null
+++ b/readthedocs/search/tests/data/mkdocs/out/windmill.json
@@ -0,0 +1,29 @@
+[
+ {
+ "path": "index.html",
+ "title": "Windmill theme",
+ "sections": [
+ {
+ "id": "windmill-theme",
+ "title": "Windmill theme",
+ "content": ""
+ },
+ {
+ "id": "about",
+ "title": "About",
+ "content": "Windmill theme focuses on clean usable navigation for large documentation projects. It retains the state of the menu of pages and folders across page transitions, by keeping navigation to an iframe. Within pages, it uses the default mkdocs theme, including syntax highlighting."
+ },
+ {
+ "id": "installation",
+ "title": "Installation",
+ "content": "Install the Windmill theme using pip: pip install mkdocs-windmill"
+ },
+ {
+ "id": "usage",
+ "title": "Usage",
+ "content": "To use the Windmill theme installed via pip, add this to your mkdocs.yml: theme: 'windmill' If you cloned Windmill from GitHub: theme: name: null custom_dir: '{INSTALL_DIR}/mkdocs_windmill' # Copy settings from mkdocs_theme.yml, which is ignored by custom_dir themes. static_templates: [404.html] search_index_only: true include_search_page: true Note that it's important for there to exist a homepage, e.g. a top-level root element in mkdocs 1.0+: nav: - Home: index.md"
+ }
+ ],
+ "domain_data": {}
+ }
+]
diff --git a/readthedocs/search/tests/test_parsers.py b/readthedocs/search/tests/test_parsers.py
index e5ab1927da3..8f47703a962 100644
--- a/readthedocs/search/tests/test_parsers.py
+++ b/readthedocs/search/tests/test_parsers.py
@@ -8,16 +8,20 @@
from readthedocs.builds.storage import BuildMediaFileSystemStorage
from readthedocs.projects.constants import MKDOCS, SPHINX
-from readthedocs.projects.models import HTMLFile, Project
+from readthedocs.projects.models import HTMLFile, Project, Feature
data_path = Path(__file__).parent.resolve() / 'data'
@pytest.mark.django_db
@pytest.mark.search
-class TestParseJSON:
+class TestParsers:
def setup_method(self):
+ self.feature = get(
+ Feature,
+ feature_id=Feature.INDEX_FROM_HTML_FILES,
+ )
self.project = get(
Project,
slug='test',
@@ -72,6 +76,129 @@ def test_mkdocs(self, storage_open, storage_exists):
expected_json = json.load(open(data_path / 'mkdocs/out/search_index.json'))
assert parsed_json == expected_json
+ @mock.patch.object(BuildMediaFileSystemStorage, 'exists')
+ @mock.patch.object(BuildMediaFileSystemStorage, 'open')
+ def test_mkdocs_default_theme(self, storage_open, storage_exists):
+ local_path = data_path / 'mkdocs/in/mkdocs-1.1/'
+ storage_exists.return_value = True
+
+ self.project.feature_set.add(self.feature)
+ self.version.documentation_type = MKDOCS
+ self.version.save()
+
+ parsed_json = []
+
+ all_files = [
+ 'index.html',
+ '404.html',
+ 'configuration.html',
+ 'no-title.html',
+ 'no-main-header.html',
+ ]
+ for file_name in all_files:
+ file = local_path / file_name
+ storage_open.reset_mock()
+ storage_open.side_effect = self._mock_open(file.open().read())
+ file = get(
+ HTMLFile,
+ project=self.project,
+ version=self.version,
+ path=file_name,
+ )
+ parsed_json.append(file.processed_json)
+
+ expected_json = json.load(open(data_path / 'mkdocs/out/mkdocs-1.1.json'))
+ assert parsed_json == expected_json
+
+ @mock.patch.object(BuildMediaFileSystemStorage, 'exists')
+ @mock.patch.object(BuildMediaFileSystemStorage, 'open')
+ def test_mkdocs_gitbook_theme(self, storage_open, storage_exists):
+ file = data_path / 'mkdocs/in/gitbook/index.html'
+ storage_exists.return_value = True
+
+ self.project.feature_set.add(self.feature)
+ self.version.documentation_type = MKDOCS
+ self.version.save()
+
+ storage_open.side_effect = self._mock_open(file.open().read())
+ file = get(
+ HTMLFile,
+ project=self.project,
+ version=self.version,
+ path='index.html',
+ )
+ parsed_json = [file.processed_json]
+ expected_json = json.load(open(data_path / 'mkdocs/out/gitbook.json'))
+ assert parsed_json == expected_json
+
+ @mock.patch.object(BuildMediaFileSystemStorage, 'exists')
+ @mock.patch.object(BuildMediaFileSystemStorage, 'open')
+ def test_mkdocs_material_theme(self, storage_open, storage_exists):
+ file = data_path / 'mkdocs/in/material/index.html'
+ storage_exists.return_value = True
+
+ self.project.feature_set.add(self.feature)
+ self.version.documentation_type = MKDOCS
+ self.version.save()
+
+ storage_open.side_effect = self._mock_open(file.open().read())
+ file = get(
+ HTMLFile,
+ project=self.project,
+ version=self.version,
+ path='index.html',
+ )
+ parsed_json = [file.processed_json]
+ expected_json = json.load(open(data_path / 'mkdocs/out/material.json'))
+ assert parsed_json == expected_json
+
+ @mock.patch.object(BuildMediaFileSystemStorage, 'exists')
+ @mock.patch.object(BuildMediaFileSystemStorage, 'open')
+ def test_mkdocs_windmill_theme(self, storage_open, storage_exists):
+ file = data_path / 'mkdocs/in/windmill/index.html'
+ storage_exists.return_value = True
+
+ self.project.feature_set.add(self.feature)
+ self.version.documentation_type = MKDOCS
+ self.version.save()
+
+ storage_open.side_effect = self._mock_open(file.open().read())
+ file = get(
+ HTMLFile,
+ project=self.project,
+ version=self.version,
+ path='index.html',
+ )
+ parsed_json = [file.processed_json]
+ expected_json = json.load(open(data_path / 'mkdocs/out/windmill.json'))
+ assert parsed_json == expected_json
+
+ @mock.patch.object(BuildMediaFileSystemStorage, 'exists')
+ @mock.patch.object(BuildMediaFileSystemStorage, 'open')
+ def test_mkdocs_readthedocs_theme(self, storage_open, storage_exists):
+ self.project.feature_set.add(self.feature)
+ storage_exists.return_value = True
+ self.version.documentation_type = MKDOCS
+ self.version.save()
+
+ local_path = data_path / 'mkdocs/in/readthedocs-1.1/'
+ parsed_json = []
+
+ for file_name in ['index.html', '404.html', 'versions.html']:
+ file = local_path / file_name
+ storage_open.reset_mock()
+ storage_open.side_effect = self._mock_open(file.open().read())
+ file = get(
+ HTMLFile,
+ project=self.project,
+ version=self.version,
+ path=file_name,
+ )
+ parsed_json.append(file.processed_json)
+
+ expected_json = json.load(open(data_path / 'mkdocs/out/readthedocs-1.1.json'))
+ assert parsed_json == expected_json
+
@mock.patch.object(BuildMediaFileSystemStorage, 'exists')
@mock.patch.object(BuildMediaFileSystemStorage, 'open')
def test_mkdocs_old_version(self, storage_open, storage_exists):