@@ -86,7 +86,7 @@ def tags(self):
8686 self ._tags = self ._parse_readme_input_file_tags ()
8787 return self ._tags
8888
89- def _parse_readme_input_file_tags (self ):
89+ def _parse_readme_input_file_tags_v0 (self ):
9090 tags = {}
9191 if not self ._readme_paths :
9292 return tags
@@ -133,6 +133,43 @@ def _parse_readme_input_file_tags(self):
133133 tags = OrderedDict (tags )
134134 return tags
135135
136+ def _parse_readme_input_file_tags (self ):
137+ tags = {}
138+ if not self ._readme_paths :
139+ return tags
140+
141+ for readme_path in self ._readme_paths :
142+ with open (readme_path , 'r' , encoding = 'utf-8' ) as f :
143+ readme = f .read ()
144+
145+ pattern = re .compile (r'yaml\s*\$\(\s*tag\s*\)\s*==\s*\'([^\']+)\'\s*input-file:\s*((?:\s*- [^\n]+\s*)+)\s*' ,
146+ flags = re .DOTALL )
147+ for piece in pattern .finditer (readme ):
148+ tag = piece [1 ].strip ()
149+ input_files = piece [2 ].splitlines ()
150+ files = []
151+ for i_file in input_files :
152+ file_path = i_file .strip ().lstrip ('-' ).strip ()
153+ file_path = file_path .replace ('$(this-folder)/' , '' )
154+ file_path = os .path .join (os .path .dirname (readme_path ), * file_path .split ('/' ))
155+ if not os .path .isfile (file_path ):
156+ logger .warning (f'FileNotExist: { self } : { file_path } ' )
157+ continue
158+ files .append (file_path )
159+
160+ if len (files ):
161+ if tag is None :
162+ tag = ''
163+ tag = OpenAPIResourceProviderTag (tag .strip (), self )
164+ if tag not in tags :
165+ tags [tag ] = set ()
166+ tags [tag ] = tags [tag ].union (files )
167+
168+ tags = [* tags .items ()]
169+ tags .sort (key = lambda item : item [0 ].date , reverse = True )
170+ tags = OrderedDict (tags )
171+ return tags
172+
136173 def _fetch_latest_tag (self , file_path ):
137174 for tag , file_set in self .tags .items ():
138175 if file_path in file_set :
0 commit comments