1515
1616
1717class PluginsDocUpToDateRule (Rule ):
18- """Check that PLUGINS.md is up-to-date by running 'make update'"""
18+ """Check that PLUGINS.md and docs/data.json are up-to-date by running 'make update'"""
1919
2020 @property
2121 def rule_id (self ) -> str :
2222 return "plugins-doc-up-to-date"
2323
2424 @property
2525 def description (self ) -> str :
26- return "PLUGINS.md must be up-to-date with plugin metadata. Run 'make update' to regenerate."
26+ return "PLUGINS.md and docs/data.json must be up-to-date with plugin metadata. Run 'make update' to regenerate."
2727
2828 def default_severity (self ) -> Severity :
2929 return Severity .ERROR
@@ -36,6 +36,8 @@ def check(self, context: RepositoryContext) -> List[RuleViolation]:
3636 return violations
3737
3838 plugins_md_path = context .root_path / "PLUGINS.md"
39+ data_json_path = context .root_path / "docs" / "data.json"
40+
3941 if not plugins_md_path .exists ():
4042 return violations
4143
@@ -45,8 +47,9 @@ def check(self, context: RepositoryContext) -> List[RuleViolation]:
4547 return violations
4648
4749 try :
48- # Read current PLUGINS.md content
49- original_content = plugins_md_path .read_text ()
50+ # Read current content of files to check
51+ original_plugins_md = plugins_md_path .read_text ()
52+ original_data_json = data_json_path .read_text () if data_json_path .exists () else None
5053
5154 # Run the docs generation script
5255 result = subprocess .run (
@@ -66,13 +69,31 @@ def check(self, context: RepositoryContext) -> List[RuleViolation]:
6669 )
6770 return violations
6871
69- # Read the generated PLUGINS.md content
70- generated_content = plugins_md_path .read_text ()
72+ # Also run build-website.py if it exists
73+ website_script_path = context .root_path / "scripts" / "build-website.py"
74+ if website_script_path .exists ():
75+ result = subprocess .run (
76+ ["python3" , str (website_script_path )],
77+ cwd = str (context .root_path ),
78+ capture_output = True ,
79+ text = True ,
80+ timeout = 30
81+ )
82+
83+ if result .returncode != 0 :
84+ violations .append (
85+ self .violation (
86+ f"build-website.py failed: { result .stderr } " ,
87+ file_path = data_json_path if data_json_path .exists () else plugins_md_path
88+ )
89+ )
90+ return violations
7191
72- # Compare
73- if original_content != generated_content :
92+ # Check if PLUGINS.md changed
93+ generated_plugins_md = plugins_md_path .read_text ()
94+ if original_plugins_md != generated_plugins_md :
7495 # Restore original content
75- plugins_md_path .write_text (original_content )
96+ plugins_md_path .write_text (original_plugins_md )
7697
7798 violations .append (
7899 self .violation (
@@ -81,6 +102,21 @@ def check(self, context: RepositoryContext) -> List[RuleViolation]:
81102 )
82103 )
83104
105+ # Check if docs/data.json changed
106+ if data_json_path .exists ():
107+ generated_data_json = data_json_path .read_text ()
108+ if original_data_json != generated_data_json :
109+ # Restore original content
110+ if original_data_json is not None :
111+ data_json_path .write_text (original_data_json )
112+
113+ violations .append (
114+ self .violation (
115+ "docs/data.json is out of sync with plugin metadata. Run 'make update' to update." ,
116+ file_path = data_json_path
117+ )
118+ )
119+
84120 except subprocess .TimeoutExpired :
85121 violations .append (
86122 self .violation (
@@ -91,7 +127,7 @@ def check(self, context: RepositoryContext) -> List[RuleViolation]:
91127 except Exception as e :
92128 violations .append (
93129 self .violation (
94- f"Error checking PLUGINS.md up-to-date status: { e } " ,
130+ f"Error checking files up-to-date status: { e } " ,
95131 file_path = plugins_md_path
96132 )
97133 )
0 commit comments