Skip to content

Commit 8052a79

Browse files
committed
Add check scripts
1 parent 1fce5b7 commit 8052a79

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

scripts/check-code-samples.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env python3
2+
import yaml
3+
import sys
4+
5+
# Validate input arguments
6+
if len(sys.argv) != 3:
7+
print("Usage: python compare_yaml_keys.py <your.yaml> <reference.yaml>")
8+
sys.exit(1)
9+
10+
your_path = sys.argv[1]
11+
reference_path = sys.argv[2]
12+
13+
# Configured ignore/include lists
14+
# Gotten from https://github.com/meilisearch/integration-automations/blob/main/code-samples-checkers/missing-cs-in-integration.sh
15+
NOT_NEEDED_IN_INTEGRATION = {
16+
'tenant_token_guide_search_no_sdk_1',
17+
'updating_guide_check_version_new_authorization_header',
18+
'updating_guide_check_version_old_authorization_header',
19+
'updating_guide_get_displayed_attributes_old_authorization_header',
20+
'updating_guide_reset_displayed_attributes_old_authorization_header',
21+
'updating_guide_create_dump',
22+
}
23+
24+
NOT_IN_DOCS_CODE_SAMPLES_FILE = {
25+
'tenant_token_guide_generate_sdk_1',
26+
'tenant_token_guide_search_sdk_1',
27+
'landing_getting_started_1',
28+
}
29+
30+
# Load YAML files
31+
with open(your_path) as f1, open(reference_path) as f2:
32+
your_yaml = yaml.safe_load(f1) or {}
33+
ref_yaml = yaml.safe_load(f2) or {}
34+
35+
# Collect keys
36+
your_keys = set(your_yaml.keys())
37+
ref_keys = set(ref_yaml.keys())
38+
39+
# Print results
40+
print("❌ Incorrect:")
41+
print("\n".join(sorted(your_keys - ref_keys - NOT_IN_DOCS_CODE_SAMPLES_FILE)))
42+
43+
print("\n🔁 Missing:")
44+
print("\n".join(sorted(ref_keys - your_keys - NOT_NEEDED_IN_INTEGRATION)))

scripts/check-code-samples.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
python3 -m venv .venv
2+
3+
source .venv/bin/activate
4+
5+
pip install pyyaml
6+
7+
wget https://raw.githubusercontent.com/meilisearch/documentation/main/.code-samples.meilisearch.yaml -O reference.yaml
8+
9+
python3 scripts/check-code-samples.py .code-samples.meilisearch.yaml reference.yaml
10+
11+
rm reference.yaml

0 commit comments

Comments
 (0)