@@ -12,7 +12,7 @@ use serde_json::{self, Value};
1212// Centralized constants for hardcoded project paths and filenames
1313const DOCS_DIR : & str = "docs" ;
1414const READMES_DIR : & str = "docs/content/readmes" ;
15- const EXPANDED_DIR : & str = "docs/content/expanded " ;
15+ const CONTENT_DIR : & str = "docs/content" ;
1616const README_MD : & str = "README.md" ;
1717// Link rewriting target for other README.md files
1818const READMES_LINK_DIR : & str = "../readmes" ;
@@ -61,7 +61,7 @@ fn main() -> Result<()> {
6161
6262fn sync_repo_readmes ( repo_root : & Path ) -> Result < ( ) > {
6363 let dest_dir = repo_root. join ( READMES_DIR ) ;
64- let expanded_dir = repo_root. join ( EXPANDED_DIR ) ;
64+ let content_dir = repo_root. join ( CONTENT_DIR ) ;
6565
6666 fs:: create_dir_all ( & dest_dir) . context ( "creating destination directory" ) ?;
6767
@@ -102,7 +102,7 @@ fn sync_repo_readmes(repo_root: &Path) -> Result<()> {
102102 let src = dent. path ( ) . to_path_buf ( ) ;
103103 // Skip root README.md
104104 if src == repo_root. join ( README_MD ) { continue ; }
105- process_readme ( repo_root, & src, & dest_dir, & expanded_dir )
105+ process_readme ( repo_root, & src, & dest_dir, & content_dir )
106106 . with_context ( || format ! ( "processing {}" , rel( repo_root, & src) ) ) ?;
107107 count += 1 ;
108108 }
@@ -119,7 +119,7 @@ fn rel(root: &Path, path: &Path) -> String {
119119 . replace ( '\\' , "/" )
120120}
121121
122- fn process_readme ( repo_root : & Path , src_path : & Path , dest_dir : & Path , expanded_dir : & Path ) -> Result < ( ) > {
122+ fn process_readme ( repo_root : & Path , src_path : & Path , dest_dir : & Path , content_dir : & Path ) -> Result < ( ) > {
123123 let src_dir = src_path. parent ( ) . ok_or_else ( || anyhow ! ( "no parent for src" ) ) ?;
124124 let rel_dir = diff_paths ( src_dir, repo_root) . ok_or_else ( || anyhow ! ( "rel path failed" ) ) ?;
125125 let slug = rel_dir. to_string_lossy ( ) . replace ( '\\' , "/" ) . replace ( '/' , "-" ) ;
@@ -134,7 +134,7 @@ fn process_readme(repo_root: &Path, src_path: &Path, dest_dir: &Path, expanded_d
134134 let prefix = & caps[ 1 ] ;
135135 let href = & caps[ 2 ] ;
136136 let rest = & caps[ 3 ] ;
137- let new_href = rewrite_href ( repo_root, src_dir, dest_dir, expanded_dir , href) ;
137+ let new_href = rewrite_href ( repo_root, src_dir, dest_dir, content_dir , href) ;
138138 format ! ( "{}{}{})" , prefix, new_href, rest)
139139 } )
140140 . into_owned ( ) ;
@@ -146,7 +146,7 @@ fn process_readme(repo_root: &Path, src_path: &Path, dest_dir: &Path, expanded_d
146146 let start = & caps[ 1 ] ;
147147 let href = & caps[ 2 ] ;
148148 let end = & caps[ 3 ] ;
149- let new_href = rewrite_href ( repo_root, src_dir, dest_dir, expanded_dir , href) ;
149+ let new_href = rewrite_href ( repo_root, src_dir, dest_dir, content_dir , href) ;
150150 format ! ( "{}{}{}" , start, new_href, end)
151151 } )
152152 . into_owned ( ) ;
@@ -159,16 +159,16 @@ fn process_readme(repo_root: &Path, src_path: &Path, dest_dir: &Path, expanded_d
159159 Ok ( ( ) )
160160}
161161
162- fn rewrite_href ( repo_root : & Path , src_dir : & Path , dest_dir : & Path , expanded_dir : & Path , raw : & str ) -> String {
162+ fn rewrite_href ( repo_root : & Path , src_dir : & Path , dest_dir : & Path , content_dir : & Path , raw : & str ) -> String {
163163 let href = raw. trim ( ) ;
164164 if href. is_empty ( ) { return raw. to_string ( ) ; }
165165 if is_external ( href) { return raw. to_string ( ) ; }
166166
167167 let ( base_no_q_anchor, suffix) = split_query_anchor ( href) ;
168168 let abs_target = normalize_join ( src_dir, & base_no_q_anchor) ;
169169
170- // If inside docs/content/expanded , make it relative to dest_dir
171- if starts_with_path ( & abs_target, expanded_dir ) {
170+ // If inside docs/content, make it relative to dest_dir
171+ if starts_with_path ( & abs_target, content_dir ) {
172172 let rel_to_dest = diff_paths ( & abs_target, dest_dir) . unwrap_or ( abs_target. clone ( ) ) ;
173173 return path_to_unix ( & rel_to_dest) + & suffix;
174174 }
0 commit comments