diff options
author | 2018-06-28 15:17:29 -0700 | |
---|---|---|
committer | 2018-06-28 15:18:58 -0700 | |
commit | c90764ddf8abf78dc43c65d2043e01a76e4e98e5 (patch) | |
tree | 0ec5935116156f11b03959a5055c5e619cce8ad8 /src/main/java/com/google/devtools/build/skydoc/FilesystemFileAccessor.java | |
parent | 5f76f67041922b4aa0eb53a77eda97e866a45984 (diff) |
Implement imports (via load()) in Skydoc.
Skydoc will generate documentation for all rule definitions in the transitive dependencies of the given input file.
RELNOTES: None.
PiperOrigin-RevId: 202553088
Diffstat (limited to 'src/main/java/com/google/devtools/build/skydoc/FilesystemFileAccessor.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/skydoc/FilesystemFileAccessor.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/skydoc/FilesystemFileAccessor.java b/src/main/java/com/google/devtools/build/skydoc/FilesystemFileAccessor.java new file mode 100644 index 0000000000..e9ad5f33d0 --- /dev/null +++ b/src/main/java/com/google/devtools/build/skydoc/FilesystemFileAccessor.java @@ -0,0 +1,33 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.devtools.build.skydoc; + +import com.google.devtools.build.lib.syntax.ParserInputSource; +import com.google.devtools.build.lib.vfs.PathFragment; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; + +/** + * Implementation of {@link SkylarkFileAccessor} which uses the real filesystem. + */ +public class FilesystemFileAccessor implements SkylarkFileAccessor { + + @Override + public ParserInputSource inputSource(String pathString) throws IOException { + byte[] content = Files.readAllBytes(Paths.get(pathString)); + return ParserInputSource.create(content, PathFragment.create(pathString)); + } +} |