Fix Skydoc's following of imports to correctly process absolute labels.
Previously, any absolute label (starting with double slash) would be converted to an absolute path, instead of a path relative to the current workspace directory.
RELNOTES: None.
PiperOrigin-RevId: 204472080
diff --git a/src/main/java/com/google/devtools/build/skydoc/SkydocMain.java b/src/main/java/com/google/devtools/build/skydoc/SkydocMain.java
index 2f0a7f4..01fff20 100644
--- a/src/main/java/com/google/devtools/build/skydoc/SkydocMain.java
+++ b/src/main/java/com/google/devtools/build/skydoc/SkydocMain.java
@@ -188,6 +188,10 @@
ImmutableMap.Builder<String, RuleInfo> ruleInfoMap,
ImmutableList.Builder<RuleInfo> unknownNamedRules)
throws InterruptedException, IOException {
+ if (path.isAbsolute()) {
+ path = Paths.get(PathFragment.create(path.toString()).toRelative().getPathString());
+ }
+
List<RuleInfo> ruleInfoList = new ArrayList<>();
Environment env = recursiveEval(path, ruleInfoList);
@@ -253,7 +257,7 @@
private static Path fromPathFragment(Path fromPath, PathFragment pathFragment) {
return pathFragment.isAbsolute()
- ? Paths.get(pathFragment.getPathString())
+ ? Paths.get(pathFragment.toRelative().getPathString())
: fromPath.resolveSibling(pathFragment.getPathString());
}