Skip to content

Commit 9780643

Browse files
committed
Use config object to get doctype
1 parent 0db0d94 commit 9780643

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

readthedocs/projects/models.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -595,16 +595,6 @@ def conf_dir(self, version=LATEST):
595595
if conf_file:
596596
return os.path.dirname(conf_file)
597597

598-
@property
599-
def is_type_sphinx(self):
600-
"""Is project type Sphinx."""
601-
return 'sphinx' in self.documentation_type
602-
603-
@property
604-
def is_type_mkdocs(self):
605-
"""Is project type Mkdocs."""
606-
return 'mkdocs' in self.documentation_type
607-
608598
@property
609599
def is_imported(self):
610600
return bool(self.repo)

readthedocs/projects/tasks.py

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ def update_app_instances(self, html=False, localmedia=False, search=False,
614614
args=[
615615
self.project.pk,
616616
self.version.pk,
617+
self.config,
617618
],
618619
kwargs=dict(
619620
hostname=socket.gethostname(),
@@ -695,10 +696,12 @@ def build_docs_html(self):
695696

696697
# Gracefully attempt to move files via task on web workers.
697698
try:
698-
broadcast(type='app', task=move_files,
699-
args=[self.version.pk, socket.gethostname()],
700-
kwargs=dict(html=True)
701-
)
699+
broadcast(
700+
type='app',
701+
task=move_files,
702+
args=[self.version.pk, socket.gethostname(), self.config],
703+
kwargs=dict(html=True)
704+
)
702705
except socket.error:
703706
log.exception('move_files task has failed on socket error.')
704707

@@ -710,23 +713,23 @@ def build_docs_localmedia(self):
710713
return False
711714

712715
if self.build_localmedia:
713-
if self.project.is_type_sphinx:
716+
if self.is_type_sphinx():
714717
return self.build_docs_class('sphinx_singlehtmllocalmedia')
715718
return False
716719

717720
def build_docs_pdf(self):
718721
"""Build PDF docs."""
719722
if ('pdf' not in self.config.formats or
720-
self.project.slug in HTML_ONLY or
721-
not self.project.is_type_sphinx):
723+
self.project.slug in HTML_ONLY or
724+
not self.is_type_sphinx()):
722725
return False
723726
return self.build_docs_class('sphinx_pdf')
724727

725728
def build_docs_epub(self):
726729
"""Build ePub docs."""
727730
if ('epub' not in self.config.formats or
728731
self.project.slug in HTML_ONLY or
729-
not self.project.is_type_sphinx):
732+
not self.is_type_sphinx()):
730733
return False
731734
return self.build_docs_class('sphinx_epub')
732735

@@ -750,16 +753,22 @@ def send_notifications(self):
750753
"""Send notifications on build failure."""
751754
send_notifications.delay(self.version.pk, build_pk=self.build['id'])
752755

756+
def is_type_sphinx(self):
757+
"""Is documentation type Sphinx."""
758+
return 'sphinx' in self.config.doctype
759+
753760

754761
# Web tasks
755762
@app.task(queue='web')
756-
def sync_files(project_pk, version_pk, hostname=None, html=False,
763+
def sync_files(project_pk, version_pk, config, hostname=None, html=False,
757764
localmedia=False, search=False, pdf=False, epub=False):
758765
"""
759766
Sync build artifacts to application instances.
760767
761768
This task broadcasts from a build instance on build completion and performs
762769
synchronization of build artifacts on each application instance.
770+
771+
:param config: A `readthedocs.config.BuildConfigBase` object
763772
"""
764773
# Clean up unused artifacts
765774
version = Version.objects.get(pk=version_pk)
@@ -782,6 +791,7 @@ def sync_files(project_pk, version_pk, hostname=None, html=False,
782791
move_files(
783792
version_pk,
784793
hostname,
794+
config,
785795
html=html,
786796
localmedia=localmedia,
787797
search=search,
@@ -797,13 +807,14 @@ def sync_files(project_pk, version_pk, hostname=None, html=False,
797807

798808

799809
@app.task(queue='web')
800-
def move_files(version_pk, hostname, html=False, localmedia=False, search=False,
801-
pdf=False, epub=False):
810+
def move_files(version_pk, hostname, config, html=False, localmedia=False,
811+
search=False, pdf=False, epub=False):
802812
"""
803813
Task to move built documentation to web servers.
804814
805815
:param version_pk: Version id to sync files for
806816
:param hostname: Hostname to sync to
817+
:param config: A `readthedocs.config.BuildConfigBase` object
807818
:param html: Sync HTML
808819
:type html: bool
809820
:param localmedia: Sync local media files
@@ -827,12 +838,12 @@ def move_files(version_pk, hostname, html=False, localmedia=False, search=False,
827838
if html:
828839
from_path = version.project.artifact_path(
829840
version=version.slug,
830-
type_=version.project.documentation_type,
841+
type_=config.doctype,
831842
)
832843
target = version.project.rtd_build_path(version.slug)
833844
Syncer.copy(from_path, target, host=hostname)
834845

835-
if 'sphinx' in version.project.documentation_type:
846+
if 'sphinx' in config.doctype:
836847
if search:
837848
from_path = version.project.artifact_path(
838849
version=version.slug,
@@ -883,21 +894,21 @@ def move_files(version_pk, hostname, html=False, localmedia=False, search=False,
883894

884895

885896
@app.task(queue='web')
886-
def update_search(version_pk, commit, delete_non_commit_files=True):
897+
def update_search(version_pk, commit, config, delete_non_commit_files=True):
887898
"""
888899
Task to update search indexes.
889900
890901
:param version_pk: Version id to update
891902
:param commit: Commit that updated index
903+
:param config: A `readthedocs.config.BuildConfigBase` object
892904
:param delete_non_commit_files: Delete files not in commit from index
893905
"""
894906
version = Version.objects.get(pk=version_pk)
895907

896-
if version.project.is_type_sphinx:
908+
if 'sphinx' in config.doctype:
897909
page_list = process_all_json_files(version, build_dir=False)
898910
else:
899-
log.debug('Unknown documentation type: %s',
900-
version.project.documentation_type)
911+
log.debug('Unknown documentation type: %s', config.doctype)
901912
return
902913

903914
log_msg = ' '.join([page['path'] for page in page_list])

0 commit comments

Comments
 (0)