Transform lines, and possibly output to the given file.
(self, lines)
| 335 | return oldname.rstrip(upper) == newname.rstrip(upper) |
| 336 | |
| 337 | def transformFile(self, lines): |
| 338 | """Transform lines, and possibly output to the given file.""" |
| 339 | |
| 340 | for line in lines: |
| 341 | self.state.incrLineNumber() |
| 342 | |
| 343 | # Is this a title line (leading '= ' followed by text)? |
| 344 | thisTitle = False |
| 345 | |
| 346 | # The logic here is broken. If we are in a non-transformable block and |
| 347 | # this line *does not* end the block, it should always be |
| 348 | # accumulated. |
| 349 | |
| 350 | # Test for a blockCommonTransform delimiter comment first, to avoid |
| 351 | # treating it solely as an end-Paragraph marker comment. |
| 352 | if line == blockCommonTransform: |
| 353 | # Starting or ending a pseudo-block for "common" VU statements. |
| 354 | self.endParaBlockTransform(line, vuBlock = True) |
| 355 | |
| 356 | elif blockTransform.match(line): |
| 357 | # Starting or ending a block whose contents may be transformed. |
| 358 | # Blocks cannot be nested. |
| 359 | |
| 360 | # Is this is an explicit Valid Usage block? |
| 361 | vuBlock = (self.state.lineNumber > 1 and |
| 362 | lines[self.state.lineNumber-2] == '.Valid Usage\n') |
| 363 | |
| 364 | self.endParaBlockTransform(line, vuBlock) |
| 365 | |
| 366 | elif endPara.match(line): |
| 367 | # Ending a paragraph. Emit the current paragraph, if any, and |
| 368 | # prepare to begin a new paragraph. |
| 369 | |
| 370 | self.endPara(line) |
| 371 | |
| 372 | # If this is an include:: line starting the definition of a |
| 373 | # structure or command, track that for use in VUID generation. |
| 374 | |
| 375 | matches = includePat.search(line) |
| 376 | if matches is not None: |
| 377 | generated_type = matches.group('generated_type') |
| 378 | include_type = matches.group('category') |
| 379 | if generated_type == 'api' and include_type in ('protos', 'structs', 'funcpointers'): |
| 380 | apiName = matches.group('entity_name') |
| 381 | if self.state.apiName != self.state.defaultApiName: |
| 382 | # This happens when there are multiple API include |
| 383 | # lines in a single block. The style guideline is to |
| 384 | # always place the API which others are promoted to |
| 385 | # first. In virtually all cases, the promoted API |
| 386 | # will differ solely in the vendor suffix (or |
| 387 | # absence of it), which is benign. |
| 388 | if not self.apiMatch(self.state.apiName, apiName): |
| 389 | logDiag(f'Promoted API name mismatch at line {self.state.lineNumber}: {apiName} does not match self.state.apiName (this is OK if it is just a spelling alias)') |
| 390 | else: |
| 391 | self.state.apiName = apiName |
| 392 | |
| 393 | elif endParaContinue.match(line): |
| 394 | # For now, always just end the paragraph. |
no test coverage detected