Generate text showing what core versions and extensions introduce an API. This relies on the map in apimap.py, which may be loaded at runtime into self.apidict. If not present, no message is generated. - name - name of the API - mustBeFound - If True, when re
(self, name, mustBeFound = True, indent = 0)
| 174 | OutputGenerator.endFeature(self) |
| 175 | |
| 176 | def genRequirements(self, name, mustBeFound = True, indent = 0): |
| 177 | """Generate text showing what core versions and extensions introduce |
| 178 | an API. This relies on the map in apimap.py, which may be loaded at |
| 179 | runtime into self.apidict. If not present, no message is |
| 180 | generated. |
| 181 | |
| 182 | - name - name of the API |
| 183 | - mustBeFound - If True, when requirements for 'name' cannot be |
| 184 | determined, a warning comment is generated. |
| 185 | """ |
| 186 | |
| 187 | if self.apidict: |
| 188 | if name in self.apidict.requiredBy: |
| 189 | # It is possible to get both 'A with B' and 'B with A' for |
| 190 | # the same API. |
| 191 | # To simplify this, sort the (base,dependency) requirements |
| 192 | # and put them in a set to ensure they are unique. |
| 193 | features = set() |
| 194 | # 'dependency' may be a boolean expression of extension names |
| 195 | for (base,dependency) in self.apidict.requiredBy[name]: |
| 196 | if dependency is not None: |
| 197 | # 'dependency' may be a boolean expression of extension |
| 198 | # names, in which case the sorting will not work well. |
| 199 | |
| 200 | # First, convert it from asciidoctor markup to language. |
| 201 | depLanguage = dependencyLanguageComment(dependency) |
| 202 | |
| 203 | # If they are the same, the dependency is only a |
| 204 | # single extension, and sorting them works. |
| 205 | # Otherwise, skip it. |
| 206 | if depLanguage == dependency: |
| 207 | deps = sorted( |
| 208 | sorted((base, dependency)), |
| 209 | key=orgLevelKey) |
| 210 | depString = ' with '.join(deps) |
| 211 | else: |
| 212 | # An expression with multiple extensions |
| 213 | depString = f'{base} with {depLanguage}' |
| 214 | |
| 215 | features.add(depString) |
| 216 | else: |
| 217 | features.add(base) |
| 218 | # Sort the overall dependencies so core versions are first |
| 219 | provider = ', '.join(sorted( |
| 220 | sorted(features), |
| 221 | key=orgLevelKey)) |
| 222 | return f"{indent * ' '}// Provided by {provider}\n" |
| 223 | else: |
| 224 | if mustBeFound: |
| 225 | self.logMsg('warn', f'genRequirements: API {name} not found') |
| 226 | return '' |
| 227 | else: |
| 228 | # No API dictionary available, return nothing |
| 229 | return '' |
| 230 | |
| 231 | # Determine whether an API should be deprecated based on whether it is |
| 232 | # vendor/core/EXT/KHR and whether the thing deprecating it is |