2
2
3
3
from jinja2 import DictLoader , Environment
4
4
5
- __path__ = os .path .realpath (os .path .join (os .getcwd (), os .path .dirname (__file__ ), '..' ))
5
+ __path__ = os .path .realpath (os .path .join (os .getcwd (), os .path .dirname (__file__ ), ".." ))
6
6
7
- apidoc_root = ' docs/reference/api'
7
+ apidoc_root = " docs/reference/api"
8
8
9
9
10
10
class Module :
11
11
def __init__ (self , name , title = None , * , automodule_options = None ):
12
12
13
13
self .name = name
14
- self .title = title or ' ' .join (map (str .title , self .name .split ('.' )[1 :]))
14
+ self .title = title or " " .join (map (str .title , self .name .split ("." )[1 :]))
15
15
self .automodule_options = automodule_options or list ()
16
16
17
17
def __repr__ (self ):
18
- return ' <{} ({})>' .format (self .title , self .name )
18
+ return " <{} ({})>" .format (self .title , self .name )
19
19
20
20
def asdict (self ):
21
- return {' name' : self .name , ' title' : self .title , ' automodule_options' : self .automodule_options }
21
+ return {" name" : self .name , " title" : self .title , " automodule_options" : self .automodule_options }
22
22
23
23
def get_path (self ):
24
- return os .path .join (__path__ , apidoc_root , * self .name .split ('.' )) + ' .rst'
24
+ return os .path .join (__path__ , apidoc_root , * self .name .split ("." )) + " .rst"
25
25
26
26
27
27
modules = [
28
- Module (' bonobo' , title = ' Bonobo' ),
29
- Module (' bonobo.config' ),
30
- Module (' bonobo.constants' , automodule_options = [' no-members' ]),
31
- Module (' bonobo.execution' ),
32
- Module (' bonobo.execution.contexts' ),
33
- Module (' bonobo.execution.events' ),
34
- Module (' bonobo.execution.strategies' ),
35
- Module (' bonobo.util' ),
28
+ Module (" bonobo" , title = " Bonobo" ),
29
+ Module (" bonobo.config" ),
30
+ Module (" bonobo.constants" , automodule_options = [" no-members" ]),
31
+ Module (" bonobo.execution" ),
32
+ Module (" bonobo.execution.contexts" ),
33
+ Module (" bonobo.execution.events" ),
34
+ Module (" bonobo.execution.strategies" ),
35
+ Module (" bonobo.util" ),
36
36
]
37
37
38
38
39
39
def underlined_filter (txt , chr ):
40
- return txt + ' \n ' + chr * len (txt )
40
+ return txt + " \n " + chr * len (txt )
41
41
42
42
43
43
env = Environment (
44
44
loader = DictLoader (
45
45
{
46
- ' module' : '''
46
+ " module" : """
47
47
{{ (':mod:`'~title~' <'~name~'>`') | underlined('=') }}
48
48
49
49
.. currentmodule:: {{ name }}
@@ -52,15 +52,15 @@ def underlined_filter(txt, chr):
52
52
53
53
.. automodule:: {{ name }}
54
54
{% for opt in automodule_options %} :{{ opt }}:{{ "\n " }}{% endfor %}
55
- ''' [
55
+ """ [
56
56
1 :- 1
57
57
]
58
- + ' \n '
58
+ + " \n "
59
59
}
60
60
)
61
61
)
62
- env .filters [' underlined' ] = underlined_filter
62
+ env .filters [" underlined" ] = underlined_filter
63
63
64
64
for module in modules :
65
- with open (module .get_path (), 'w+' ) as f :
66
- f .write (env .get_template (' module' ).render (module .asdict ()))
65
+ with open (module .get_path (), "w+" ) as f :
66
+ f .write (env .get_template (" module" ).render (module .asdict ()))
0 commit comments