@@ -173,10 +173,12 @@ def main():
173
173
parser .add_argument ('--glossary' , default = './src/components/GlossaryTooltip/glossary.json' , help = 'Glossary JSON file' )
174
174
parser .add_argument ('--dry-run' , action = 'store_true' , help = 'Show changes without writing files' )
175
175
parser .add_argument ('--force' , action = 'store_true' , help = 'Process files even if they already have glossary syntax' )
176
+ parser .add_argument ('--check' , action = 'store_true' , help = 'Check for unwrapped terms and show warnings (non-blocking)' )
176
177
177
178
args = parser .parse_args ()
178
179
179
- print ("🚀 Starting Glossary Term Wrapper...\n " )
180
+ if not args .check :
181
+ print ("🚀 Starting Glossary Term Wrapper...\n " )
180
182
181
183
# Load glossary
182
184
if not os .path .exists (args .glossary ):
@@ -192,45 +194,67 @@ def main():
192
194
# Filter out skip patterns
193
195
files = [f for f in all_files if not should_skip_file (f )]
194
196
195
- print (f"📁 Found { len (all_files )} MDX files, processing { len (files )} files" )
196
- print (f"⏭️ Skipped { len (all_files ) - len (files )} files based on skip patterns" )
197
-
198
- if args .force :
199
- print ("💪 FORCE MODE - Processing files even with existing glossary syntax" )
200
-
201
- if args .dry_run :
202
- print ("🔍 DRY RUN MODE - No files will be modified" )
203
-
204
- print ()
197
+ if not args .check :
198
+ print (f"📁 Found { len (all_files )} MDX files, processing { len (files )} files" )
199
+ print (f"⏭️ Skipped { len (all_files ) - len (files )} files based on skip patterns" )
200
+
201
+ if args .force :
202
+ print ("💪 FORCE MODE - Processing files even with existing glossary syntax" )
203
+
204
+ if args .dry_run :
205
+ print ("🔍 DRY RUN MODE - No files will be modified" )
206
+
207
+ print ()
205
208
206
209
# Process files
207
210
stats = {'modified' : 0 , 'unchanged' : 0 , 'skipped' : 0 , 'error' : 0 , 'terms_wrapped' : 0 }
211
+ file_details = [] # Track which files had terms for warning display
208
212
209
213
for file_path in files :
210
214
rel_path = os .path .relpath (file_path , args .docs_dir )
211
- status , changes = process_file (file_path , terms , args .dry_run , args .force )
215
+ # For check mode, always use dry_run=True to avoid writing files
216
+ status , changes = process_file (file_path , terms , args .dry_run or args .check , args .force )
212
217
213
- if status == 'modified' :
214
- print (f"✅ Modified { rel_path } ({ changes } terms)" )
215
- elif status == 'unchanged' :
218
+ if status == 'modified' and changes > 0 :
219
+ file_details .append ((rel_path , changes ))
220
+ if not args .check :
221
+ print (f"✅ Modified { rel_path } ({ changes } terms)" )
222
+ elif status == 'unchanged' and not args .check :
216
223
print (f"➖ No changes needed for { rel_path } " )
217
- elif status == 'skipped' :
224
+ elif status == 'skipped' and not args . check :
218
225
print (f"⏭️ Skipped { rel_path } (already has glossary syntax)" )
219
226
220
227
stats [status ] += 1
221
228
stats ['terms_wrapped' ] += changes
222
229
223
- # Print summary
224
- print (f"\n 📊 Summary:" )
225
- print (f" Files processed: { stats ['modified' ] + stats ['unchanged' ]} " )
226
- print (f" Files modified: { stats ['modified' ]} " )
227
- print (f" Files skipped: { stats ['skipped' ]} " )
228
- print (f" Terms wrapped: { stats ['terms_wrapped' ]} " )
229
-
230
- if args .dry_run :
231
- print ("\n 💡 Run without --dry-run to apply changes" )
232
- if not args .force and stats ['skipped' ] > 0 :
233
- print ("💡 Use --force to process files with existing glossary syntax" )
230
+ # Show results
231
+ if args .check :
232
+ # Check mode: show warning if terms found
233
+ if stats ['terms_wrapped' ] > 0 :
234
+ print (f"⚠️ GLOSSARY WARNING: Found { stats ['terms_wrapped' ]} unwrapped glossary terms in { len (file_details )} files" )
235
+ print ("💡 Run 'python3 scripts/wrap_glossary_terms.py' to add glossary tooltips" )
236
+
237
+ # Show files with opportunities (limit to top 10 to avoid spam)
238
+ if file_details :
239
+ print (" Files with unwrapped terms:" )
240
+ for rel_path , count in sorted (file_details , key = lambda x : x [1 ], reverse = True )[:10 ]:
241
+ print (f" - { rel_path } ({ count } terms)" )
242
+ if len (file_details ) > 10 :
243
+ print (f" ... and { len (file_details ) - 10 } more files" )
244
+ else :
245
+ print ("✅ All glossary terms are properly wrapped" )
246
+ else :
247
+ # Normal mode: show detailed summary
248
+ print (f"\n 📊 Summary:" )
249
+ print (f" Files processed: { stats ['modified' ] + stats ['unchanged' ]} " )
250
+ print (f" Files modified: { stats ['modified' ]} " )
251
+ print (f" Files skipped: { stats ['skipped' ]} " )
252
+ print (f" Terms wrapped: { stats ['terms_wrapped' ]} " )
253
+
254
+ if args .dry_run :
255
+ print ("\n 💡 Run without --dry-run to apply changes" )
256
+ if not args .force and stats ['skipped' ] > 0 :
257
+ print ("💡 Use --force to process files with existing glossary syntax" )
234
258
235
259
if __name__ == '__main__' :
236
260
main ()
0 commit comments