Skip to content

Commit 2ff888f

Browse files
committed
refactor: improve documentation link generation for capabilities
1 parent 10ca810 commit 2ff888f

File tree

2 files changed

+46
-20
lines changed

2 files changed

+46
-20
lines changed

docs/website/tools/constants.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,31 @@
2929
CAPABILITIES_TABLE_HEADER = "| Feature | Value | More |\n"
3030

3131
SELECTED_CAPABILITIES_ATTRIBUTES = {
32-
"preferred_loader_file_format", # /docs/dlt-ecosystem/file-formats
33-
"supported_loader_file_formats", # /docs/dlt-ecosystem/file-formats
34-
"preferred_staging_file_format", # /docs/dlt-ecosystem/file-formats
35-
"supported_staging_file_formats", # /docs/devel/dlt-ecosystem/file-formats
36-
"has_case_sensitive_identifiers", # /docs/general-usage/naming-convention#case-sensitive-and-insensitive-destinations
37-
"supported_merge_strategies", # /docs/general-usage/merge-loading#merge-strategies
38-
"supported_replace_strategies", # /docs/general-usage/full-loading#the-truncate-and-insert-strategy
39-
"supports_tz_aware_datetime", # /docs/general-usage/schema#handling-of-timestamp-and-time-zones
40-
"supports_naive_datetime", # /docs/general-usage/schema#handling-of-timestamp-and-time-zones
41-
"sqlglot_dialect", # /docs/general-usage/dataset-access/dataset
42-
"preferred_table_format", # /docs/dlt-ecosystem/table-formats
43-
"supported_table_formats", # /docs/dlt-ecosystem/table-formats
32+
"preferred_loader_file_format",
33+
"supported_loader_file_formats",
34+
"preferred_staging_file_format",
35+
"supported_staging_file_formats",
36+
"has_case_sensitive_identifiers",
37+
"supported_merge_strategies",
38+
"supported_replace_strategies",
39+
"supports_tz_aware_datetime",
40+
"supports_naive_datetime",
41+
"sqlglot_dialect",
42+
"preferred_table_format",
43+
"supported_table_formats",
4444
}
4545

4646
CAPABILITIES_DOC_LINK_PATTERNS = [
47-
("_formats", "../file-formats/"),
48-
("_strategies", "../../general-usage/merge-loading#merge-strategies"),
47+
("table", "../table-formats/"),
48+
("file_format", "../file-formats/"),
49+
("merge", "../../general-usage/merge-loading#merge-strategies"),
50+
("replace", "../../general-usage/full-loading#the-truncate-and-insert-strategy"),
51+
("time", "../../general-usage/schema#handling-of-timestamp-and-time-zones"),
52+
("dialect", "../../general-usage/dataset-access/dataset"),
53+
(
54+
"identifier",
55+
"../../general-usage/naming-convention#case-sensitive-and-insensitive-destinations",
56+
),
4957
]
5058

5159
CAPABILITIES_DATA_TYPES_DOC_LINK = "[Data types](../../general-usage/schema#data-types)"

docs/website/tools/preprocess_destination_capabilities.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,33 @@ def _format_value(value: Any) -> str:
7474

7575
def _generate_doc_link(attr_name: str) -> str:
7676
"""Generate documentation link based on attribute name pattern."""
77-
for pattern, link in CAPABILITIES_DOC_LINK_PATTERNS:
78-
if attr_name.endswith(pattern):
79-
section_name = (
80-
link.strip("/").split("/")[-1].split("#")[0].replace("-", " ").capitalize()
81-
)
82-
return f"[{section_name}]({link})"
77+
lower = attr_name.lower()
78+
for key, link in CAPABILITIES_DOC_LINK_PATTERNS:
79+
if key in lower:
80+
return _format_doc_link_for_key(key, link)
81+
82+
# Fallback to data types link when nothing matches
8383
return CAPABILITIES_DATA_TYPES_DOC_LINK
8484

8585

86+
def _format_doc_link_for_key(key: str, link: str) -> str:
87+
"""Format the markdown link for a capability mapping key and link.
88+
89+
Centralizes any human-friendly label overrides.
90+
"""
91+
if key == "merge":
92+
return f"[Merge strategy]({link})"
93+
if key == "replace":
94+
return f"[Truncate-and-insert strategy]({link})"
95+
if key == "time":
96+
return f"[Timestamps and Timezones]({link})"
97+
if key == "dialect":
98+
return f"[Dataset access]({link})"
99+
100+
section_name = link.strip("/").split("/")[-1].split("#")[0].replace("-", " ").capitalize()
101+
return f"[{section_name}]({link})"
102+
103+
86104
def _is_relevant_capability(attr_name: str, value: Any) -> bool:
87105
"""Check if capability should be included in table."""
88106
if value is None or attr_name not in SELECTED_CAPABILITIES_ATTRIBUTES:

0 commit comments

Comments
 (0)