Skip to content

Commit f85f983

Browse files
committed
2 parents 57f4a11 + 658bb07 commit f85f983

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2608
-2399
lines changed

.readthedocs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ formats: all
33
sphinx:
44
configuration: docs/conf.py
55
python:
6-
requirements: requirements/local-docs-build.txt
6+
install:
7+
- requirements: requirements/local-docs-build.txt

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ python:
44
matrix:
55
include:
66
- python: 3.6
7-
env: TOXENV=py36 ES_VERSION=1.3.9 ES_DOWNLOAD_URL=https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
7+
env: TOXENV=py36 ES_VERSION=6.2.4 ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
88
- python: 3.6
99
env: TOXENV=docs
1010
- python: 3.6

CHANGELOG.rst

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,71 @@
1+
Version 3.1.0
2+
-------------
3+
4+
This version greatly improves our search capabilities,
5+
thanks to the Google Summer of Code.
6+
We're hoping to have another version of search coming soon after this,
7+
but this is a large upgrade moving to the latest Elastic Search.
8+
9+
:Date: January 24, 2019
10+
11+
* `@ericholscher <http://github.com/ericholscher>`__: Fix docs build (`#5164 <https://github.com/rtfd/readthedocs.org/pull/5164>`__)
12+
* `@ericholscher <http://github.com/ericholscher>`__: Release 3.0.0 (`#5163 <https://github.com/rtfd/readthedocs.org/pull/5163>`__)
13+
* `@stsewd <http://github.com/stsewd>`__: Fix tests on master (`#5162 <https://github.com/rtfd/readthedocs.org/pull/5162>`__)
14+
* `@dojutsu-user <http://github.com/dojutsu-user>`__: Sort versions smartly everywhere (`#5157 <https://github.com/rtfd/readthedocs.org/pull/5157>`__)
15+
* `@stsewd <http://github.com/stsewd>`__: Allow query params in redirects (`#5081 <https://github.com/rtfd/readthedocs.org/pull/5081>`__)
16+
* `@dojutsu-user <http://github.com/dojutsu-user>`__: Implement get objects or log (`#4900 <https://github.com/rtfd/readthedocs.org/pull/4900>`__)
17+
* `@stsewd <http://github.com/stsewd>`__: Remove usage of project.documentation_type in tasks (`#4896 <https://github.com/rtfd/readthedocs.org/pull/4896>`__)
18+
* `@ericholscher <http://github.com/ericholscher>`__: Reapply the Elastic Search upgrade to `master` (`#4722 <https://github.com/rtfd/readthedocs.org/pull/4722>`__)
19+
20+
Version 3.0.0
21+
-------------
22+
23+
**Read the Docs now only supports Python 3.6+**.
24+
This is for people running the software on their own servers,
25+
builds continue to work across all supported Python versions.
26+
27+
:Date: January 23, 2019
28+
29+
* `@stsewd <http://github.com/stsewd>`__: Fix tests on master (`#5162 <https://github.com/rtfd/readthedocs.org/pull/5162>`__)
30+
* `@dojutsu-user <http://github.com/dojutsu-user>`__: Sort versions smartly everywhere (`#5157 <https://github.com/rtfd/readthedocs.org/pull/5157>`__)
31+
* `@rvmzes <http://github.com/rvmzes>`__: SyntaxError caused by comma in python3 (`#5156 <https://github.com/rtfd/readthedocs.org/pull/5156>`__)
32+
* `@ericholscher <http://github.com/ericholscher>`__: Fix Sphinx conf.py inserts (`#5150 <https://github.com/rtfd/readthedocs.org/pull/5150>`__)
33+
* `@ericholscher <http://github.com/ericholscher>`__: Upgrade recommonmark to latest and fix integration (`#5146 <https://github.com/rtfd/readthedocs.org/pull/5146>`__)
34+
* `@stsewd <http://github.com/stsewd>`__: Fix requirements for local installation (`#5138 <https://github.com/rtfd/readthedocs.org/pull/5138>`__)
35+
* `@ericholscher <http://github.com/ericholscher>`__: Fix local-docs-build requirements (`#5136 <https://github.com/rtfd/readthedocs.org/pull/5136>`__)
36+
* `@humitos <http://github.com/humitos>`__: Upgrade all dependencies (`#5134 <https://github.com/rtfd/readthedocs.org/pull/5134>`__)
37+
* `@humitos <http://github.com/humitos>`__: Configuration file for ProBot Mergeable Bot (`#5132 <https://github.com/rtfd/readthedocs.org/pull/5132>`__)
38+
* `@xavfernandez <http://github.com/xavfernandez>`__: docs: fix integration typos (`#5128 <https://github.com/rtfd/readthedocs.org/pull/5128>`__)
39+
* `@Hamdy722 <http://github.com/Hamdy722>`__: Update LICENSE (`#5125 <https://github.com/rtfd/readthedocs.org/pull/5125>`__)
40+
* `@stsewd <http://github.com/stsewd>`__: Remove doctype from search (`#5121 <https://github.com/rtfd/readthedocs.org/pull/5121>`__)
41+
* `@humitos <http://github.com/humitos>`__: Validate mkdocs.yml config on values that we manipulate (`#5119 <https://github.com/rtfd/readthedocs.org/pull/5119>`__)
42+
* `@humitos <http://github.com/humitos>`__: Use 2019 in our README (`#5117 <https://github.com/rtfd/readthedocs.org/pull/5117>`__)
43+
* `@stsewd <http://github.com/stsewd>`__: Remove dead code from config module (`#5116 <https://github.com/rtfd/readthedocs.org/pull/5116>`__)
44+
* `@ericholscher <http://github.com/ericholscher>`__: Check that the repo exists before trying to get a git commit (`#5115 <https://github.com/rtfd/readthedocs.org/pull/5115>`__)
45+
* `@ericholscher <http://github.com/ericholscher>`__: Release 2.8.5 (`#5111 <https://github.com/rtfd/readthedocs.org/pull/5111>`__)
46+
* `@stsewd <http://github.com/stsewd>`__: Use the python path from virtualenv in Conda (`#5110 <https://github.com/rtfd/readthedocs.org/pull/5110>`__)
47+
* `@humitos <http://github.com/humitos>`__: Feature flag to use `readthedocs/build:testing` image (`#5109 <https://github.com/rtfd/readthedocs.org/pull/5109>`__)
48+
* `@stsewd <http://github.com/stsewd>`__: Use python from virtualenv's bin directory when executing commands (`#5107 <https://github.com/rtfd/readthedocs.org/pull/5107>`__)
49+
* `@dojutsu-user <http://github.com/dojutsu-user>`__: Split requirements/pip.txt (`#5100 <https://github.com/rtfd/readthedocs.org/pull/5100>`__)
50+
* `@humitos <http://github.com/humitos>`__: Do not list banned projects under /projects/ (`#5097 <https://github.com/rtfd/readthedocs.org/pull/5097>`__)
51+
* `@humitos <http://github.com/humitos>`__: Do not build projects from banned users (`#5096 <https://github.com/rtfd/readthedocs.org/pull/5096>`__)
52+
* `@humitos <http://github.com/humitos>`__: Support custom robots.txt (`#5086 <https://github.com/rtfd/readthedocs.org/pull/5086>`__)
53+
* `@stsewd <http://github.com/stsewd>`__: Allow query params in redirects (`#5081 <https://github.com/rtfd/readthedocs.org/pull/5081>`__)
54+
* `@davidfischer <http://github.com/davidfischer>`__: Fire a signal for domain verification (eg. for SSL) (`#5071 <https://github.com/rtfd/readthedocs.org/pull/5071>`__)
55+
* `@humitos <http://github.com/humitos>`__: Upgrade all code to be Python3 only (`#5065 <https://github.com/rtfd/readthedocs.org/pull/5065>`__)
56+
* `@dojutsu-user <http://github.com/dojutsu-user>`__: Use default settings for Config object (`#5056 <https://github.com/rtfd/readthedocs.org/pull/5056>`__)
57+
* `@agjohnson <http://github.com/agjohnson>`__: Allow large form posts via multipart encoded forms to command API (`#5000 <https://github.com/rtfd/readthedocs.org/pull/5000>`__)
58+
* `@dojutsu-user <http://github.com/dojutsu-user>`__: Validate url from webhook notification (`#4983 <https://github.com/rtfd/readthedocs.org/pull/4983>`__)
59+
* `@dojutsu-user <http://github.com/dojutsu-user>`__: Display error, using inbuilt notification system, if primary email is not verified (`#4964 <https://github.com/rtfd/readthedocs.org/pull/4964>`__)
60+
* `@dojutsu-user <http://github.com/dojutsu-user>`__: Implement get objects or log (`#4900 <https://github.com/rtfd/readthedocs.org/pull/4900>`__)
61+
* `@humitos <http://github.com/humitos>`__: CRUD for EnvironmentVariables from Project's admin (`#4899 <https://github.com/rtfd/readthedocs.org/pull/4899>`__)
62+
* `@stsewd <http://github.com/stsewd>`__: Remove usage of project.documentation_type in tasks (`#4896 <https://github.com/rtfd/readthedocs.org/pull/4896>`__)
63+
* `@dojutsu-user <http://github.com/dojutsu-user>`__: Fix the failing domain deletion task (`#4891 <https://github.com/rtfd/readthedocs.org/pull/4891>`__)
64+
* `@stsewd <http://github.com/stsewd>`__: Remove unused validations from v1 config (`#4883 <https://github.com/rtfd/readthedocs.org/pull/4883>`__)
65+
* `@humitos <http://github.com/humitos>`__: Appropiate logging when a LockTimeout for VCS is reached (`#4804 <https://github.com/rtfd/readthedocs.org/pull/4804>`__)
66+
* `@stsewd <http://github.com/stsewd>`__: Implement extended install option (`#4740 <https://github.com/rtfd/readthedocs.org/pull/4740>`__)
67+
* `@bansalnitish <http://github.com/bansalnitish>`__: Added a link to open new issue with prefilled details (`#3683 <https://github.com/rtfd/readthedocs.org/pull/3683>`__)
68+
169
Version 2.8.5
270
-------------
371

conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# -*- coding: utf-8 -*-
22
import pytest
3+
from django.conf import settings
4+
from rest_framework.test import APIClient
35

46
try:
57
# TODO: this file is read/executed even when called from ``readthedocsinc``,
@@ -44,3 +46,7 @@ def pytest_configure(config):
4446
@pytest.fixture(autouse=True)
4547
def settings_modification(settings):
4648
settings.CELERY_ALWAYS_EAGER = True
49+
50+
@pytest.fixture
51+
def api_client():
52+
return APIClient()

docs/custom_installs/elasticsearch.rst

Lines changed: 0 additions & 130 deletions
This file was deleted.

docs/development/search.rst

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
Search
2+
======
3+
4+
Read The Docs uses Elasticsearch_ instead of the built in Sphinx search for providing better search
5+
results. Documents are indexed in the Elasticsearch index and the search is made through the API.
6+
All the Search Code is open source and lives in the `GitHub Repository`_.
7+
Currently we are using the `Elasticsearch 6.3`_ version.
8+
9+
Local Development Configuration
10+
-------------------------------
11+
12+
Installing and running Elasticsearch
13+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
You need to install and run Elasticsearch_ version 6.3 on your local development machine.
15+
You can get the installation instructions
16+
`here <https://www.elastic.co/guide/en/elasticsearch/reference/6.3/install-elasticsearch.html>`_.
17+
Otherwise, you can also start an Elasticsearch Docker container by running the following command::
18+
19+
docker run -p 9200:9200 -p 9300:9300 \
20+
-e "discovery.type=single-node" \
21+
docker.elastic.co/elasticsearch/elasticsearch:6.3.2
22+
23+
Indexing into Elasticsearch
24+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
25+
For using search, you need to index data to the Elasticsearch Index. Run ``reindex_elasticsearch``
26+
management command::
27+
28+
./manage.py reindex_elasticsearch
29+
30+
For performance optimization, we implemented our own version of management command rather than
31+
the built in management command provided by the `django-elasticsearch-dsl`_ package.
32+
33+
Auto Indexing
34+
^^^^^^^^^^^^^
35+
By default, Auto Indexing is turned off in development mode. To turn it on, change the
36+
``ELASTICSEARCH_DSL_AUTOSYNC`` settings to `True` in the `readthedocs/settings/dev.py` file.
37+
After that, whenever a documentation successfully builds, or project gets added,
38+
the search index will update automatically.
39+
40+
41+
Architecture
42+
------------
43+
The search architecture is devided into 2 parts.
44+
One part is responsible for **indexing** the documents and projects and
45+
the other part is responsible for querying the Index to show the proper results to users.
46+
We use the `django-elasticsearch-dsl`_ package mostly to the keep the search working.
47+
`django-elasticsearch-dsl`_ is a wrapper around `elasticsearch-dsl`_ for easy configuration
48+
with Django.
49+
50+
Indexing
51+
^^^^^^^^
52+
All the Sphinx documents are indexed into Elasticsearch after the build is successful.
53+
Currently, we do not index MkDocs documents to elasticsearch, but
54+
`any kind of help is welcome <https://github.com/rtfd/readthedocs.org/issues/1088>`_.
55+
56+
How we index documentations
57+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
58+
59+
After any build is successfully finished, `HTMLFile` objects are created for each of the
60+
``HTML`` files and the old version's `HTMLFile` object is deleted. By default,
61+
`django-elasticsearch-dsl`_ package listens to the `post_create`/`post_delete` signals
62+
to index/delete documents, but it has performance drawbacks as it send HTTP request whenever
63+
any `HTMLFile` objects is created or deleted. To optimize the performance, `bulk_post_create`
64+
and `bulk_post_delete` Signals_ are dispatched with list of `HTMLFIle` objects so its possible
65+
to bulk index documents in elasticsearch ( `bulk_post_create` signal is dispatched for created
66+
and `bulk_post_delete` is dispatched for deleted objects). Both of the signals are dispatched
67+
with the list of the instances of `HTMLFile` in `instance_list` parameter.
68+
69+
We listen to the `bulk_post_create` and `bulk_post_delete` signals in our `Search` application
70+
and index/delete the documentation content from the `HTMLFile` instances.
71+
72+
73+
How we index projects
74+
~~~~~~~~~~~~~~~~~~~~~
75+
We also index project information in our search index so that the user can search for projects
76+
from the main site. `django-elasticsearch-dsl`_ listen `post_create` and `post_delete` signals of
77+
`Project` model and index/delete into Elasticsearch accordingly.
78+
79+
80+
Elasticsearch Document
81+
~~~~~~~~~~~~~~~~~~~~~~
82+
83+
`elasticsearch-dsl`_ provides model-like wrapper for the `Elasticsearch document`_.
84+
As per requirements of `django-elasticsearch-dsl`_, it is stored in the
85+
`readthedocs/search/documents.py` file.
86+
87+
**ProjectDocument:** It is used for indexing projects. Signal listener of
88+
`django-elasticsearch-dsl`_ listens to the `post_save` signal of `Project` model and
89+
then index/delete into Elasticsearch.
90+
91+
**PageDocument**: It is used for indexing documentation of projects. By default, the auto
92+
indexing is turned off by `ignore_signals = settings.ES_PAGE_IGNORE_SIGNALS`.
93+
`settings.ES_PAGE_IGNORE_SIGNALS` is `False` both in development and production.
94+
As mentioned above, our `Search` app listens to the `bulk_post_create` and `bulk_post_delete`
95+
signals and indexes/deleted documentation into Elasticsearch. The signal listeners are in
96+
the `readthedocs/search/signals.py` file. Both of the signals are dispatched
97+
after a successful documentation build.
98+
99+
The fields and ES Datatypes are specified in the `PageDocument`. The indexable data is taken
100+
from `processed_json` property of `HTMLFile`. This property provides python dictionary with
101+
document data like `title`, `headers`, `content` etc.
102+
103+
104+
.. _Elasticsearch: https://www.elastic.co/products/elasticsearch
105+
.. _Elasticsearch 6.3: https://www.elastic.co/guide/en/elasticsearch/reference/6.3/index.html
106+
.. _GitHub Repository: https://github.com/rtfd/readthedocs.org/tree/master/readthedocs/search
107+
.. _Elasticsearch document: https://www.elastic.co/guide/en/elasticsearch/guide/current/document.html
108+
.. _django-elasticsearch-dsl: https://github.com/sabricot/django-elasticsearch-dsl
109+
.. _elasticsearch-dsl: http://elasticsearch-dsl.readthedocs.io/en/latest/
110+
.. _Signals: https://docs.djangoproject.com/en/2.1/topics/signals/

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ to help you create fantastic documentation for your project.
114114

115115
changelog
116116
install
117+
development/search
117118
architecture
118119
tests
119120
docs

docs/install.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Additionally Read the Docs depends on:
1919
* `Redis`_
2020
* `Elasticsearch`_ (only if you want full support for searching inside the site)
2121

22-
* Ubuntu users could install this package by following :doc:`/custom_installs/elasticsearch`.
22+
* Follow :doc:`/development/search` documentation for more instruction.
2323

2424
.. note::
2525

@@ -56,8 +56,6 @@ you need these libraries.
5656

5757
.. tab:: CentOS/RHEL 7
5858

59-
Install::
60-
6159
sudo yum install python-devel python-pip libxml2-devel libxslt-devel
6260

6361
.. tab:: Other OS

0 commit comments

Comments
 (0)