1
+ """ Tabbed views for Sphinx, with HTML builder """
2
+
1
3
import os
2
4
from docutils .parsers .rst import Directive
3
5
from docutils import nodes
11
13
12
14
13
15
class TabsDirective (Directive ):
16
+ """ Top-level tabs directive """
17
+
14
18
has_content = True
15
19
16
20
def run (self ):
21
+ """ Parse a tabs directive """
17
22
self .assert_has_content ()
18
23
env = self .state .document .settings .env
19
24
@@ -40,9 +45,12 @@ def run(self):
40
45
41
46
42
47
class TabDirective (Directive ):
48
+ """ Tab directive, for adding a tab to a collection of tabs """
49
+
43
50
has_content = True
44
51
45
52
def run (self ):
53
+ """ Parse a tab directive """
46
54
env = self .state .document .settings .env
47
55
self .assert_has_content ()
48
56
text = '\n ' .join (self .content )
@@ -59,6 +67,7 @@ def run(self):
59
67
60
68
61
69
def add_assets (app ):
70
+ """ Add CSS and JS asset files """
62
71
for path in FILES :
63
72
if '.css' in path :
64
73
app .add_stylesheet (path )
@@ -67,6 +76,7 @@ def add_assets(app):
67
76
68
77
69
78
def copy_assets (app , exception ):
79
+ """ Copy asset files to the output """
70
80
if app .builder .name != 'html' or exception :
71
81
return
72
82
app .info ('Copying tabs assets... ' , nonl = True )
@@ -78,7 +88,8 @@ def copy_assets(app, exception):
78
88
79
89
80
90
def setup (app ):
81
- app .add_directive ('tabs' , TabsDirective )
82
- app .add_directive ('tab' , TabDirective )
91
+ """ Set up the plugin """
92
+ app .add_directive ('tabs' , TabsDirective )
93
+ app .add_directive ('tab' , TabDirective )
83
94
app .connect ('builder-inited' , add_assets )
84
95
app .connect ('build-finished' , copy_assets )
0 commit comments