flow icon indicating copy to clipboard operation
flow copied to clipboard

Some links from SVG files are wrong

Open andrewdavidmackenzie opened this issue 1 year ago • 2 comments

Some links from SVG files are wrong There are a number of different cases of links from bubbles in SVG files in flowstdlib and flowsamples: -> provided function (fixed) -> to context function (works) -> to standard library function or flow -> from a library flow to a library function

and a number of them are wrong due to differences in the directory structure and the use of the resolved url/path from a library reference.

Basically all the warnings in the list below, where the URL has a "../../../" that takes it up too high, are bugs that need to be fixed.

flowstdlib structure in target/html has an extra "src" level in it versus the structure in target, and that causes problems also.

andrewdavidmackenzie avatar Nov 30 '22 22:11 andrewdavidmackenzie

flowstdlib

rm -rf target/flowstdlib cargo build -p flowstdlib

warning: source: /Users/andrew/workspace/flow/flowstdlib/src/math/range.toml warning: target: /Users/andrew/workspace/flow/target/flowstdlib/math/range_split/range_split.toml warning: relative: ../../../target/flowstdlib/math/range_split/range_split.toml

flowsamples

warning: source: /Users/andrew/workspace/flow/flowsamples/reverse-echo/root.toml warning: target: /Users/andrew/workspace/flow/flowr/src/cli/stdio/readline.toml warning: relative: ../../flowr/src/cli/stdio/readline.toml warning: source: /Users/andrew/workspace/flow/flowsamples/reverse-echo/root.toml warning: target: /Users/andrew/workspace/flow/flowsamples/reverse-echo/reverse/reverse.toml warning: relative: reverse/reverse.toml warning: source: /Users/andrew/workspace/flow/flowsamples/reverse-echo/root.toml warning: target: /Users/andrew/workspace/flow/flowr/src/cli/stdio/stdout.toml warning: relative: ../../flowr/src/cli/stdio/stdout.toml

andrewdavidmackenzie avatar Nov 30 '22 22:11 andrewdavidmackenzie

Uncomment lines in this function to print out the conversion

// figure out a relative path to get to target from source
fn absolute_to_relative(target: &Path, source: PathBuf) -> Result<String> {
    println!("cargo:warning=source: {}", source.display());
    println!("cargo:warning=target: {}", target.display());
    let mut current_path = source.parent()
        .ok_or("Could not get directory containing source")?.to_path_buf();
    let mut relative_path_to_root = String::new();
    while !target.starts_with(&current_path) {
        relative_path_to_root.push_str("../");
        if !current_path.pop() {
            bail!("Could not find a common node to calculate a relative path")
        }
    }
    let sub_path_from_common_point = target.strip_prefix(current_path.as_path())
        .map_err(|_| "Could not calculate sub-path")?;
    relative_path_to_root = relative_path_to_root
        .add(&sub_path_from_common_point.to_string_lossy());
    println!("cargo:warning=relative: {}", relative_path_to_root);
    Ok(relative_path_to_root)
}

andrewdavidmackenzie avatar Nov 30 '22 22:11 andrewdavidmackenzie