-
-
Notifications
You must be signed in to change notification settings - Fork 891
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
website/scripts/docsmg: final version (#11501)
* add docsmg tool * moved to the correct scripts directory * removed test files * added install script and readme draft to docsmg * fix install script * fixed issues * Revert "fixed issues" This reverts commit a511920. * Revert "Revert "fixed issues"" This reverts commit ab68918. * added dotenv and updated readme * fixed install script * update readme to ensure that new installers of rust have envs loaded * changed docsmg from using .env to docsmg.env * fixed docsmg to fix internal links in file * fixed docsmg migrate not making directories to file * fixed docsmg migrate trying to read pngs to string * did stuff * fix links * fix links 2 * fix links 3 * fix links * fix links * fix links * fix links * fix links * fixed docsmg migrate replacing links * fixed docsmg migrate replacing links * fixed docsmg migrate replacing links * fixed docsmg migrate replacing links * fixed links * update docsmg fixing links * update docsmg fixing links * update docsmg fixing links * update docsmg removing empty directories * remove changed docs * Revert "remove changed docs" This reverts commit 2e21a5b. * remove changed docs * fixed readme --------- Signed-off-by: Tana M Berry <tanamarieberry@yahoo.com> Co-authored-by: Tana M Berry <tanamarieberry@yahoo.com>
- Loading branch information
1 parent
4fbc13a
commit ff53bcc
Showing
8 changed files
with
359 additions
and
27 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use std::{ffi::OsStr, fs::{read_to_string, write}, path::PathBuf}; | ||
|
||
use crate::recurse_directory; | ||
|
||
pub fn add_extra_dot_dot_to_expression_mdx(migrate_path: PathBuf) { | ||
let binding = recurse_directory(migrate_path); | ||
let files = binding.iter().filter(|x| if let Some(i) = x.file_name() { | ||
if Some("expression.mdx") == i.to_str() || Some("expressions.md") == i.to_str() { | ||
true | ||
} else { | ||
false | ||
} | ||
} else { | ||
false | ||
}); | ||
|
||
for file in files { | ||
let content = match read_to_string(file) { | ||
Ok(i) => i, | ||
_ => continue, | ||
}; | ||
let _ = write(file, content.replace("../expressions", "../../expressions")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use std::{fs::read_to_string, path::PathBuf}; | ||
|
||
use regex::{Captures, Regex}; | ||
|
||
use crate::recurse_directory; | ||
|
||
pub fn shorten_all_external_links(migrate_path: PathBuf) { | ||
let files = recurse_directory(migrate_path.clone()); | ||
for file in files { | ||
let file = migrate_path.join(file); | ||
let absolute_file = file.clone().canonicalize().unwrap(); | ||
let contents = if let Ok(x) = read_to_string(file) { | ||
x | ||
} else { | ||
continue; | ||
}; | ||
let re = Regex::new(r"\[(?<name>.*)\]\((?<link>.*)\)").unwrap(); | ||
let captures: Vec<Captures> = re.captures_iter(&contents).collect(); | ||
for capture in captures { | ||
let link = &capture["link"]; | ||
let link = PathBuf::from(link); | ||
let absolute_link = absolute_file | ||
.clone() | ||
.parent() | ||
.unwrap() | ||
.join(link) | ||
.canonicalize() | ||
.unwrap(); | ||
shorten_link_relative_to(absolute_link.clone(), absolute_file.clone()); | ||
} | ||
} | ||
} | ||
|
||
fn shorten_link_relative_to(link_to_shorten: PathBuf, relative_to: PathBuf) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.