1+ """Base formatter class."""
12from abc import abstractmethod , ABCMeta
23
34from .registry import register
45
6+
57def counter ():
68 """Simple Iteratable Counter.
79
@@ -18,12 +20,14 @@ def counter():
1820
1921
2022class FormatterMeta (ABCMeta ):
21- """Registers the class in the formatter
23+ """Register the class in the formatter.
2224
2325 Extends:
2426 ABCMeta
2527 """
28+
2629 def __new__ (mcs , classname , bases , attributes ):
30+ """---."""
2731 newclass = super (FormatterMeta , mcs ).__new__ (mcs , classname , bases , attributes )
2832 register (newclass )
2933 return newclass
@@ -51,10 +55,12 @@ class Base(metaclass=FormatterMeta):
5155 tab_index {generator} -- Provides a simple count generator for convenience
5256 in making tabbable fields
5357 """
58+
5459 name = None
5560 tab_index = counter ()
5661
5762 def __dict__ (self ):
63+ """---."""
5864 return {
5965 'summary' : self .summary ,
6066 'description' : self .description ,
@@ -69,11 +75,12 @@ def __dict__(self):
6975 }
7076
7177 def __iter__ (self ):
78+ """---."""
7279 for attr , value in self .__dict__ ().items ():
7380 yield attr , value
7481
7582 def _generate_field (self , name , value = None ):
76- """Makes Sublime Text snippet fields .
83+ """Make a Sublime Text snippet field .
7784
7885 If a value is passed and it is not None, it will be returned. Otherwise,
7986 this will generate a snippet field in the next tabbable index.
@@ -96,65 +103,85 @@ def _generate_field(self, name, value=None):
96103 )
97104
98105 def summary (self ):
106+ """Create snippet string for the summary line."""
99107 return '{}' .format (self ._generate_field ('summary' ))
100108
101109 def description (self ):
110+ """Create snippet string for the description body."""
102111 return '\n \n {}\n ' .format (self ._generate_field ('description' ))
103112
104113 @abstractmethod
105114 def decorators (self , attributes ):
115+ """Create snippet string for a list of decorators."""
106116 return ''
107117
108118 @abstractmethod
109119 def extends (self , attributes ):
120+ """Create snippet string for a list of extended objects."""
110121 return ''
111122
112123 @abstractmethod
113124 def arguments (self , attributes ):
125+ """Create snippet string for a list of arguments."""
114126 return ''
115127
116128 @abstractmethod
117129 def keyword_arguments (self , attributes ):
130+ """Create snippet string for a list of keyword arguments."""
118131 return ''
119132
120133 @abstractmethod
121134 def returns (self , attribute ):
135+ """Create snippet string for a list of return values."""
122136 return ''
123137
124138 @abstractmethod
125139 def yields (self , attribute ):
140+ """Create snippet string for a list of yielded results."""
126141 return ''
127142
128143 @abstractmethod
129144 def raises (self , attributes ):
145+ """Create snippet string for a list of raiased exceptions."""
130146 return ''
131147
132148 @abstractmethod
133149 def variables (self , attributes ):
150+ """Create snippet string for a list of variables."""
134151 return ''
135152
136153
137154class BaseFormatter (Base ):
155+ """Documentation Formatter Class."""
156+
138157 def decorators (self , attributes ):
158+ """Create snippet string for a list of decorators."""
139159 return '{}\n ' .format (self ._generate_field ('decorators' ))
140160
141161 def extends (self , attributes ):
162+ """Create snippet string for a list of extended objects."""
142163 return '{}\n ' .format (self ._generate_field ('extends' ))
143164
144165 def arguments (self , attributes ):
166+ """Create snippet string for a list of arguments."""
145167 return '{}\n ' .format (self ._generate_field ('arguments' ))
146168
147169 def keyword_arguments (self , attributes ):
170+ """Create snippet string for a list of keyword arguments."""
148171 return '{}\n ' .format (self ._generate_field ('keyword arguments' ))
149172
150173 def returns (self , attribute ):
174+ """Create snippet string for a list of return values."""
151175 return '{}\n ' .format (self ._generate_field ('returns' ))
152176
153177 def yields (self , attribute ):
178+ """Create snippet string for a list of yielded results."""
154179 return '{}\n ' .format (self ._generate_field ('yields' ))
155180
156181 def raises (self , attributes ):
182+ """Create snippet string for a list of raiased exceptions."""
157183 return '{}\n ' .format (self ._generate_field ('raises' ))
158184
159185 def variables (self , attributes ):
186+ """Create snippet string for a list of variables."""
160187 return '{}\n ' .format (self ._generate_field ('variables' ))
0 commit comments