MCPcopy
hub / github.com/KhronosGroup/Vulkan-Docs / findRefs

Function findRefs

scripts/reflib.py:431–659  ·  view source on GitHub ↗

Identify reference pages in a list of strings, returning a dictionary of pageInfo entries for each one found, or None on failure. - file - list of strings - filename - name of file strings were loaded from - aliasFrom - map from refpage name to a set of its aliases

(file, filename, aliasFrom)

Source from the content-addressed store, hash-verified

429 r'include::(?P<directory_traverse>((../){1,4}|\{generated\}/)(generated/)?)(?P<generated_type>[\w]+)/(?P<category>\w+)/(?P<entity_name>[^./]+)\.(adoc|txt)[\[][\]]')
430
431def findRefs(file, filename, aliasFrom):
432 """Identify reference pages in a list of strings, returning a dictionary of
433 pageInfo entries for each one found, or None on failure.
434 - file - list of strings
435 - filename - name of file strings were loaded from
436 - aliasFrom - map from refpage name to a set of its aliases"""
437
438 setLogSourcefile(filename)
439 setLogProcname('findRefs')
440
441 # To reliably detect the open blocks around reference pages, we must
442 # first detect the '[open,refpage=...]' markup delimiting the block;
443 # skip past the '--' block delimiter on the next line; and identify the
444 # '--' block delimiter closing the page.
445 # This cannot be done solely with pattern matching, and requires state to
446 # track 'inside/outside block'.
447 # When looking for open blocks, possible states are:
448 # 'outside' - outside a block
449 # 'start' - have found the '[open...]' line
450 # 'inside' - have found the following '--' line
451 openBlockState = 'outside'
452
453 # Dictionary of interesting line numbers and strings related to an API
454 # name
455 refpageMap = {}
456
457 numLines = len(file)
458 line = 0
459
460 # Track the pageInfo object corresponding to the current open block
461 pi = None
462
463 while (line < numLines):
464 setLogLine(line)
465
466 # Only one of the patterns can possibly match. Add it to
467 # the dictionary for that name.
468
469 # [open,refpage=...] starting a refpage block
470 matches = beginPat.search(file[line])
471 if matches is not None:
472 logDiag('Matched open block pattern')
473 attribs = matches.group('attribs')
474
475 # If the previous open block was not closed, raise an error
476 if openBlockState != 'outside':
477 logErr(f'Nested open block starting at line {line} of {filename}')
478
479 openBlockState = 'start'
480
481 # Parse the block attributes
482 matches = attribPat.findall(attribs)
483
484 # Extract each attribute
485 name = None
486 desc = None
487 refpage_type = None
488 spec_type = None

Callers 3

genRefFunction · 0.90
insertTagsFunction · 0.85
replaceRefFunction · 0.85

Calls 10

setLogSourcefileFunction · 0.85
setLogProcnameFunction · 0.85
setLogLineFunction · 0.85
logDiagFunction · 0.85
logErrFunction · 0.85
unescapeQuotesFunction · 0.85
logWarnFunction · 0.85
lookupPageFunction · 0.85
compatiblePageTypesFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected