aboutsummaryrefslogtreecommitdiffhomepage
path: root/registry/spec_tools/conventions.py
diff options
context:
space:
mode:
authorJon Leech <[email protected]>2023-11-26 21:52:30 -0800
committerJon Leech <[email protected]>2023-11-26 21:54:32 -0800
commit9d27c893cdfc8d96bc8ad5f6f4d88743f958305e (patch)
tree4c64138e76f1149bd484cfaccf9f7e9d21cdae48 /registry/spec_tools/conventions.py
parent7d92fe7b687eb92dafb5d344d1f4c817780cd3ce (diff)
downloadVulkan-Headers-9d27c893cdfc8d96bc8ad5f6f4d88743f958305e.tar.gz
Vulkan-Headers-9d27c893cdfc8d96bc8ad5f6f4d88743f958305e.zip
Update for Vulkan-Docs 1.3.271v1.3.271
Diffstat (limited to 'registry/spec_tools/conventions.py')
-rw-r--r--registry/spec_tools/conventions.py83
1 files changed, 79 insertions, 4 deletions
diff --git a/registry/spec_tools/conventions.py b/registry/spec_tools/conventions.py
index 00d2b81..9118fea 100644
--- a/registry/spec_tools/conventions.py
+++ b/registry/spec_tools/conventions.py
@@ -32,12 +32,12 @@ TYPES_KNOWN_ALWAYS_VALID = set(('char',
))
# Split an extension name into vendor ID and name portions
-EXT_NAME_DECOMPOSE_RE = re.compile(r'[A-Z]+_(?P<vendor>[A-Z]+)_(?P<name>[\w_]+)')
+EXT_NAME_DECOMPOSE_RE = re.compile(r'(?P<prefix>[A-Za-z]+)_(?P<vendor>[A-Za-z]+)_(?P<name>[\w_]+)')
# Match an API version name.
+# Match object includes API prefix, major, and minor version numbers.
# This could be refined further for specific APIs.
-API_VERSION_NAME_RE = re.compile(r'[A-Z]+_VERSION_[0-9]')
-
+API_VERSION_NAME_RE = re.compile(r'(?P<apivariant>[A-Za-z]+)_VERSION_(?P<major>[0-9]+)_(?P<minor>[0-9]+)')
class ProseListFormats(Enum):
"""A connective, possibly with a quantifier."""
@@ -80,10 +80,39 @@ class ConventionsBase(abc.ABC):
self._command_prefix = None
self._type_prefix = None
+ def formatVersionOrExtension(self, name):
+ """Mark up an API version or extension name as a link in the spec."""
+
+ # Is this a version name?
+ match = API_VERSION_NAME_RE.match(name)
+ if match is not None:
+ return self.formatVersion(name,
+ match.group('apivariant'),
+ match.group('major'),
+ match.group('minor'))
+ else:
+ # If not, assumed to be an extension name. Might be worth checking.
+ return self.formatExtension(name)
+
+ def formatVersion(self, name, apivariant, major, minor):
+ """Mark up an API version name as a link in the spec."""
+ return '`<<{}>>`'.format(name)
+
def formatExtension(self, name):
- """Mark up an extension name as a link the spec."""
+ """Mark up an extension name as a link in the spec."""
return '`<<{}>>`'.format(name)
+ def formatSPIRVlink(self, name):
+ """Mark up a SPIR-V extension name as an external link in the spec.
+ Since these are external links, the formatting probably will be
+ the same for all APIs creating such links, so long as they use
+ the asciidoctor {spirv} attribute for the base path to the SPIR-V
+ extensions."""
+
+ (vendor, _) = self.extension_name_split(name)
+
+ return f'{{spirv}}/{vendor}/{name}.html[{name}]'
+
@property
@abc.abstractmethod
def null(self):
@@ -261,6 +290,42 @@ class ConventionsBase(abc.ABC):
raise NotImplementedError
@property
+ def extension_name_prefix(self):
+ """Return extension name prefix.
+
+ Typically two uppercase letters followed by an underscore.
+
+ Assumed to be the same as api_prefix, but some APIs use different
+ case conventions."""
+
+ return self.api_prefix
+
+ @property
+ def write_contacts(self):
+ """Return whether contact list should be written to extension appendices"""
+ return False
+
+ @property
+ def write_extension_type(self):
+ """Return whether extension type should be written to extension appendices"""
+ return True
+
+ @property
+ def write_extension_number(self):
+ """Return whether extension number should be written to extension appendices"""
+ return True
+
+ @property
+ def write_extension_revision(self):
+ """Return whether extension revision number should be written to extension appendices"""
+ return True
+
+ @property
+ def write_refpage_include(self):
+ """Return whether refpage include should be written to extension appendices"""
+ return True
+
+ @property
def api_version_prefix(self):
"""Return API core version token prefix.
@@ -375,6 +440,16 @@ class ConventionsBase(abc.ABC):
documentation includes."""
return False
+ def extension_name_split(self, name):
+ """Split an extension name, returning (vendor, rest of name).
+ The API prefix of the name is ignored."""
+
+ match = EXT_NAME_DECOMPOSE_RE.match(name)
+ vendor = match.group('vendor')
+ bare_name = match.group('name')
+
+ return (vendor, bare_name)
+
@abc.abstractmethod
def extension_file_path(self, name):
"""Return file path to an extension appendix relative to a directory