Skip to content

Commit 6701a4e

Browse files
committed
add test for domains and filter by version and project
1 parent b7ce777 commit 6701a4e

File tree

11 files changed

+276
-43
lines changed

11 files changed

+276
-43
lines changed

readthedocs/doc_builder/python_environments.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ def install_core_requirements(self):
325325
negative='sphinx<2',
326326
),
327327
'sphinx-rtd-theme<0.5',
328-
'readthedocs-sphinx-ext<0.7',
328+
# 'readthedocs-sphinx-ext<0.7',
329+
'git+https://github.com/readthedocs/readthedocs-sphinx-ext@master',
329330
])
330331

331332
cmd = copy.copy(pip_install_cmd)

readthedocs/search/faceted_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class PageSearchBase(RTDFacetedSearch):
105105
_section_fields = ['sections.title^3', 'sections.content']
106106
_domain_fields = [
107107
'domains.type_display',
108-
'domains.name',
108+
'domains.name^2',
109109
'domains.display_name',
110110
]
111111
fields = _outer_fields

readthedocs/search/tests/conftest.py

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
from readthedocs.projects.models import Project, HTMLFile
1010
from readthedocs.search.documents import PageDocument
11+
from readthedocs.sphinx_domains.models import SphinxDomain
12+
1113
from .dummy_data import ALL_PROJECTS, PROJECT_DATA_FILES
1214

1315

@@ -32,6 +34,28 @@ def all_projects(es_index, mock_processed_json, db, settings):
3234
file_name = file_basename + '.html'
3335
version = project.versions.all()[0]
3436
html_file = G(HTMLFile, project=project, version=version, name=file_name)
37+
38+
# creating sphinx domain test objects
39+
file_path = get_json_file_path(project.slug, file_basename)
40+
if os.path.exists(file_path):
41+
with open (file_path) as f:
42+
data = json.load(f)
43+
domains = data['domains']
44+
45+
for domain_data in domains:
46+
domain_role_name = domain_data.pop('role_name')
47+
domain, type_ = domain_role_name.split(':')
48+
49+
G(
50+
SphinxDomain,
51+
project=project,
52+
version=version,
53+
html_file=html_file,
54+
domain=domain,
55+
type=type_,
56+
**domain_data
57+
)
58+
3559
PageDocument().update(html_file)
3660

3761
projects_list.append(project)
@@ -46,12 +70,17 @@ def project(all_projects):
4670
return all_projects[0]
4771

4872

73+
def get_json_file_path(project_slug, basename):
74+
current_path = os.path.abspath(os.path.dirname(__file__))
75+
file_name = f'{basename}.json'
76+
file_path = os.path.join(current_path, 'data', project_slug, file_name)
77+
return file_path
78+
79+
4980
def get_dummy_processed_json(instance):
5081
project_slug = instance.project.slug
5182
basename = os.path.splitext(instance.name)[0]
52-
file_name = basename + '.json'
53-
current_path = os.path.abspath(os.path.dirname(__file__))
54-
file_path = os.path.join(current_path, "data", project_slug, file_name)
83+
file_path = get_json_file_path(project_slug, basename)
5584

5685
if os.path.exists(file_path):
5786
with open(file_path) as f:

readthedocs/search/tests/data/docs/support.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,25 @@
1717
"title": "Commercial Support",
1818
"content": "We offer commercial support for Read the Docs, commercial hosting, as well as consulting around all documentation systems. You can contact us at [email protected] to learn more, or read more at https://readthedocs.com/services/#open-source-support."
1919
}
20+
],
21+
"domains": [
22+
{
23+
"role_name": "http:post",
24+
"doc_name": "api/v3.html",
25+
"anchor": "post--api-v3-projects-(string-project_slug)-versions-(string-version_slug)-builds-",
26+
"type_display": "post",
27+
"doc_display": "API v3",
28+
"name": "/api/v3/projects/(string:project_slug)/versions/(string:version_slug)/builds/",
29+
"display_name": ""
30+
},
31+
{
32+
"role_name": "http:patch",
33+
"doc_name": "api/v3.html",
34+
"anchor": "patch--api-v3-projects-(string-project_slug)-version-(string-version_slug)-",
35+
"type_display": "patch",
36+
"doc_display": "API v3",
37+
"name": "/api/v3/projects/(string:project_slug)/version/(string:version_slug)/",
38+
"display_name": ""
39+
}
2040
]
2141
}

readthedocs/search/tests/data/docs/wiping.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,43 @@
77
"title": "Wiping a Build Environment",
88
"content": "Sometimes it happen that your Builds start failing because the build environment where the documentation is created is stale or broken. This could happen for a couple of different reasons like pip not upgrading a package properly or a corrupted cached Python package.In any of these cases (and many others), the solution could be just wiping out the existing build environment files and allow Read the Docs to create a new fresh one.Follow these steps to wipe the build environment:Click on the Edit button of the version you want to wipe on the right side of the page. Go to the bottom of the page and click the wipe link, next to the “Save” buttonBy wiping the documentation build environment, all the rst, md, and code files associated with it will be removed but not the documentation already built (HTML and PDF files). Your documentation will still online after wiping the build environment.Now you can re-build the version with a fresh build environment!"
99
}
10+
],
11+
"domains": [
12+
{
13+
"role_name": "http:get",
14+
"doc_name": "api/v3.html",
15+
"anchor": "get--api-v3-users-(str-username)",
16+
"type_display": "get",
17+
"doc_display": "API v3",
18+
"name": "/api/v3/users/(str:username)",
19+
"display_name": ""
20+
},
21+
{
22+
"role_name": "http:get",
23+
"doc_name": "api/v3.html",
24+
"anchor": "get--api-v3-projects-(string-project_slug)-versions-(string-version_slug)-",
25+
"type_display": "get",
26+
"doc_display": "API v3",
27+
"name": "/api/v3/projects/(string:project_slug)/versions/(string:version_slug)/",
28+
"display_name": ""
29+
},
30+
{
31+
"role_name": "http:get",
32+
"doc_name": "api/v3.html",
33+
"anchor": "get--api-v3-projects-(string-project_slug)-versions-",
34+
"type_display": "get",
35+
"doc_display": "API v3",
36+
"name": "/api/v3/projects/(string:project_slug)/versions/",
37+
"display_name": ""
38+
},
39+
{
40+
"role_name": "http:get",
41+
"doc_name": "api/v3.html",
42+
"anchor": "get--api-v3-projects-(string-project_slug)-",
43+
"type_display": "get",
44+
"doc_display": "API v3",
45+
"name": "/api/v3/projects/(string:project_slug)/",
46+
"display_name": ""
47+
}
1048
]
1149
}

readthedocs/search/tests/data/kuma/docker.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,25 @@
1212
"title": "Docker Images",
1313
"content": "Docker images are used in development, usually with the local working files mounted in the images to set behaviour.. Images are built by Jenkins, after tests pass, and are published to DockerHub. We try to store the configuration in the environment, so that the published images can be used in deployments by setting environment variables to deployment-specific values.. Here are some of the images used in the Kuma project:. kuma. The kuma Docker image builds on the kuma_base image, installing a kuma branch and building the assets needed for running as a webservice. The environment can be customized for different deployments.. The image can be recreated locally with make build-kuma.. The image tagged latest is used by default for development. It can be created locally with make build-kuma VERSION=latest. The official latest image is created from the master branch in Jenkins and published to DockerHub.. kuma_base. The kuma_base Docker image contains the OS and libraries (C, Python, and Node.js) that support the kuma project. The kuma image extends this by installing the kuma source and building assets needed for production.. The image can be recreated locally with make build-base.. The image tagged latest is used by default for development. It can be created localled with make build-base VERSION=latest. The official latest image is created from the master branch in Jenkins and published to DockerHub. kumascript. The kumascript Docker image contains the kumascript rendering engine and support files. The environment can be customized for different deployments.. The image can be recreated locally with make build-kumascript.. The image tagged latest is used by default for development. It can be created locally with make build-kumascript KS_VERSION=latest. The official latest image is created from the master branch in Jenkins and published to DockerHub.. integration-tests. The integration-tests Docker image contains browser-based integration tests that check the functionality of a running Kuma deployment.. The image can be recreated locally with docker build -f docker/images/integration-tests/ ., but this is only necessary for image development. Most developers will follow the Client-side testing documentation to develop and run these integration tests.. The image is built and used in Jenkins in the stage-integration-tests and prod-integration-tests pipelines, configured by scripts in the Jenkinsfiles folder. It is not published to DockerHub."
1414
}
15+
],
16+
"domains": [
17+
{
18+
"role_name": "py:module",
19+
"doc_name": "autoapi/notfound/utils/index.html",
20+
"anchor": "module-notfound.utils",
21+
"type_display": "module",
22+
"doc_display": "notfound.utils",
23+
"name": "notfound.utils",
24+
"display_name": ""
25+
},
26+
{
27+
"role_name": "py:function",
28+
"doc_name": "autoapi/notfound/utils/index.html",
29+
"anchor": "notfound.utils.replace_uris",
30+
"type_display": "function",
31+
"doc_display": "notfound.utils",
32+
"name": "notfound.utils.replace_uris",
33+
"display_name": ""
34+
}
1535
]
1636
}

