Merge pull request #299 from aya-rs/revert-298-fix-docs

Revert "docs: Merge search indexes"
pull/304/head
Dave Tucker 2 years ago committed by GitHub
commit 79e06f2644
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,4 @@
use std::{ use std::{
fs::File,
io::BufRead,
path::{Path, PathBuf}, path::{Path, PathBuf},
process::Command, process::Command,
}; };
@ -42,34 +40,9 @@ pub fn docs() -> Result<(), anyhow::Error> {
.open("./target/doc/crates.js")?; .open("./target/doc/crates.js")?;
file.write_all(crates_js)?; file.write_all(crates_js)?;
let mut search_indexes = read_lines("./target/doc/search-index.js")?
.map(|l| l.unwrap())
.collect::<Vec<_>>();
search_indexes.truncate(search_indexes.len() - 2);
let mut last = search_indexes.pop().unwrap();
last = last.trim_end_matches('\\').to_string() + ",\\";
search_indexes.push(last);
for l in read_lines("./bpf/target/doc/search-index.js")?.skip(1) {
search_indexes.push(l.unwrap());
}
let mut file = fs::File::options()
.read(true)
.write(true)
.open("./target/doc/search-index.js")?;
file.write_all(search_indexes.join("\n").as_bytes())?;
Ok(()) Ok(())
} }
fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
where
P: AsRef<Path>,
{
let file = File::open(filename)?;
Ok(io::BufReader::new(file).lines())
}
fn copy_dir_all<P: AsRef<Path>>(src: P, dst: P) -> io::Result<()> { fn copy_dir_all<P: AsRef<Path>>(src: P, dst: P) -> io::Result<()> {
fs::create_dir_all(&dst)?; fs::create_dir_all(&dst)?;
for entry in fs::read_dir(src)? { for entry in fs::read_dir(src)? {

Loading…
Cancel
Save