1
1
# -*- coding: utf-8 -*-
2
+
2
3
"""
3
4
Custom management command to rebuild documentation for all projects.
4
5
5
6
Invoked via ``./manage.py update_repos``.
6
7
"""
7
8
8
- from __future__ import absolute_import
9
+ from __future__ import (
10
+ absolute_import , division , print_function , unicode_literals )
9
11
10
12
import logging
11
- from optparse import make_option
12
13
13
14
from django .core .management .base import BaseCommand
14
15
17
18
from readthedocs .projects import tasks
18
19
from readthedocs .projects .models import Project
19
20
20
-
21
21
log = logging .getLogger (__name__ )
22
22
23
23
24
24
class Command (BaseCommand ):
25
25
26
- """Management command for rebuilding documentation on projects"""
26
+ """Management command for rebuilding documentation on projects. """
27
27
28
28
help = __doc__
29
29
@@ -35,39 +35,45 @@ def add_arguments(self, parser):
35
35
action = 'store_true' ,
36
36
dest = 'record' ,
37
37
default = False ,
38
- help = 'Make a Build'
38
+ help = 'Make a Build' ,
39
39
)
40
40
41
41
parser .add_argument (
42
42
'-f' ,
43
43
action = 'store_true' ,
44
44
dest = 'force' ,
45
45
default = False ,
46
- help = 'Force a build in sphinx'
46
+ help = 'Force a build in sphinx' ,
47
47
)
48
48
49
49
parser .add_argument (
50
50
'-V' ,
51
51
dest = 'version' ,
52
52
default = None ,
53
- help = 'Build a version, or all versions'
53
+ help = 'Build a version, or all versions' ,
54
54
)
55
55
56
56
def handle (self , * args , ** options ):
57
57
record = options ['record' ]
58
58
force = options ['force' ]
59
59
version = options ['version' ]
60
- if args :
60
+
61
+ if options .get ('slug' , []):
61
62
for slug in options ['slugs' ]:
62
- if version and version != "all" :
63
- log .info ("Updating version %s for %s" , version , slug )
64
- for version in Version .objects .filter (project__slug = slug , slug = version ):
63
+ if version and version != 'all' :
64
+ log .info ('Updating version %s for %s' , version , slug )
65
+ for version in Version .objects .filter (
66
+ project__slug = slug ,
67
+ slug = version ,
68
+ ):
65
69
trigger_build (project = version .project , version = version )
66
- elif version == "all" :
67
- log .info ("Updating all versions for %s" , slug )
68
- for version in Version .objects .filter (project__slug = slug ,
69
- active = True ,
70
- uploaded = False ):
70
+ elif version == 'all' :
71
+ log .info ('Updating all versions for %s' , slug )
72
+ for version in Version .objects .filter (
73
+ project__slug = slug ,
74
+ active = True ,
75
+ uploaded = False ,
76
+ ):
71
77
72
78
build_pk = None
73
79
if record :
@@ -83,28 +89,30 @@ def handle(self, *args, **options):
83
89
pk = version .project_id ,
84
90
build_pk = build_pk ,
85
91
record = record ,
86
- version_pk = version .pk
92
+ version_pk = version .pk ,
87
93
)
88
94
else :
89
95
p = Project .all_objects .get (slug = slug )
90
- log .info (" Building %s" , p )
96
+ log .info (' Building %s' , p )
91
97
trigger_build (project = p , force = force , record = record )
92
98
else :
93
- if version == "all" :
94
- log .info ("Updating all versions" )
95
- for version in Version .objects .filter (active = True ,
96
- uploaded = False ):
99
+ if version == 'all' :
100
+ log .info ('Updating all versions' )
101
+ for version in Version .objects .filter (
102
+ active = True ,
103
+ uploaded = False ,
104
+ ):
97
105
tasks .UpdateDocsTask ().run (
98
106
pk = version .project_id ,
99
107
record = record ,
100
108
force = force ,
101
- version_pk = version .pk
109
+ version_pk = version .pk ,
102
110
)
103
111
else :
104
- log .info (" Updating all docs" )
112
+ log .info (' Updating all docs' )
105
113
for project in Project .objects .all ():
106
114
tasks .UpdateDocsTask ().run (
107
115
pk = project .pk ,
108
116
record = record ,
109
- force = force
117
+ force = force ,
110
118
)
0 commit comments