@@ -116,7 +116,7 @@ def parse_wiki_structure_from_sync_script(sync_script_path: Path) -> dict[str, s
116116 result [str (key .value )] = str (value .value )
117117 return result
118118 except (OSError , SyntaxError ) as e :
119- print (red (f"ERROR: Could not parse { sync_script_path } : { e } " ))
119+ print (red (f"ERROR: Could not parse { sync_script_path } : { e } " ), file = sys . stderr )
120120
121121 return {}
122122
@@ -156,7 +156,7 @@ def parse_hardcoded_sidebar_from_sync_script(sync_script_path: Path) -> str | No
156156 if isinstance (stmt .value , ast .Constant ):
157157 return str (stmt .value .value )
158158 except (OSError , SyntaxError ) as e :
159- print (red (f"ERROR: Could not parse { sync_script_path } : { e } " ))
159+ print (red (f"ERROR: Could not parse { sync_script_path } : { e } " ), file = sys . stderr )
160160
161161 return None
162162
@@ -272,7 +272,8 @@ def validate_sync_script_sidebar_template(
272272 errors += 1
273273 print (
274274 red ("ERROR:" )
275- + f" Could not extract hardcoded sidebar template from { sync_script_path } "
275+ + f" Could not extract hardcoded sidebar template from { sync_script_path } " ,
276+ file = sys .stderr ,
276277 )
277278 return ValidationResult (errors = errors , warnings = warnings )
278279
@@ -302,7 +303,8 @@ def validate_sync_script_sidebar_template(
302303 + f" { sync_script_path .name } :generate_sidebar(): "
303304 + f"Wiki-link [[{ page_name } |{ display_text } ]] "
304305 + f"contains '{ char } ' in display text ({ reason } ). "
305- + f"Use standard markdown [Display](Page) syntax instead."
306+ + f"Use standard markdown [Display](Page) syntax instead." ,
307+ file = sys .stderr ,
306308 )
307309 break # Only report first problematic character per link
308310
@@ -367,7 +369,7 @@ def parse_sidebar_wiki_links(
367369 content = sidebar_path .read_text (encoding = "utf-8" )
368370 return parse_wiki_links_from_string (content )
369371 except (OSError , UnicodeDecodeError ) as e :
370- print (red (f"ERROR: Could not read { sidebar_path } : { e } " ))
372+ print (red (f"ERROR: Could not read { sidebar_path } : { e } " ), file = sys . stderr )
371373 return []
372374
373375
@@ -433,7 +435,8 @@ def validate_wiki_link_display_text(
433435 red ("ERROR:" )
434436 + f" _Sidebar.md:{ line_num } : Wiki-link [[{ page_name } |{ display_text } ]] "
435437 + f"contains '{ char } ' in display text ({ reason } ). "
436- + f"Use standard markdown [Display](Page) syntax instead."
438+ + f"Use standard markdown [Display](Page) syntax instead." ,
439+ file = sys .stderr ,
437440 )
438441 break # Only report first problematic character per link
439442
@@ -463,7 +466,8 @@ def validate_sidebar_links(
463466 print (
464467 red ("ERROR:" )
465468 + f" _Sidebar.md:{ line_num } : Link to '{ page_name } ' "
466- + f"points to non-existent page '{ page_name } .md'"
469+ + f"points to non-existent page '{ page_name } .md'" ,
470+ file = sys .stderr ,
467471 )
468472 elif verbose :
469473 syntax_label = "wiki" if syntax_type == "wiki" else "md"
@@ -495,7 +499,8 @@ def validate_wiki_structure_completeness(
495499 print (
496500 yellow ("WARNING:" )
497501 + f" docs/{ unmapped } has no mapping in WIKI_STRUCTURE "
498- + "(scripts/sync-wiki.py)"
502+ + "(scripts/sync-wiki.py)" ,
503+ file = sys .stderr ,
499504 )
500505
501506 # Also check for stale mappings (mapped files that no longer exist)
@@ -506,7 +511,8 @@ def validate_wiki_structure_completeness(
506511 print (
507512 yellow ("WARNING:" )
508513 + f" WIKI_STRUCTURE contains mapping for '{ stale } ' "
509- + "which does not exist in docs/"
514+ + "which does not exist in docs/" ,
515+ file = sys .stderr ,
510516 )
511517
512518 return ValidationResult (errors = errors , warnings = warnings )
@@ -546,7 +552,8 @@ def validate_sidebar_completeness(
546552 warnings += 1
547553 print (
548554 yellow ("WARNING:" )
549- + f" Wiki page '{ missing } .md' has no entry in _Sidebar.md"
555+ + f" Wiki page '{ missing } .md' has no entry in _Sidebar.md" ,
556+ file = sys .stderr ,
550557 )
551558
552559 return ValidationResult (errors = errors , warnings = warnings )
@@ -632,17 +639,19 @@ def validate_table_pipe_escaping(
632639 print (
633640 red ("ERROR:" )
634641 + f" { md_file .name } :{ line_num } : Table cell contains "
635- + f"unescaped pipe in code span: `{ code_content } `"
642+ + f"unescaped pipe in code span: `{ code_content } `" ,
643+ file = sys .stderr ,
636644 )
637645 print (
638646 " "
639647 + yellow ("Tip:" )
640648 + " Escape the pipe with backslash: "
641- + f"`{ code_content .replace ('|' , chr (92 ) + '|' )} `"
649+ + f"`{ code_content .replace ('|' , chr (92 ) + '|' )} `" ,
650+ file = sys .stderr ,
642651 )
643652
644653 except (OSError , UnicodeDecodeError ) as e :
645- print (red (f"ERROR: Could not read { md_file } : { e } " ))
654+ print (red (f"ERROR: Could not read { md_file } : { e } " ), file = sys . stderr )
646655 errors += 1
647656
648657 return ValidationResult (errors = errors , warnings = warnings )
@@ -682,7 +691,8 @@ def validate_markdown_link_syntax(wiki_dir: Path, verbose: bool = False) -> Vali
682691 print (
683692 red ("ERROR:" )
684693 + f" { md_file .name } :{ line_num } : Malformed link with space "
685- + f"after '[': { match .group ()} "
694+ + f"after '[': { match .group ()} " ,
695+ file = sys .stderr ,
686696 )
687697
688698 # Check for space before closing bracket
@@ -691,7 +701,8 @@ def validate_markdown_link_syntax(wiki_dir: Path, verbose: bool = False) -> Vali
691701 print (
692702 yellow ("WARNING:" )
693703 + f" { md_file .name } :{ line_num } : Link has trailing space "
694- + f"before ']': { match .group ()} "
704+ + f"before ']': { match .group ()} " ,
705+ file = sys .stderr ,
695706 )
696707
697708 # Check for empty link text
@@ -700,11 +711,12 @@ def validate_markdown_link_syntax(wiki_dir: Path, verbose: bool = False) -> Vali
700711 print (
701712 yellow ("WARNING:" )
702713 + f" { md_file .name } :{ line_num } : Empty link text: "
703- + f"{ match .group ()} "
714+ + f"{ match .group ()} " ,
715+ file = sys .stderr ,
704716 )
705717
706718 except (OSError , UnicodeDecodeError ) as e :
707- print (red (f"ERROR: Could not read { md_file } : { e } " ))
719+ print (red (f"ERROR: Could not read { md_file } : { e } " ), file = sys . stderr )
708720 errors += 1
709721
710722 return ValidationResult (errors = errors , warnings = warnings )
@@ -730,15 +742,15 @@ def main() -> int:
730742
731743 # Check required files/directories exist
732744 if not wiki_dir .exists ():
733- print (red ("ERROR:" ) + f" Wiki directory not found: { wiki_dir } " )
745+ print (red ("ERROR:" ) + f" Wiki directory not found: { wiki_dir } " , file = sys . stderr )
734746 return 1
735747
736748 if not sidebar_path .exists ():
737- print (red ("ERROR:" ) + f" Sidebar not found: { sidebar_path } " )
749+ print (red ("ERROR:" ) + f" Sidebar not found: { sidebar_path } " , file = sys . stderr )
738750 return 1
739751
740752 if not sync_script_path .exists ():
741- print (red ("ERROR:" ) + f" Sync script not found: { sync_script_path } " )
753+ print (red ("ERROR:" ) + f" Sync script not found: { sync_script_path } " , file = sys . stderr )
742754 return 1
743755
744756 # Get wiki pages and parse WIKI_STRUCTURE
@@ -747,7 +759,7 @@ def main() -> int:
747759 docs_files = get_docs_source_files (docs_dir )
748760
749761 if not wiki_structure :
750- print (red ("ERROR:" ) + " Could not parse WIKI_STRUCTURE from sync-wiki.py" )
762+ print (red ("ERROR:" ) + " Could not parse WIKI_STRUCTURE from sync-wiki.py" , file = sys . stderr )
751763 return 1
752764
753765 if verbose :
0 commit comments