1
+ # -*- coding: utf-8 -*-
1
2
"""Base classes for Builders."""
2
3
3
- from __future__ import absolute_import
4
- from builtins import object
5
- from functools import wraps
6
- import os
4
+ from __future__ import (
5
+ absolute_import , division , print_function , unicode_literals )
6
+
7
7
import logging
8
+ import os
8
9
import shutil
10
+ from builtins import object
11
+ from functools import wraps
9
12
10
13
log = logging .getLogger (__name__ )
11
14
@@ -19,6 +22,7 @@ def decorator(*args, **kw):
19
22
return fn (* args , ** kw )
20
23
finally :
21
24
os .chdir (path )
25
+
22
26
return decorator
23
27
24
28
@@ -27,11 +31,12 @@ class BaseBuilder(object):
27
31
"""
28
32
The Base for all Builders. Defines the API for subclasses.
29
33
30
- Expects subclasses to define ``old_artifact_path``,
31
- which points at the directory where artifacts should be copied from.
34
+ Expects subclasses to define ``old_artifact_path``, which points at the
35
+ directory where artifacts should be copied from.
32
36
"""
33
37
34
38
_force = False
39
+
35
40
# old_artifact_path = ..
36
41
37
42
def __init__ (self , build_env , python_env , force = False ):
@@ -41,13 +46,11 @@ def __init__(self, build_env, python_env, force=False):
41
46
self .project = build_env .project
42
47
self ._force = force
43
48
self .target = self .project .artifact_path (
44
- version = self .version .slug ,
45
- type_ = self .type
46
- )
49
+ version = self .version .slug , type_ = self .type )
47
50
48
51
def force (self , ** __ ):
49
52
"""An optional step to force a build even when nothing has changed."""
50
- log .info (" Forcing a build" )
53
+ log .info (' Forcing a build' )
51
54
self ._force = True
52
55
53
56
def build (self ):
@@ -59,16 +62,16 @@ def move(self, **__):
59
62
if os .path .exists (self .old_artifact_path ):
60
63
if os .path .exists (self .target ):
61
64
shutil .rmtree (self .target )
62
- log .info (" Copying %s on the local filesystem" , self .type )
65
+ log .info (' Copying %s on the local filesystem' , self .type )
63
66
shutil .copytree (self .old_artifact_path , self .target )
64
67
else :
65
- log .warning (" Not moving docs, because the build dir is unknown." )
68
+ log .warning (' Not moving docs, because the build dir is unknown.' )
66
69
67
70
def clean (self , ** __ ):
68
- """Clean the path where documentation will be built"""
71
+ """Clean the path where documentation will be built. """
69
72
if os .path .exists (self .old_artifact_path ):
70
73
shutil .rmtree (self .old_artifact_path )
71
- log .info (" Removing old artifact path: %s" , self .old_artifact_path )
74
+ log .info (' Removing old artifact path: %s' , self .old_artifact_path )
72
75
73
76
def docs_dir (self , docs_dir = None , ** __ ):
74
77
"""Handle creating a custom docs_dir if it doesn't exist."""
@@ -87,9 +90,11 @@ def create_index(self, extension='md', **__):
87
90
"""Create an index file if it needs it."""
88
91
docs_dir = self .docs_dir ()
89
92
90
- index_filename = os .path .join (docs_dir , 'index.{ext}' .format (ext = extension ))
93
+ index_filename = os .path .join (
94
+ docs_dir , 'index.{ext}' .format (ext = extension ))
91
95
if not os .path .exists (index_filename ):
92
- readme_filename = os .path .join (docs_dir , 'README.{ext}' .format (ext = extension ))
96
+ readme_filename = os .path .join (
97
+ docs_dir , 'README.{ext}' .format (ext = extension ))
93
98
if os .path .exists (readme_filename ):
94
99
return 'README'
95
100
else :
@@ -101,15 +106,19 @@ def create_index(self, extension='md', **__):
101
106
102
107
This is an autogenerated index file.
103
108
104
- Please create a ``{dir}/index.{ext}`` or ``{dir}/README.{ext}`` file with your own content.
109
+ Please create an ``index.{ext}`` or ``README.{ext}`` file with your own content
110
+ under the root (or ``/docs``) directory in your repository.
105
111
106
112
If you want to use another markup, choose a different builder in your settings.
113
+ Check out our `Getting Started Guide
114
+ <https://docs.readthedocs.io/en/latest/getting_started.html>`_ to become more
115
+ familiar with Read the Docs.
107
116
"""
108
117
109
118
index_file .write (index_text .format (dir = docs_dir , ext = extension ))
110
119
index_file .close ()
111
120
return 'index'
112
121
113
122
def run (self , * args , ** kwargs ):
114
- """Proxy run to build environment"""
123
+ """Proxy run to build environment. """
115
124
return self .build_env .run (* args , ** kwargs )
0 commit comments