1
+ """Models for the builds app."""
2
+
1
3
import logging
2
4
import re
3
5
import os .path
32
34
33
35
34
36
class Version (models .Model ):
37
+
38
+ """Version of a ``Project``."""
39
+
35
40
project = models .ForeignKey (Project , verbose_name = _ ('Project' ),
36
41
related_name = 'versions' )
37
42
type = models .CharField (
@@ -154,7 +159,7 @@ def save(self, *args, **kwargs):
154
159
155
160
def delete (self , * args , ** kwargs ):
156
161
from readthedocs .projects import tasks
157
- log .info ('Removing files for version %s' % self .slug )
162
+ log .info ('Removing files for version %s' , self .slug )
158
163
tasks .clear_artifacts .delay (version_pk = self .pk )
159
164
broadcast (type = 'app' , task = tasks .symlink_project , args = [self .project .pk ])
160
165
super (Version , self ).delete (* args , ** kwargs )
@@ -220,6 +225,18 @@ def clean_build_path(self):
220
225
log .error ('Build path cleanup failed' , exc_info = True )
221
226
222
227
def get_github_url (self , docroot , filename , source_suffix = '.rst' , action = 'view' ):
228
+ """
229
+ Return a GitHub URL for a given filename.
230
+
231
+ `docroot`
232
+ Location of documentation in repository
233
+ `filename`
234
+ Name of file
235
+ `source_suffix`
236
+ File suffix of documentation format
237
+ `action`
238
+ `view` (default) or `edit`
239
+ """
223
240
repo_url = self .project .repo
224
241
if 'github' not in repo_url :
225
242
return ''
@@ -283,6 +300,9 @@ def get_bitbucket_url(self, docroot, filename, source_suffix='.rst'):
283
300
284
301
285
302
class VersionAlias (models .Model ):
303
+
304
+ """Alias for a ``Version``."""
305
+
286
306
project = models .ForeignKey (Project , verbose_name = _ ('Project' ),
287
307
related_name = 'aliases' )
288
308
from_slug = models .CharField (_ ('From slug' ), max_length = 255 , default = '' )
@@ -299,6 +319,9 @@ def __unicode__(self):
299
319
300
320
301
321
class Build (models .Model ):
322
+
323
+ """Build data."""
324
+
302
325
project = models .ForeignKey (Project , verbose_name = _ ('Project' ),
303
326
related_name = 'builds' )
304
327
version = models .ForeignKey (Version , verbose_name = _ ('Version' ), null = True ,
@@ -373,6 +396,9 @@ def failed(self):
373
396
374
397
375
398
class BuildCommandResult (BuildCommandResultMixin , models .Model ):
399
+
400
+ """Build command for a ``Build``."""
401
+
376
402
build = models .ForeignKey (Build , verbose_name = _ ('Build' ),
377
403
related_name = 'commands' )
378
404
0 commit comments