readthedocs/search/tests/data/kuma/documentation.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,25 @@
1212
"title": "Generating documentation",
1313
"content": "Sphinx uses a Makefile in the docs subfolder to build documentation in several formats. MDN only uses the HTML format, and the generated document index is at docs/_build/html/index.html.. To generate the documentation in a virtualenv on the host machine, first install the requirements:. pip install -r requirements/docs.txt. Then switch to the docs folder to use the Makefile:. cd docs make html python -m webbrowser file://${PWD}/_build/html/index.html. To generate the documentation with Docker:. docker-compose run --rm --user $(id -u) web sh -c \"\\ virtualenv /tmp/.venvs/docs && \\ . /tmp/.venvs/docs/bin/activate && \\ pip install -r /app/requirements/docs.txt && \\ cd /app/docs && \\ make html\" python -m webbrowser file://${PWD}/docs/_build/html/index.html. A virtualenv is required, to avoid a pip bug when changing the version of a system-installed package."
1414
}
15+
],
16+
"domains": [
17+
{
18+
"role_name": "py:module",
19+
"doc_name": "autoapi/notfound/index.html",
20+
"anchor": "module-notfound",
21+
"type_display": "module",
22+
"doc_display": "notfound",
23+
"name": "notfound",
24+
"display_name": ""
25+
},
26+
{
27+
"role_name": "py:data",
28+
"doc_name": "autoapi/notfound/index.html",
29+
"anchor": "notfound.version",
30+
"type_display": "data",
31+
"doc_display": "notfound",
32+
"name": "notfound.version",
33+
"display_name": ""
34+
}
1535
]
1636
}

readthedocs/search/tests/data/pipeline/installation.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,16 @@
2222
"title": "Recommendations",
2323
"content": "Pipeline’s default CSS and JS compressor is Yuglify. Yuglify wraps UglifyJS and cssmin, applying the default YUI configurations to them. It can be downloaded from: https://github.com/yui/yuglify/.. If you do not install yuglify, make sure to disable the compressor in your settings."
2424
}
25+
],
26+
"domains": [
27+
{
28+
"role_name": "std:confval",
29+
"doc_name": "configuration.html",
30+
"anchor": "confval-notfound_default_language",
31+
"type_display": "confval",
32+
"doc_display": "Configuration",
33+
"name": "notfound_default_language",
34+
"display_name": ""
35+
}
2536
]
2637
}

readthedocs/search/tests/data/pipeline/signals.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,25 @@
1717
"title": "js_compressed",
1818
"content": "pipeline.signals.js_compressed. Whenever a js package is compressed, this signal is sent after the compression.. Arguments sent with this signal :. sender:. The Packager class that compressed the group.. package:. The package actually compressed."
1919
}
20+
],
21+
"domains": [
22+
{
23+
"role_name": "py:method",
24+
"doc_name": "autoapi/notfound/extension/index.html",
25+
"anchor": "notfound.extension.OrphanMetadataCollector.process_doc",
26+
"type_display": "method",
27+
"doc_display": "notfound.extension",
28+
"name": "notfound.extension.OrphanMetadataCollector.process_doc",
29+
"display_name": ""
30+
},
31+
{
32+
"role_name": "py:method",
33+
"doc_name": "autoapi/notfound/extension/index.html",
34+
"anchor": "notfound.extension.OrphanMetadataCollector.clear_doc",
35+
"type_display": "method",
36+
"doc_display": "notfound.extension",
37+
"name": "notfound.extension.OrphanMetadataCollector.clear_doc",
38+
"display_name": ""
39+
}
2040
]
2141
}

0 commit comments

Comments
 (0)