Skip to content

Commit 1b01fa5

Browse files
committed
Keep every variant of a page definition in the catalogue
A page that defines one name several times (per cloud, per stage kind, per authentication method) kept only its last definition. Each variant is now its own definition, named by the page qualifier when the page gives one, e.g. "cloudProviderParams (for Amazon S3)", else "#2", "#3", so every id stays <source>::<name>. A form's uses lists every variant of a name its grammar refers to. Only ddl, dml and security_admin change; no form grammar changes.
1 parent a55b27e commit 1b01fa5

6 files changed

Lines changed: 308 additions & 51 deletions

File tree

‎coverage/syntax/catalogue/ddl.toml‎

Lines changed: 175 additions & 24 deletions
Large diffs are not rendered by default.

‎coverage/syntax/catalogue/dml.toml‎

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ grammar = [
3838
grammar_sha256 = "7257ab1eb586ec61c4dc5aec2fb00990ffd2b23a2854602bba1b1517c88a2ed3"
3939
uses = [
4040
"copyOptions",
41-
"externalLocation",
41+
"externalLocation (for Amazon S3)",
42+
"externalLocation (for Google Cloud Storage)",
43+
"externalLocation (for Microsoft Azure)",
4244
"externalStage",
4345
"formatTypeOptions",
4446
"internalStage",
@@ -57,7 +59,9 @@ grammar = [
5759
grammar_sha256 = "140ad7e910d61741cf56f9bdd0690b090ecedfb6e5d03d064049f1093206ad11"
5860
uses = [
5961
"copyOptions",
60-
"externalLocation",
62+
"externalLocation (for Amazon S3)",
63+
"externalLocation (for Google Cloud Storage)",
64+
"externalLocation (for Microsoft Azure)",
6165
"externalStage",
6266
"formatTypeOptions",
6367
"internalStage",
@@ -293,9 +297,21 @@ name = "copyOptions"
293297
grammar = "copyOptions ::= OVERWRITE = TRUE | FALSE SINGLE = TRUE | FALSE MAX_FILE_SIZE = <num> INCLUDE_QUERY_ID = TRUE | FALSE DETAILED_OUTPUT = TRUE | FALSE"
294298

295299
[[definition]]
296-
id = "doc.sql.copy-into-location::externalLocation"
300+
id = "doc.sql.copy-into-location::externalLocation (for Amazon S3)"
297301
source = "doc.sql.copy-into-location"
298-
name = "externalLocation"
302+
name = "externalLocation (for Amazon S3)"
303+
grammar = "externalLocation (for Amazon S3) ::= '<protocol>://<bucket>[/<path>]' [ { STORAGE_INTEGRATION = <integration_name> } | { CREDENTIALS = ( { { AWS_KEY_ID = '<string>' AWS_SECRET_KEY = '<string>' [ AWS_TOKEN = '<string>' ] } } ) } ] [ ENCRYPTION = ( [ TYPE = 'AWS_CSE' ] [ MASTER_KEY = '<string>' ] | [ TYPE = 'AWS_SSE_S3' ] | [ TYPE = 'AWS_SSE_KMS' [ KMS_KEY_ID = '<string>' ] ] | [ TYPE = 'NONE' ] ) ]"
304+
305+
[[definition]]
306+
id = "doc.sql.copy-into-location::externalLocation (for Google Cloud Storage)"
307+
source = "doc.sql.copy-into-location"
308+
name = "externalLocation (for Google Cloud Storage)"
309+
grammar = "externalLocation (for Google Cloud Storage) ::= 'gcs://<bucket>[/<path>]' [ STORAGE_INTEGRATION = <integration_name> ] [ ENCRYPTION = ( [ TYPE = 'GCS_SSE_KMS' ] [ KMS_KEY_ID = '<string>' ] | [ TYPE = 'NONE' ] ) ]"
310+
311+
[[definition]]
312+
id = "doc.sql.copy-into-location::externalLocation (for Microsoft Azure)"
313+
source = "doc.sql.copy-into-location"
314+
name = "externalLocation (for Microsoft Azure)"
299315
grammar = "externalLocation (for Microsoft Azure) ::= 'azure://<account>.blob.core.windows.net/<container>[/<path>]' [ { STORAGE_INTEGRATION = <integration_name> } | { CREDENTIALS = ( [ AZURE_SAS_TOKEN = '<string>' ] ) } ] [ ENCRYPTION = ( [ TYPE = { 'AZURE_CSE' | 'NONE' } ] [ MASTER_KEY = '<string>' ] ) ]"
300316

301317
[[definition]]
@@ -323,9 +339,21 @@ name = "copyOptions"
323339
grammar = "copyOptions ::= CLUSTER_AT_INGEST_TIME = TRUE | FALSE ENFORCE_LENGTH = TRUE | FALSE FORCE = TRUE | FALSE INCLUDE_METADATA = ( <column_name> = METADATA$<field> [ , <column_name> = METADATA${field} ... ] ) LOAD_MODE = { FULL_INGEST | ADD_FILES_COPY } LOAD_UNCERTAIN_FILES = TRUE | FALSE MATCH_BY_COLUMN_NAME = CASE_SENSITIVE | CASE_INSENSITIVE | NONE ON_ERROR = { CONTINUE | SKIP_FILE | SKIP_FILE_<num> | 'SKIP_FILE_<num>%' | ABORT_STATEMENT } PURGE = TRUE | FALSE RETURN_FAILED_ONLY = TRUE | FALSE SIZE_LIMIT = <num> TRUNCATECOLUMNS = TRUE | FALSE"
324340

325341
[[definition]]
326-
id = "doc.sql.copy-into-table::externalLocation"
342+
id = "doc.sql.copy-into-table::externalLocation (for Amazon S3)"
343+
source = "doc.sql.copy-into-table"
344+
name = "externalLocation (for Amazon S3)"
345+
grammar = "externalLocation (for Amazon S3) ::= '<protocol>://<bucket>[/<path>]' [ { STORAGE_INTEGRATION = <integration_name> } | { CREDENTIALS = ( { { AWS_KEY_ID = '<string>' AWS_SECRET_KEY = '<string>' [ AWS_TOKEN = '<string>' ] } } ) } ] [ ENCRYPTION = ( [ TYPE = 'AWS_CSE' ] [ MASTER_KEY = '<string>' ] | [ TYPE = 'AWS_SSE_S3' ] | [ TYPE = 'AWS_SSE_KMS' [ KMS_KEY_ID = '<string>' ] ] | [ TYPE = 'NONE' ] ) ]"
346+
347+
[[definition]]
348+
id = "doc.sql.copy-into-table::externalLocation (for Google Cloud Storage)"
349+
source = "doc.sql.copy-into-table"
350+
name = "externalLocation (for Google Cloud Storage)"
351+
grammar = "externalLocation (for Google Cloud Storage) ::= 'gcs://<bucket>[/<path>]' [ STORAGE_INTEGRATION = <integration_name> ] [ ENCRYPTION = ( [ TYPE = 'GCS_SSE_KMS' ] [ KMS_KEY_ID = '<string>' ] | [ TYPE = 'NONE' ] ) ]"
352+
353+
[[definition]]
354+
id = "doc.sql.copy-into-table::externalLocation (for Microsoft Azure)"
327355
source = "doc.sql.copy-into-table"
328-
name = "externalLocation"
356+
name = "externalLocation (for Microsoft Azure)"
329357
grammar = "externalLocation (for Microsoft Azure) ::= 'azure://<account>.blob.core.windows.net/<container>[/<path>]' [ { STORAGE_INTEGRATION = <integration_name> } | { CREDENTIALS = ( [ AZURE_SAS_TOKEN = '<string>' ] ) } ] [ ENCRYPTION = ( [ TYPE = { 'AZURE_CSE' | 'NONE' } ] [ MASTER_KEY = '<string>' ] ) ]"
330358

331359
[[definition]]

‎coverage/syntax/catalogue/security_admin.toml‎

Lines changed: 71 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,8 @@ grammar = [
718718
]
719719
grammar_sha256 = "1d0be5b4bd3a60768db38fe67171df8efde32d2e9c9e900bedc413cd5ff52901"
720720
uses = [
721-
"restAuthenticationParams",
721+
"restAuthenticationParams (for Bearer token)",
722+
"restAuthenticationParams (for OAuth)",
722723
]
723724
status = "catalogued"
724725

@@ -4087,7 +4088,8 @@ grammar = [
40874088
]
40884089
grammar_sha256 = "7feaa2b60000c01936b87554c174ccee027a85997ba5c9cc2cf1d5c00f7e9513"
40894090
uses = [
4090-
"cloudProviderParams",
4091+
"cloudProviderParams (for Amazon S3)",
4092+
"cloudProviderParams (for Microsoft Azure)",
40914093
]
40924094
status = "catalogued"
40934095

@@ -4847,7 +4849,9 @@ grammar = [
48474849
]
48484850
grammar_sha256 = "c8baae332ee125c9b814494c3ba63bec87eb66e31e6ab093fb033b7f6ad54d69"
48494851
uses = [
4850-
"restAuthenticationParams",
4852+
"restAuthenticationParams (for Bearer token)",
4853+
"restAuthenticationParams (for OAuth)",
4854+
"restAuthenticationParams (for OIDC)",
48514855
]
48524856
status = "catalogued"
48534857

@@ -4914,7 +4918,9 @@ grammar = [
49144918
]
49154919
grammar_sha256 = "08f82964f355a3508b1181b57268b2ea4f9805ea74fbe82b0055a90fca1e5518"
49164920
uses = [
4917-
"restAuthenticationParams",
4921+
"restAuthenticationParams (for Bearer token)",
4922+
"restAuthenticationParams (for OAuth)",
4923+
"restAuthenticationParams (for SigV4)",
49184924
"restConfigParams",
49194925
]
49204926
status = "catalogued"
@@ -5975,7 +5981,9 @@ grammar = [
59755981
]
59765982
grammar_sha256 = "7135ba3340406c714d3ffe522c0fab05e57d172dc9d0bf23af9bb95f7d5d3736"
59775983
uses = [
5978-
"cloudProviderParams",
5984+
"cloudProviderParams (for Amazon S3)",
5985+
"cloudProviderParams (for Google Cloud Storage)",
5986+
"cloudProviderParams (for Microsoft Azure)",
59795987
]
59805988
status = "catalogued"
59815989

@@ -8487,11 +8495,17 @@ name = "sessionParams"
84878495
grammar = "sessionParams ::= ABORT_DETACHED_QUERY = TRUE | FALSE AUTOCOMMIT = TRUE | FALSE BINARY_INPUT_FORMAT = <string> BINARY_OUTPUT_FORMAT = <string> DATE_INPUT_FORMAT = <string> DATE_OUTPUT_FORMAT = <string> DEFAULT_NULL_ORDERING = <string> ENABLE_GET_DDL_USE_DATA_TYPE_ALIAS = TRUE | FALSE ERROR_ON_NONDETERMINISTIC_MERGE = TRUE | FALSE ERROR_ON_NONDETERMINISTIC_UPDATE = TRUE | FALSE JSON_INDENT = <num> LOCK_TIMEOUT = <num> OPT_OUT_ERROR_LOGGING = TRUE | FALSE QUERY_TAG = <string> ROWS_PER_RESULTSET = <num> S3_STAGE_VPCE_DNS_NAME = <string> SEARCH_PATH = <string> SIMULATED_DATA_SHARING_CONSUMER = <string> STATEMENT_TIMEOUT_IN_SECONDS = <num> STRICT_JSON_OUTPUT = TRUE | FALSE TIMESTAMP_DAY_IS_ALWAYS_24H = TRUE | FALSE TIMESTAMP_INPUT_FORMAT = <string> TIMESTAMP_LTZ_OUTPUT_FORMAT = <string> TIMESTAMP_NTZ_OUTPUT_FORMAT = <string> TIMESTAMP_OUTPUT_FORMAT = <string> TIMESTAMP_TYPE_MAPPING = <string> TIMESTAMP_TZ_OUTPUT_FORMAT = <string> TIMEZONE = <string> TIME_INPUT_FORMAT = <string> TIME_OUTPUT_FORMAT = <string> TRANSACTION_DEFAULT_ISOLATION_LEVEL = <string> TWO_DIGIT_CENTURY_START = <num> UNSUPPORTED_DDL_ACTION = <string> USE_CACHED_RESULT = TRUE | FALSE WEEK_OF_YEAR_POLICY = <num> WEEK_START = <num>"
84888496

84898497
[[definition]]
8490-
id = "doc.sql.alter-catalog-integration::restAuthenticationParams"
8498+
id = "doc.sql.alter-catalog-integration::restAuthenticationParams (for Bearer token)"
84918499
source = "doc.sql.alter-catalog-integration"
8492-
name = "restAuthenticationParams"
8500+
name = "restAuthenticationParams (for Bearer token)"
84938501
grammar = "restAuthenticationParams (for Bearer token) ::= BEARER_TOKEN = '<bearer_token>'"
84948502

8503+
[[definition]]
8504+
id = "doc.sql.alter-catalog-integration::restAuthenticationParams (for OAuth)"
8505+
source = "doc.sql.alter-catalog-integration"
8506+
name = "restAuthenticationParams (for OAuth)"
8507+
grammar = "restAuthenticationParams (for OAuth) ::= OAUTH_CLIENT_SECRET = '<oauth_client_secret>'"
8508+
84958509
[[definition]]
84968510
id = "doc.sql.alter-organization-user::objectProperties"
84978511
source = "doc.sql.alter-organization-user"
@@ -8505,9 +8519,15 @@ name = "triggerDefinition"
85058519
grammar = "triggerDefinition ::= ON <threshold> PERCENT DO { SUSPEND | SUSPEND_IMMEDIATE | NOTIFY }"
85068520

85078521
[[definition]]
8508-
id = "doc.sql.alter-storage-integration::cloudProviderParams"
8522+
id = "doc.sql.alter-storage-integration::cloudProviderParams (for Amazon S3)"
8523+
source = "doc.sql.alter-storage-integration"
8524+
name = "cloudProviderParams (for Amazon S3)"
8525+
grammar = "cloudProviderParams (for Amazon S3) ::= STORAGE_AWS_ROLE_ARN = '<iam_role>' [ STORAGE_AWS_OBJECT_ACL = 'bucket-owner-full-control' ] [ STORAGE_AWS_EXTERNAL_ID = '<external_id>' ] [ USE_PRIVATELINK_ENDPOINT = { TRUE | FALSE } ]"
8526+
8527+
[[definition]]
8528+
id = "doc.sql.alter-storage-integration::cloudProviderParams (for Microsoft Azure)"
85098529
source = "doc.sql.alter-storage-integration"
8510-
name = "cloudProviderParams"
8530+
name = "cloudProviderParams (for Microsoft Azure)"
85118531
grammar = "cloudProviderParams (for Microsoft Azure) ::= AZURE_TENANT_ID = '<tenant_id>' [ USE_PRIVATELINK_ENDPOINT = { TRUE | FALSE } ]"
85128532

85138533
[[definition]]
@@ -8535,15 +8555,39 @@ name = "sessionParams"
85358555
grammar = "sessionParams ::= ABORT_DETACHED_QUERY = TRUE | FALSE AUTOCOMMIT = TRUE | FALSE BINARY_INPUT_FORMAT = <string> BINARY_OUTPUT_FORMAT = <string> DATE_INPUT_FORMAT = <string> DATE_OUTPUT_FORMAT = <string> DEFAULT_NULL_ORDERING = <string> ENABLE_GET_DDL_USE_DATA_TYPE_ALIAS = TRUE | FALSE ENABLE_NOTEBOOK_CREATION_IN_PERSONAL_DB = TRUE | FALSE ERROR_ON_NONDETERMINISTIC_MERGE = TRUE | FALSE ERROR_ON_NONDETERMINISTIC_UPDATE = TRUE | FALSE JSON_INDENT = <num> LOCK_TIMEOUT = <num> OPT_OUT_ERROR_LOGGING = TRUE | FALSE QUERY_TAG = <string> ROWS_PER_RESULTSET = <num> S3_STAGE_VPCE_DNS_NAME = <string> SEARCH_PATH = <string> SIMULATED_DATA_SHARING_CONSUMER = <string> STATEMENT_TIMEOUT_IN_SECONDS = <num> STRICT_JSON_OUTPUT = TRUE | FALSE TIMESTAMP_DAY_IS_ALWAYS_24H = TRUE | FALSE TIMESTAMP_INPUT_FORMAT = <string> TIMESTAMP_LTZ_OUTPUT_FORMAT = <string> TIMESTAMP_NTZ_OUTPUT_FORMAT = <string> TIMESTAMP_OUTPUT_FORMAT = <string> TIMESTAMP_TYPE_MAPPING = <string> TIMESTAMP_TZ_OUTPUT_FORMAT = <string> TIMEZONE = <string> TIME_INPUT_FORMAT = <string> TIME_OUTPUT_FORMAT = <string> TRANSACTION_DEFAULT_ISOLATION_LEVEL = <string> TWO_DIGIT_CENTURY_START = <num> UNSUPPORTED_DDL_ACTION = <string> USE_CACHED_RESULT = TRUE | FALSE WEEK_OF_YEAR_POLICY = <num> WEEK_START = <num>"
85368556

85378557
[[definition]]
8538-
id = "doc.sql.create-catalog-integration-delta-sharing::restAuthenticationParams"
8558+
id = "doc.sql.create-catalog-integration-delta-sharing::restAuthenticationParams (for Bearer token)"
85398559
source = "doc.sql.create-catalog-integration-delta-sharing"
8540-
name = "restAuthenticationParams"
8560+
name = "restAuthenticationParams (for Bearer token)"
8561+
grammar = "restAuthenticationParams (for Bearer token) ::= TYPE = BEARER BEARER_TOKEN = '<bearer_token>'"
8562+
8563+
[[definition]]
8564+
id = "doc.sql.create-catalog-integration-delta-sharing::restAuthenticationParams (for OAuth)"
8565+
source = "doc.sql.create-catalog-integration-delta-sharing"
8566+
name = "restAuthenticationParams (for OAuth)"
85418567
grammar = "restAuthenticationParams (for OAuth) ::= TYPE = OAUTH [ OAUTH_API_TYPE = { PUBLIC | PRIVATE } ] OAUTH_CLIENT_ID = '<oauth_client_id>' OAUTH_CLIENT_SECRET = '<oauth_client_secret>' OAUTH_TOKEN_URI = 'https://<token_server_uri>'"
85428568

85438569
[[definition]]
8544-
id = "doc.sql.create-catalog-integration-rest::restAuthenticationParams"
8570+
id = "doc.sql.create-catalog-integration-delta-sharing::restAuthenticationParams (for OIDC)"
8571+
source = "doc.sql.create-catalog-integration-delta-sharing"
8572+
name = "restAuthenticationParams (for OIDC)"
8573+
grammar = "restAuthenticationParams (for OIDC) ::= TYPE = OIDC OIDC_AUDIENCE = '<audience>'"
8574+
8575+
[[definition]]
8576+
id = "doc.sql.create-catalog-integration-rest::restAuthenticationParams (for Bearer token)"
85458577
source = "doc.sql.create-catalog-integration-rest"
8546-
name = "restAuthenticationParams"
8578+
name = "restAuthenticationParams (for Bearer token)"
8579+
grammar = "restAuthenticationParams (for Bearer token) ::= TYPE = BEARER BEARER_TOKEN = '<bearer_token>'"
8580+
8581+
[[definition]]
8582+
id = "doc.sql.create-catalog-integration-rest::restAuthenticationParams (for OAuth)"
8583+
source = "doc.sql.create-catalog-integration-rest"
8584+
name = "restAuthenticationParams (for OAuth)"
8585+
grammar = "restAuthenticationParams (for OAuth) ::= TYPE = OAUTH [ OAUTH_API_TYPE = { PUBLIC | PRIVATE } ] [ OAUTH_TOKEN_URI = 'https://<token_server_uri>' ] OAUTH_CLIENT_ID = '<oauth_client_id>' OAUTH_CLIENT_SECRET = '<oauth_client_secret>' OAUTH_ALLOWED_SCOPES = ('<scope_1>', '<scope_2>')"
8586+
8587+
[[definition]]
8588+
id = "doc.sql.create-catalog-integration-rest::restAuthenticationParams (for SigV4)"
8589+
source = "doc.sql.create-catalog-integration-rest"
8590+
name = "restAuthenticationParams (for SigV4)"
85478591
grammar = "restAuthenticationParams (for SigV4) ::= TYPE = SIGV4 SIGV4_IAM_ROLE = '<iam_role_arn>' [ SIGV4_SIGNING_REGION = '<region>' ] [ SIGV4_EXTERNAL_ID = '<external_id>' ]"
85488592

85498593
[[definition]]
@@ -8571,9 +8615,21 @@ name = "triggerDefinition"
85718615
grammar = "triggerDefinition ::= ON <threshold> PERCENT DO { SUSPEND | SUSPEND_IMMEDIATE | NOTIFY }"
85728616

85738617
[[definition]]
8574-
id = "doc.sql.create-storage-integration::cloudProviderParams"
8618+
id = "doc.sql.create-storage-integration::cloudProviderParams (for Amazon S3)"
8619+
source = "doc.sql.create-storage-integration"
8620+
name = "cloudProviderParams (for Amazon S3)"
8621+
grammar = "cloudProviderParams (for Amazon S3) ::= STORAGE_PROVIDER = 'S3' STORAGE_AWS_ROLE_ARN = '<iam_role>' [ STORAGE_AWS_EXTERNAL_ID = '<external_id>' ] [ STORAGE_AWS_OBJECT_ACL = 'bucket-owner-full-control' ] [ USE_PRIVATELINK_ENDPOINT = { TRUE | FALSE } ]"
8622+
8623+
[[definition]]
8624+
id = "doc.sql.create-storage-integration::cloudProviderParams (for Google Cloud Storage)"
8625+
source = "doc.sql.create-storage-integration"
8626+
name = "cloudProviderParams (for Google Cloud Storage)"
8627+
grammar = "cloudProviderParams (for Google Cloud Storage) ::= STORAGE_PROVIDER = 'GCS'"
8628+
8629+
[[definition]]
8630+
id = "doc.sql.create-storage-integration::cloudProviderParams (for Microsoft Azure)"
85758631
source = "doc.sql.create-storage-integration"
8576-
name = "cloudProviderParams"
8632+
name = "cloudProviderParams (for Microsoft Azure)"
85778633
grammar = "cloudProviderParams (for Microsoft Azure) ::= STORAGE_PROVIDER = 'AZURE' AZURE_TENANT_ID = '<tenant_id>' [ USE_PRIVATELINK_ENDPOINT = { TRUE | FALSE } ]"
85788634

85798635
[[definition]]

‎scripts/syntax_catalogue/_helpers/catalogue.py‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import gzip
66
import json
7+
import re
78
import tomllib
89
from pathlib import Path
910

@@ -25,6 +26,7 @@
2526
DECISION_HAND,
2627
DECISION_MERGED_HEADINGS,
2728
DECISION_PROSE,
29+
DEFINITION_QUALIFIER,
2830
FAMILIES,
2931
FORMAT_HTML,
3032
FORMAT_MARKDOWN,
@@ -138,14 +140,31 @@ def page_groups(
138140
)
139141
prose, prose_decisions = prose_groups(page=page, hand_list=hand_list)
140142
hand_decisions: set[str] = {DECISION_HAND.format(basis=form.basis) for form in hand}
141-
definitions: dict[str, str] = {p.name: p.grammar for p in prods if p.kind == KIND_DEFINITION}
143+
definitions: dict[str, str] = {}
144+
for prod in prods:
145+
if prod.kind == KIND_DEFINITION:
146+
definitions[definition_key(name=prod.name, grammar=prod.grammar, taken=definitions)] = (
147+
prod.grammar
148+
)
142149
return PageResult(
143150
groups=groups + prose + hand_list,
144151
definitions=list(definitions.items()),
145152
decisions=decisions | grouping | prose_decisions | hand_decisions,
146153
)
147154

148155

156+
def definition_key(*, name: str, grammar: str, taken: dict[str, str]) -> str:
157+
"""The name, with its `(for ...)` qualifier when the page gives one, unique on the page."""
158+
qualifier: re.Match[str] | None = DEFINITION_QUALIFIER.match(grammar)
159+
key: str = f"{name} {qualifier[1]}" if qualifier else name
160+
number: int = 1
161+
unique: str = key
162+
while unique in taken:
163+
number += 1
164+
unique = f"{key} #{number}"
165+
return unique
166+
167+
149168
def source_row(
150169
*, record: PageSource, page: Page, family: str | None, status: str, decisions: set[str]
151170
) -> Row:
@@ -205,10 +224,10 @@ def build_catalogue(*, cache: Path, out: Path, hand_path: Path) -> Catalogue:
205224
if family is None or not result.groups:
206225
continue
207226
catalogue.definitions[family].extend(
208-
{"id": f"{sid}::{name}", "source": sid, "name": name, "grammar": grammar}
209-
for name, grammar in result.definitions
227+
{"id": f"{sid}::{key}", "source": sid, "name": key, "grammar": grammar}
228+
for key, grammar in result.definitions
210229
)
211-
names: tuple[str, ...] = tuple(name for name, _ in result.definitions)
230+
names: tuple[str, ...] = tuple(k for k, _ in result.definitions)
212231
context: PageContext = PageContext(
213232
f"sf.{family}.{page_slug(record.path)}", family, sid, names
214233
)

‎scripts/syntax_catalogue/_helpers/forms.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,5 +250,7 @@ def refers_to(*, name: str, grammars: tuple[str, ...]) -> bool:
250250

251251

252252
def uses(*, definitions: tuple[str, ...], grammars: tuple[str, ...]) -> list[str]:
253-
"""The page's sub-grammar names a form's grammar refers to."""
254-
return sorted(name for name in definitions if refers_to(name=name, grammars=grammars))
253+
"""The page's definitions a form's grammar refers to, every variant of a name it names."""
254+
return sorted(
255+
name for name in definitions if refers_to(name=name.split(" ")[0], grammars=grammars)
256+
)

‎scripts/syntax_catalogue/constants.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
ELISION_LINE: re.Pattern[str] = re.compile(r"^\s*(\[\s*)?\.\.\.(\s*\])?\s*$")
168168
QUOTED_OR_PLACEHOLDER: re.Pattern[str] = re.compile(r"<[^<>]*>|'[^']*'|\"[^\"]*\"")
169169
QUOTED_OR_ANGLE: re.Pattern[str] = re.compile(r"'[^']*'|<[^<>]*>")
170+
DEFINITION_QUALIFIER: re.Pattern[str] = re.compile(r"\S+ (\([^()]*\)) ::=")
170171
SQL_LINE_COMMENT: re.Pattern[str] = re.compile(r"(^|\s)--(?=(?:[^']*'[^']*')*[^']*$).*$")
171172
CALL_START: re.Pattern[str] = re.compile(r"^\s*([A-Za-z_][\w$.]*)\s*\(")
172173
NAME_ALTERNATION: re.Pattern[str] = re.compile(

0 commit comments

Comments
 (0)