浏览代码

Update the docs.go

Vadim Markovtsev 7 年之前
父节点
当前提交
f194715c56
共有 3 个文件被更改,包括 12 次插入19 次删除
  1. 1 1
      burndown_test.go
  2. 8 18
      doc.go
  3. 3 0
      pipeline.go

+ 1 - 1
burndown_test.go

@@ -5,10 +5,10 @@ import (
 	"io"
 	"io"
 	"testing"
 	"testing"
 
 
+	"github.com/gogo/protobuf/proto"
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/assert"
 	"gopkg.in/src-d/go-git.v4/plumbing"
 	"gopkg.in/src-d/go-git.v4/plumbing"
 	"gopkg.in/src-d/go-git.v4/plumbing/object"
 	"gopkg.in/src-d/go-git.v4/plumbing/object"
-	"github.com/gogo/protobuf/proto"
 	"gopkg.in/src-d/hercules.v3/pb"
 	"gopkg.in/src-d/hercules.v3/pb"
 )
 )
 
 

+ 8 - 18
doc.go

@@ -6,7 +6,7 @@ The analysis is expressed in a form of the tree: there are nodes - "pipeline ite
 require some other nodes to be executed prior to selves and in turn provide the data for
 require some other nodes to be executed prior to selves and in turn provide the data for
 dependent nodes. There are several service items which do not produce any useful
 dependent nodes. There are several service items which do not produce any useful
 statistics but rather provide the requirements for other items. The top-level items
 statistics but rather provide the requirements for other items. The top-level items
-are:
+include:
 
 
 - BurndownAnalysis - line burndown statistics for project, files and developers.
 - BurndownAnalysis - line burndown statistics for project, files and developers.
 - Couples - coupling statistics for files and developers.
 - Couples - coupling statistics for files and developers.
@@ -19,31 +19,21 @@ The typical API usage is to initialize the Pipeline class:
 	// ...initialize repository...
 	// ...initialize repository...
 	pipeline := hercules.NewPipeline(repository)
 	pipeline := hercules.NewPipeline(repository)
 
 
-Then add the required analysis tree nodes:
+Then add the required analysis:
 
 
-  pipeline.AddItem(&hercules.BlobCache{})
-	pipeline.AddItem(&hercules.DaysSinceStart{})
-	pipeline.AddItem(&hercules.TreeDiff{})
-	pipeline.AddItem(&hercules.FileDiff{})
-	pipeline.AddItem(&hercules.RenameAnalysis{SimilarityThreshold: 80})
-	pipeline.AddItem(&hercules.IdentityDetector{})
-
-Then initialize BurndownAnalysis:
-
-  burndowner := &hercules.BurndownAnalysis{
+  ba := pipeline.DeployItem(&hercules.BurndownAnalysis{
     Granularity:  30,
     Granularity:  30,
 		Sampling:     30,
 		Sampling:     30,
-  }
-  pipeline.AddItem(burndowner)
+  })
 
 
-Then execute the analysis tree:
+This call will add all the needed intermediate pipeline items. Then link and execute the analysis tree:
 
 
-  pipeline.Initialize()
-	result, err := pipeline.Run(commits)
+  pipeline.Initialize(nil)
+	result, err := pipeline.Run(pipeline.Commits())
 
 
 Finally extract the result:
 Finally extract the result:
 
 
-  burndownResults := result[burndowner].(hercules.BurndownResult)
+  result := result[ba].(hercules.BurndownResult)
 
 
 The actual usage example is cmd/hercules/main.go - the command line tool's code.
 The actual usage example is cmd/hercules/main.go - the command line tool's code.
 
 

+ 3 - 0
pipeline.go

@@ -441,6 +441,9 @@ func (pipeline *Pipeline) resolve(dumpPath string) {
 }
 }
 
 
 func (pipeline *Pipeline) Initialize(facts map[string]interface{}) {
 func (pipeline *Pipeline) Initialize(facts map[string]interface{}) {
+	if facts == nil {
+		facts = map[string]interface{}{}
+	}
 	dumpPath, _ := facts["Pipeline.DumpPath"].(string)
 	dumpPath, _ := facts["Pipeline.DumpPath"].(string)
 	pipeline.resolve(dumpPath)
 	pipeline.resolve(dumpPath)
 	if dryRun, _ := facts["Pipeline.DryRun"].(bool); dryRun {
 	if dryRun, _ := facts["Pipeline.DryRun"].(bool); dryRun {