devtools/{depotview,hackdoc}: tie both together
Change-Id: I0a1ca3b4fa0e0a074eccbe0f8748839b926db9c1
diff --git a/devtools/hackdoc/source/source.go b/devtools/hackdoc/source/source.go
index a79a920..73d8990 100644
--- a/devtools/hackdoc/source/source.go
+++ b/devtools/hackdoc/source/source.go
@@ -1,10 +1,36 @@
package source
-type Source interface {
- IsFile(path string) (bool, error)
- ReadFile(path string) ([]byte, error)
- IsDirectory(path string) (bool, error)
+import "context"
- CacheSet(dependencies []string, key string, value interface{})
- CacheGet(key string) interface{}
+var (
+ FlagGitwebURLPattern = "https://gerrit.hackerspace.pl/plugins/gitiles/hscloud/+/%s/%s"
+)
+
+type Source interface {
+ IsFile(ctx context.Context, path string) (bool, error)
+ ReadFile(ctx context.Context, path string) ([]byte, error)
+ IsDirectory(ctx context.Context, path string) (bool, error)
+ WebLinks(fpath string) []WebLink
+}
+
+type WebLink struct {
+ Kind string
+ LinkLabel string
+ LinkURL string
+}
+
+type SourceProvider interface {
+ Source(ctx context.Context, rev string) (Source, error)
+}
+
+type singleRefProvider struct {
+ source Source
+}
+
+func (s *singleRefProvider) Source(ctx context.Context, rev string) (Source, error) {
+ return s.source, nil
+}
+
+func NewSingleRefProvider(s Source) SourceProvider {
+ return &singleRefProvider{s}
}