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

Function genExtension

scripts/genRef.py:983–1080  ·  view source on GitHub ↗

Generate refpage, and add dictionary entry for an extension - baseDir - output directory to generate page in - extpath - None, or path to per-extension specification sources if those are to be included in extension refpages - name - extension name - info - <extension

(baseDir, extpath, name, info)

Source from the content-addressed store, hash-verified

981
982
983def genExtension(baseDir, extpath, name, info):
984 """Generate refpage, and add dictionary entry for an extension
985
986 - baseDir - output directory to generate page in
987 - extpath - None, or path to per-extension specification sources if
988 those are to be included in extension refpages
989 - name - extension name
990 - info - <extension> Element from XML"""
991
992 # Add a dictionary entry for this page
993 global genDict
994 genDict[name] = None
995 declares = set()
996 elem = info.elem
997
998 # Autogenerate interfaces from <extension> entry
999 for required in elem.findall('require'):
1000 req_name = required.get('name')
1001 if not req_name:
1002 # This is not what we are looking for
1003 continue
1004 if req_name.endswith('_SPEC_VERSION') or req_name.endswith('_EXTENSION_NAME'):
1005 # Do not link to spec version or extension name - those ref pages are not created.
1006 continue
1007
1008 if required.get('extends'):
1009 # These are either extensions of enumerated types, or const enum
1010 # values: neither of which get a ref page - although we could
1011 # include the enumerated types in the See Also list.
1012 continue
1013
1014 if req_name not in genDict:
1015 if req_name in api.alias:
1016 logWarn(f'WARN: {req_name} (in extension {name}) is an alias, so does not have a ref page')
1017 else:
1018 logWarn(f'ERROR: {req_name} (in extension {name}) does not have a ref page.')
1019
1020 declares.add(req_name)
1021
1022 appbody = None
1023 tail_content = None
1024 if extpath is not None:
1025 try:
1026 appPath = f'{extpath}/{conventions.extension_file_path(name)}'
1027 appfp = open(appPath, 'r', encoding='utf-8')
1028 appbody = appfp.read()
1029 appfp.close()
1030
1031 # Transform internal links to crosslinks
1032 specURL = conventions.specURL()
1033 appbody = xrefRewrite(appbody, specURL)
1034 except FileNotFoundError:
1035 print('Cannot find extension appendix for', name)
1036 logWarn(f'Cannot find extension appendix for {name}')
1037
1038 # Fall through to autogenerated page
1039 extpath = None
1040 appbody = None

Callers 1

genRef.pyFile · 0.85

Calls 13

logWarnFunction · 0.90
logDiagFunction · 0.90
xrefRewriteFunction · 0.85
makeExtensionIncludeFunction · 0.85
refPageShellFunction · 0.85
refPageTailFunction · 0.85
seeAlsoListFunction · 0.85
addMethod · 0.80
getMethod · 0.45
extension_file_pathMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected