1   
 2   
 3   
 4   
 5   
 6  """defines documentation extractor class interface""" 
 7   
 8  import re 
11      """defines documentation extractor interface""" 
12   
13      __escape_re = re.compile (r'((\\x[a-f0-9][a-f0-9])|(\\*"))', re.I) 
14   
18   
20          """returns documentation text for the declaration 
21   
22          This function should be implemented in derived class. 
23   
24          Using decl.location.file_name and decl.location.line variables you can 
25          find out the location of declaration within source file 
26          """ 
27          raise NotImplementedError() 
 28   
32   
33      @staticmethod 
35          """converts a text to be valid C++ string literals""" 
36          def replace_escape(m): 
37              g = m.group(1) 
38              if g.startswith ('\\x'): 
39                  return g + '""' 
40              elif g == '"': 
41                  return '\\"' 
42              else: 
43                  return g 
 44          return '"%s"' % doc_extractor_i.__escape_re.sub( replace_escape, repr(doc)[1:-1] ) 
 45