Skip to content

Commit fb673db

Browse files
committed
remove exclude rules
1 parent 2c25952 commit fb673db

File tree

1 file changed

+6
-84
lines changed

1 file changed

+6
-84
lines changed

src/scripts/generate_registry_docs.py

Lines changed: 6 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,9 @@
22
import click
33
import yaml
44
import shutil
5-
import re
6-
import json
75
from jinja2 import Environment, FileSystemLoader
86
from pathlib import Path
97

10-
def should_exclude_entry(entry, exclusion_rules):
11-
"""
12-
Check if an entry should be excluded based on the exclusion rules.
13-
14-
Args:
15-
entry (dict): The registry entry to check
16-
exclusion_rules (list): List of exclusion rule dictionaries
17-
18-
Returns:
19-
tuple: (bool, str) - Whether to exclude and the reason if excluded
20-
"""
21-
for rule in exclusion_rules:
22-
pattern = rule['pattern']
23-
case_sensitive = rule.get('case_sensitive', False)
24-
25-
# Convert entry to string for simple checking across all fields
26-
entry_str = json.dumps(entry, ensure_ascii=False)
27-
28-
# Perform the match based on case sensitivity setting
29-
if case_sensitive:
30-
if re.search(pattern, entry_str):
31-
return True, f"Matched rule: {rule['description']}"
32-
else:
33-
if re.search(pattern, entry_str, re.IGNORECASE):
34-
return True, f"Matched rule: {rule['description']}"
35-
36-
return False, ""
378

389
@click.command()
3910
@click.option('--registry-file', default='models.yaml', help='Path to LinkML registry YAML file.')
@@ -42,43 +13,8 @@ def should_exclude_entry(entry, exclusion_rules):
4213
@click.option('--overview-template', default='overview.jinja2', help='Filename of overview template.')
4314
@click.option('--detail-template', default='registry.jinja2', help='Filename of detail template.')
4415
@click.option('--src-docs-dir', default='src/docs', help='Source docs directory containing the registry.md file.')
45-
@click.option('--exclude-config', default=None, help='Path to exclusion rules JSON file. If not provided, default rules will be used.')
46-
def generate_docs(registry_file, output_dir, templates_dir, overview_template, detail_template, src_docs_dir, exclude_config):
16+
def generate_docs(registry_file, output_dir, templates_dir, overview_template, detail_template, src_docs_dir):
4717
"""Generate markdown documentation from LinkML registry data."""
48-
# Setup default exclusion rules
49-
default_exclusion_rules = [
50-
{
51-
"pattern": "not a schema",
52-
"description": "Exclude entries containing 'not a schema'",
53-
"case_sensitive": False
54-
},
55-
{
56-
"pattern": "duplicate",
57-
"description": "Exclude entries containing 'duplicate'",
58-
"case_sensitive": False
59-
},
60-
{
61-
"pattern": "draft",
62-
"description": "Exclude entries marked as 'draft'",
63-
"case_sensitive": False
64-
},
65-
{
66-
"pattern": "not yet public",
67-
"description": "Exclude entries that are not yet public",
68-
"case_sensitive": False
69-
}
70-
]
71-
72-
# Load custom exclusion rules if provided
73-
exclusion_rules = default_exclusion_rules
74-
if exclude_config:
75-
try:
76-
with open(exclude_config, 'r') as f:
77-
exclusion_rules = json.load(f)
78-
print(f"Loaded {len(exclusion_rules)} exclusion rules from {exclude_config}")
79-
except Exception as e:
80-
print(f"Error loading exclusion rules from {exclude_config}: {e}")
81-
print(f"Using default exclusion rules instead.")
8218

8319
# Setup Jinja environment
8420
env = Environment(loader=FileSystemLoader(templates_dir))
@@ -92,21 +28,7 @@ def generate_docs(registry_file, output_dir, templates_dir, overview_template, d
9228
registry_data = yaml.safe_load(f)
9329

9430
# Extract entries from registry
95-
all_entries = registry_data.get('entries', {})
96-
97-
# Filter entries based on exclusion rules
98-
filtered_entries = {}
99-
excluded_count = 0
100-
101-
for id, entry in all_entries.items():
102-
should_exclude, reason = should_exclude_entry(entry, exclusion_rules)
103-
if should_exclude:
104-
excluded_count += 1
105-
print(f"Excluding entry '{id}': {reason}")
106-
else:
107-
filtered_entries[id] = entry
108-
109-
print(f"Filtered out {excluded_count} entries, keeping {len(filtered_entries)} entries")
31+
entries = registry_data.get('entries', {})
11032

11133
# Create output directories
11234
output_path = Path(output_dir)
@@ -120,8 +42,8 @@ def generate_docs(registry_file, output_dir, templates_dir, overview_template, d
12042

12143
detail_path.mkdir(parents=True, exist_ok=True)
12244

123-
# Generate overview content with filtered entries
124-
overview_content = overview_tmpl.render(entries=filtered_entries)
45+
# Generate overview content
46+
overview_content = overview_tmpl.render(entries=entries)
12547

12648
# Update registry.md in both src/docs and output_dir
12749
src_registry_md = Path(src_docs_dir) / 'registry.md'
@@ -134,7 +56,7 @@ def generate_docs(registry_file, output_dir, templates_dir, overview_template, d
13456
f.write(overview_content)
13557

13658
# Generate detail pages for each entry
137-
for id, entry in filtered_entries.items():
59+
for id, entry in entries.items():
13860
# Ensure entry has an id field for the template
13961
entry_with_id = dict(entry)
14062
entry_with_id['id'] = id
@@ -152,7 +74,7 @@ def generate_docs(registry_file, output_dir, templates_dir, overview_template, d
15274

15375
print(f"Generated documentation in {output_path}")
15476
print(f"- Overview page: {output_path / 'registry.md'}")
155-
print(f"- {len(filtered_entries)} detail pages in {detail_path}")
77+
print(f"- {len(entries)} detail pages in {detail_path}")
15678

15779
if __name__ == '__main__':
15880
generate_docs()

0 commit comments

Comments
 (0)