Style with pre-commit command
# -*- coding: utf-8 -*-
+
"""
Custom management command to rebuild documentation for all projects.
Invoked via ``./manage.py update_repos``.
"""
-from __future__ import absolute_import
+from __future__ import (
+ absolute_import, division, print_function, unicode_literals)
import logging
@@ -16,13 +18,12 @@ from readthedocs.core.utils import trigger_build
from readthedocs.projects import tasks
from readthedocs.projects.models import Project
-
log = logging.getLogger(__name__)
class Command(BaseCommand):
- """Management command for rebuilding documentation on projects"""
+ """Management command for rebuilding documentation on projects."""
help = __doc__
@@ -34,7 +35,7 @@ class Command(BaseCommand):
action='store_true',
dest='record',
default=False,
- help='Make a Build'
+ help='Make a Build',
)
parser.add_argument(
@@ -42,14 +43,14 @@ class Command(BaseCommand):
action='store_true',
dest='force',
default=False,
- help='Force a build in sphinx'
+ help='Force a build in sphinx',
)
parser.add_argument(
'-V',
dest='version',
default=None,
- help='Build a version, or all versions'
+ help='Build a version, or all versions',
)
def handle(self, *args, **options):
@@ -59,15 +60,20 @@ class Command(BaseCommand):
if options.get('slug', []):
for slug in options['slugs']:
- if version and version != "all":
- log.info("Updating version %s for %s", version, slug)
- for version in Version.objects.filter(project__slug=slug, slug=version):
+ if version and version != 'all':
+ log.info('Updating version %s for %s', version, slug)
+ for version in Version.objects.filter(
+ project__slug=slug,
+ slug=version,
+ ):
trigger_build(project=version.project, version=version)
- elif version == "all":
- log.info("Updating all versions for %s", slug)
- for version in Version.objects.filter(project__slug=slug,
+ elif version == 'all':
+ log.info('Updating all versions for %s', slug)
+ for version in Version.objects.filter(
+ project__slug=slug,
active=True,
- uploaded=False):
+ uploaded=False,
+ ):
build_pk = None
if record:
@@ -83,28 +89,30 @@ class Command(BaseCommand):
pk=version.project_id,
build_pk=build_pk,
record=record,
- version_pk=version.pk
+ version_pk=version.pk,
)
else:
p = Project.all_objects.get(slug=slug)
- log.info("Building %s", p)
+ log.info('Building %s', p)
trigger_build(project=p, force=force, record=record)
else:
- if version == "all":
- log.info("Updating all versions")
- for version in Version.objects.filter(active=True,
- uploaded=False):
+ if version == 'all':
+ log.info('Updating all versions')
+ for version in Version.objects.filter(
+ active=True,
+ uploaded=False,
+ ):
tasks.UpdateDocsTask().run(
pk=version.project_id,
record=record,
force=force,
- version_pk=version.pk
+ version_pk=version.pk,
)
else:
- log.info("Updating all docs")
+ log.info('Updating all docs')
for project in Project.objects.all():
tasks.UpdateDocsTask().run(
pk=project.pk,
record=record,
- force=force
+ force=force,
)
