(path: &Path)
| 169 | format!("docs validation failed:\n{}", failures.join("\n")), |
| 170 | )) |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | fn validate_generated_target( |
| 175 | source: &DocOut, |
| 176 | target: &str, |
| 177 | routes: &std::collections::BTreeMap<&str, &DocOut>, |
| 178 | failures: &mut Vec<String>, |
| 179 | ) { |
| 180 | if target.starts_with("http://") |
| 181 | || target.starts_with("https://") |
| 182 | || target.starts_with("mailto:") |
| 183 | { |
| 184 | return; |
| 185 | } |
| 186 | if target.contains("://") { |
| 187 | failures.push(format!("{} has malformed URL {target}", source.route_path)); |
| 188 | return; |
| 189 | } |
| 190 | |
| 191 | let (path, fragment) = match target.split_once('#') { |
| 192 | Some(("", fragment)) => (source.route_path.as_str(), Some(fragment)), |
| 193 | Some((path, fragment)) => (path, Some(fragment)), |
| 194 | None => (target, None), |
| 195 | }; |
| 196 | if !path.starts_with("/docs") && !path.starts_with("/book") { |
| 197 | return; |
| 198 | } |
| 199 | let Some(target_doc) = routes.get(path).copied() else { |
| 200 | failures.push(format!( |
| 201 | "{} links to missing route {path}", |
no test coverage detected