subspace icon indicating copy to clipboard operation
subspace copied to clipboard

Subdoc doc generation doesn't work on windows

Open PeterChou1 opened this issue 3 months ago • 2 comments

The issues lies in subdoc_main.cc here

you need to also canonicalize the input_path to use / instead of \ too it should look something like this:

for (const std::string& input_path : paths) {
    bool found = false;

    std::string input_path_replace = input_path;
    std::replace(input_path_replace.begin(), input_path_replace.end(), '\\', '/');

    for (const std::string& s : comp_db_files) {
      // Canonicalize the path to use `/` instead of `\`.
      auto canonical_path = std::string(s);
      std::replace(canonical_path.begin(), canonical_path.end(), '\\', '/');

      if (canonical_path.find(input_path_replace) == std::string::npos) {
        continue;
      }
      run_against_files.push(sus::move(canonical_path));
      found = true;
    }
    if (!found) {
      fmt::println(stderr, "Unknown file, not in compiledb: {}", input_path);
      return 1;
    }
  }

PeterChou1 avatar Mar 08 '24 04:03 PeterChou1

Oh, I primarily use subdoc on Windows. Here is how I run it: https://github.com/chromium/subspace/blob/main/tools/run_subdoc.bat

I wonder what is different in my setup that it works.

danakj avatar Mar 08 '24 16:03 danakj

Oh, I primarily use subdoc on Windows. Here is how I run it: https://github.com/chromium/subspace/blob/main/tools/run_subdoc.bat

I wonder what is different in my setup that it works.

I was trying to generate documentation for llvm on windows as part of my research for gsoc.

Here's the command i used:

D:\Compilers\subspace\release\subdoc\Release\subdoc.exe -p D:\Compilers\clion-llvm\llvm-project\build --out .\build-docs --include-file-pattern D:\Compilers\clion-llvm\llvm-project\llvm\ --project-name llvm D:\Compilers\clion-llvm\llvm-project\llvm

its probably because I supplied windows style paths to subdoc that it failed. Maybe not necessarily a bug but i guess worth noting in the subdoc documentation?

PeterChou1 avatar Mar 08 '24 21:03 PeterChou1