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

Function remapIncludes

scripts/genRef.py:231–263  ·  view source on GitHub ↗

Remap include directives in a list of lines so they can be extracted to a different directory. Returns remapped lines. - lines - text to remap - baseDir - target directory - specDir - source directory

(lines, baseDir, specDir)

Source from the content-addressed store, hash-verified

229
230
231def remapIncludes(lines, baseDir, specDir):
232 """Remap include directives in a list of lines so they can be extracted to a
233 different directory.
234
235 Returns remapped lines.
236
237 - lines - text to remap
238 - baseDir - target directory
239 - specDir - source directory"""
240 # This should be compiled only once
241 includePat = re.compile(r'^include::(?P<path>.*)\[\]')
242
243 newLines = []
244 for line in lines:
245 matches = includePat.search(line)
246 if matches is not None:
247 path = matches.group('path')
248
249 if path[0] != '{':
250 # Relative path to include file from here
251 incPath = f'{specDir}/{path}'
252 # Remap to be relative to baseDir
253 newPath = os.path.relpath(incPath, baseDir)
254 newLine = f'include::{newPath}[]\n'
255 logDiag('remapIncludes: remapping', line, '->', newLine)
256 newLines.append(newLine)
257 else:
258 # An asciidoctor variable starts the path.
259 # This must be an absolute path, not needing to be rewritten.
260 newLines.append(line)
261 else:
262 newLines.append(line)
263 return newLines
264
265
266def refPageShell(pageName, pageDesc, pageAliases, fp, head_content = None, sections=None, tail_content=None, man_section=3):

Callers 1

emitPageFunction · 0.85

Calls 2

logDiagFunction · 0.90
appendMethod · 0.80

Tested by

no test coverage detected