-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove usage of project.documentation_type in tasks #4896
Merged
ericholscher
merged 7 commits into
readthedocs:master
from
stsewd:remove-usage-of-project-doctype
Jan 23, 2019
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7c807bb
Remove usage of project.documentation_type in tasks
stsewd 4afd086
Fix search command
stsewd f88a09b
Fix search again
stsewd 3b00678
Tests
stsewd 44f9f9c
Refactor
stsewd 93d3e63
One more test
stsewd 20c671f
Merge branch 'master' into remove-usage-of-project-doctype
stsewd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -676,6 +676,7 @@ def update_app_instances(self, html=False, localmedia=False, search=False, | |
args=[ | ||
self.project.pk, | ||
self.version.pk, | ||
self.config.doctype, | ||
], | ||
kwargs=dict( | ||
hostname=socket.gethostname(), | ||
|
@@ -759,7 +760,9 @@ def build_docs_html(self): | |
broadcast( | ||
type='app', | ||
task=move_files, | ||
args=[self.version.pk, socket.gethostname()], | ||
args=[ | ||
self.version.pk, socket.gethostname(), self.config.doctype | ||
], | ||
kwargs=dict(html=True) | ||
) | ||
except socket.error: | ||
|
@@ -828,7 +831,7 @@ def is_type_sphinx(self): | |
|
||
# Web tasks | ||
@app.task(queue='web') | ||
def sync_files(project_pk, version_pk, hostname=None, html=False, | ||
def sync_files(project_pk, version_pk, doctype, hostname=None, html=False, | ||
localmedia=False, search=False, pdf=False, epub=False): | ||
""" | ||
Sync build artifacts to application instances. | ||
|
@@ -857,6 +860,7 @@ def sync_files(project_pk, version_pk, hostname=None, html=False, | |
move_files( | ||
version_pk, | ||
hostname, | ||
doctype, | ||
html=html, | ||
localmedia=localmedia, | ||
search=search, | ||
|
@@ -872,7 +876,7 @@ def sync_files(project_pk, version_pk, hostname=None, html=False, | |
|
||
|
||
@app.task(queue='web') | ||
def move_files(version_pk, hostname, html=False, localmedia=False, | ||
def move_files(version_pk, hostname, doctype, html=False, localmedia=False, | ||
search=False, pdf=False, epub=False): | ||
""" | ||
Task to move built documentation to web servers. | ||
|
@@ -902,63 +906,62 @@ def move_files(version_pk, hostname, html=False, localmedia=False, | |
if html: | ||
from_path = version.project.artifact_path( | ||
version=version.slug, | ||
type_=version.project.documentation_type, | ||
type_=doctype, | ||
) | ||
target = version.project.rtd_build_path(version.slug) | ||
Syncer.copy(from_path, target, host=hostname) | ||
|
||
if 'sphinx' in version.project.documentation_type: | ||
if search: | ||
from_path = version.project.artifact_path( | ||
version=version.slug, | ||
type_='sphinx_search', | ||
) | ||
to_path = version.project.get_production_media_path( | ||
type_='json', | ||
version_slug=version.slug, | ||
include_file=False, | ||
) | ||
Syncer.copy(from_path, to_path, host=hostname) | ||
if search: | ||
stsewd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
from_path = version.project.artifact_path( | ||
version=version.slug, | ||
type_='sphinx_search', | ||
) | ||
to_path = version.project.get_production_media_path( | ||
type_='json', | ||
version_slug=version.slug, | ||
include_file=False, | ||
) | ||
Syncer.copy(from_path, to_path, host=hostname) | ||
|
||
if localmedia: | ||
from_path = version.project.artifact_path( | ||
version=version.slug, | ||
type_='sphinx_localmedia', | ||
) | ||
to_path = version.project.get_production_media_path( | ||
type_='htmlzip', | ||
version_slug=version.slug, | ||
include_file=False, | ||
) | ||
Syncer.copy(from_path, to_path, host=hostname) | ||
if localmedia: | ||
from_path = version.project.artifact_path( | ||
version=version.slug, | ||
type_='sphinx_localmedia', | ||
) | ||
to_path = version.project.get_production_media_path( | ||
type_='htmlzip', | ||
version_slug=version.slug, | ||
include_file=False, | ||
) | ||
Syncer.copy(from_path, to_path, host=hostname) | ||
|
||
# Always move PDF's because the return code lies. | ||
if pdf: | ||
from_path = version.project.artifact_path( | ||
version=version.slug, | ||
type_='sphinx_pdf', | ||
) | ||
to_path = version.project.get_production_media_path( | ||
type_='pdf', | ||
version_slug=version.slug, | ||
include_file=False, | ||
) | ||
Syncer.copy(from_path, to_path, host=hostname) | ||
if epub: | ||
from_path = version.project.artifact_path( | ||
version=version.slug, | ||
type_='sphinx_epub', | ||
) | ||
to_path = version.project.get_production_media_path( | ||
type_='epub', | ||
version_slug=version.slug, | ||
include_file=False, | ||
) | ||
Syncer.copy(from_path, to_path, host=hostname) | ||
# Always move PDF's because the return code lies. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment looks outdated |
||
if pdf: | ||
from_path = version.project.artifact_path( | ||
version=version.slug, | ||
type_='sphinx_pdf', | ||
) | ||
to_path = version.project.get_production_media_path( | ||
type_='pdf', | ||
version_slug=version.slug, | ||
include_file=False, | ||
) | ||
Syncer.copy(from_path, to_path, host=hostname) | ||
if epub: | ||
from_path = version.project.artifact_path( | ||
version=version.slug, | ||
type_='sphinx_epub', | ||
) | ||
to_path = version.project.get_production_media_path( | ||
type_='epub', | ||
version_slug=version.slug, | ||
include_file=False, | ||
) | ||
Syncer.copy(from_path, to_path, host=hostname) | ||
|
||
|
||
@app.task(queue='web') | ||
def update_search(version_pk, commit, delete_non_commit_files=True): | ||
def update_search(version_pk, commit, doctype, delete_non_commit_files=True): | ||
""" | ||
Task to update search indexes. | ||
|
||
|
@@ -968,12 +971,12 @@ def update_search(version_pk, commit, delete_non_commit_files=True): | |
""" | ||
version = Version.objects.get(pk=version_pk) | ||
|
||
if 'sphinx' in version.project.documentation_type: | ||
if 'sphinx' in doctype: | ||
stsewd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
page_list = process_all_json_files(version, build_dir=False) | ||
else: | ||
log.debug( | ||
'Unknown documentation type: %s', | ||
version.project.documentation_type | ||
doctype | ||
) | ||
return | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm passing only the
doctype
here rather than the wholeconfig
object, we only use the doctype, but if someone thinks it's useful passing theconfig
I can change it.