1313
1414
1515class InvalidSyntax (Exception ):
16+ """ Raise when the syntax of processed object is invalid. """
1617 pass
1718
1819
1920class DocstringUnavailable (Exception ):
21+ """ Raise when trying to process object to which there is no docstring. """
2022 pass
2123
2224
2325class Templater :
26+
2427 def __init__ (self , location , indent , style = 'google' ):
2528 self .style = style
2629 self .indent = indent
@@ -88,8 +91,8 @@ def _object_tree(self):
8891
8992 lines .append (first_line )
9093
91- func_indent = re .findall ('^(\s*)' , first_line )[0 ]
92- expected_indent = concat_ (func_indent , self .env .python_indent )
94+ obj_indent = re .findall ('^(\s*)' , first_line )[0 ]
95+ expected_indent = concat_ (obj_indent , self .env .python_indent )
9396
9497 valid_sig , _ = self ._is_valid (first_line )
9598
@@ -107,14 +110,14 @@ def _object_tree(self):
107110 valid_sig , _ = self ._is_valid (data )
108111 sig_line = last_row
109112
110- # remove func_indent from the beginning of all lines
111- data = '\n ' .join ([re .sub ('^' + func_indent , '' , l ) for l in lines ])
113+ # remove obj_indent from the beginning of all lines
114+ data = '\n ' .join ([re .sub ('^' + obj_indent , '' , l ) for l in lines ])
112115 try :
113116 tree = ast .parse (data )
114117 except Exception as e :
115118 raise InvalidSyntax ('Object has invalid syntax.' )
116119
117- return sig_line , func_indent , tree
120+ return sig_line , obj_indent , tree
118121
119122 def _is_correct_indent (self , previous_line , line , expected_indent ):
120123 """ Check whether given line has either given indentation (or more)
0 commit comments