Exemple #1
0
func TestLexer_Html(t *testing.T) {
	testdir := "./testdir/"
	a := assert.New(t)

	// 创建测试目录
	a.NotError(os.MkdirAll(testdir, os.ModePerm), "无法创建测试目录")

	docs, err := core.ScanFiles([]string{"./test.php"}, scanner.C)
	a.NotError(err).
		NotNil(docs).
		False(docs.HasError()).
		True(len(docs.Items()) > 0)

	opt := &Options{
		DocDir:     testdir,
		Version:    "doc v0.1",
		AppVersion: "appver 0.1",
		Title:      "TestDoc",
		Elapsed:    1,
	}
	a.NotError(Html(docs.Items(), opt))
}
Exemple #2
0
func main() {
	if flags() {
		return
	}

	elapsed := time.Now()

	cfg, err := loadConfig()
	if err != nil {
		printError(err)
		return
	}
	paths, err := recursivePath(cfg)
	if err != nil {
		printError(err)
		return
	}

	docs, err := core.ScanFiles(paths, cfg.lang.scan)
	if err != nil {
		printError(err)
		return
	}
	if docs.HasError() { // 语法错误,并不中断程序
		printSyntaxErrors(docs.Errors())
	}

	opt := &o.Options{
		Title:      cfg.Doc.Title,
		Version:    cfg.Doc.Version,
		DocDir:     cfg.Output.Dir,
		AppVersion: version,
		Elapsed:    time.Now().UnixNano() - elapsed.UnixNano(),
	}
	if err = o.Html(docs.Items(), opt); err != nil {
		printError(err)
		return
	}
}