Kaynağa Gözat

fix file and structure names

cdelorme 7 yıl önce
ebeveyn
işleme
cf591ae7a9
5 değiştirilmiş dosya ile 15 ekleme ve 15 silme
  1. 1 1
      cmd/smd/main.go
  2. 8 8
      markdown.go
  3. 6 6
      markdown_test.go
  4. 0 0
      static.go
  5. 0 0
      static_test.go

+ 1 - 1
cmd/smd/main.go

@@ -18,7 +18,7 @@ var operate = blackfriday.MarkdownCommon
 func main() {
 	cwd, _ := getwd()
 
-	smd := &staticmd.Generator{
+	smd := &staticmd.Markdown{
 		L:      &glog.Logger{},
 		Input:  cwd,
 		Output: filepath.Join(cwd, "public/"),

+ 8 - 8
generator.go → markdown.go

@@ -22,7 +22,7 @@ type executor interface {
 
 type operation func([]byte) []byte
 
-type Generator struct {
+type Markdown struct {
 	Book         bool   `json:"book,omitempty"`
 	Input        string `json:"input,omitempty"`
 	Output       string `json:"output,omitempty"`
@@ -36,11 +36,11 @@ type Generator struct {
 	template executor
 }
 
-func (g *Generator) ior(path string) string {
+func (g *Markdown) ior(path string) string {
 	return strings.TrimSuffix(strings.Replace(path, g.Input, g.Output, 1), filepath.Ext(path)) + ".html"
 }
 
-func (g *Generator) depth(path string) string {
+func (g *Markdown) depth(path string) string {
 	if g.Relative {
 		if rel, err := filepath.Rel(filepath.Dir(path), g.Output); err == nil {
 			return rel + string(os.PathSeparator)
@@ -49,14 +49,14 @@ func (g *Generator) depth(path string) string {
 	return ""
 }
 
-func (g *Generator) walk(path string, file os.FileInfo, err error) error {
+func (g *Markdown) walk(path string, file os.FileInfo, err error) error {
 	if file != nil && file.Mode().IsRegular() && file.Size() > 0 && isMarkdown(path) {
 		g.pages = append(g.pages, path)
 	}
 	return err
 }
 
-func (g *Generator) multi(run operation) error {
+func (g *Markdown) multi(run operation) error {
 	navi := make(map[string][]navigation)
 	var err error
 
@@ -139,7 +139,7 @@ func (g *Generator) multi(run operation) error {
 	return err
 }
 
-func (g *Generator) single(run operation) error {
+func (g *Markdown) single(run operation) error {
 	content := make([]byte, 0)
 	toc := "\n"
 	previous_depth := 0
@@ -198,7 +198,7 @@ func (g *Generator) single(run operation) error {
 	return err
 }
 
-func (g *Generator) Generate(run operation) error {
+func (g *Markdown) Generate(run operation) error {
 	var err error
 	if g.template, err = parseFiles(g.TemplateFile); err != nil {
 		g.L.Error("%s\n", err)
@@ -215,7 +215,7 @@ func (g *Generator) Generate(run operation) error {
 		g.L.Error("%s\n", err)
 		return err
 	}
-	g.L.Debug("generator state: %+v", g)
+	g.L.Debug("Markdown state: %+v", g)
 
 	if g.Book {
 		return g.single(run)

+ 6 - 6
generator_test.go → markdown_test.go

@@ -48,7 +48,7 @@ func (self *mockFileInfo) Sys() interface{}   { return self.So }
 
 func TestIor(t *testing.T) {
 	t.Parallel()
-	g := Generator{}
+	g := Markdown{}
 	if s := g.ior("some.md"); len(s) == 0 {
 		t.FailNow()
 	}
@@ -57,7 +57,7 @@ func TestIor(t *testing.T) {
 func TestDepth(t *testing.T) {
 	t.Parallel()
 	absp := "/abs/path/"
-	g := Generator{Output: absp}
+	g := Markdown{Output: absp}
 
 	// test abs depth
 	if d := g.depth("somefile"); len(d) > 0 {
@@ -74,7 +74,7 @@ func TestDepth(t *testing.T) {
 
 func TestWalk(t *testing.T) {
 	t.Parallel()
-	g := Generator{}
+	g := Markdown{}
 
 	p := "valid.md"
 	var f os.FileInfo = &mockFileInfo{S: 1}
@@ -87,7 +87,7 @@ func TestWalk(t *testing.T) {
 }
 
 func TestMulti(t *testing.T) {
-	g := Generator{L: &mockLogger{}, template: &mockTemplate{}, pages: []string{"fuck.md", "deeper/than/index.md", "deeper/than/data.md"}}
+	g := Markdown{L: &mockLogger{}, template: &mockTemplate{}, pages: []string{"fuck.md", "deeper/than/index.md", "deeper/than/data.md"}}
 
 	// set expected defaults
 	notExist = false
@@ -136,7 +136,7 @@ func TestMulti(t *testing.T) {
 }
 
 func TestSingle(t *testing.T) {
-	g := Generator{L: &mockLogger{}, template: &mockTemplate{}, pages: []string{"fuck.md", "deeper/than/index.md", "deeper/than/data.md"}}
+	g := Markdown{L: &mockLogger{}, template: &mockTemplate{}, pages: []string{"fuck.md", "deeper/than/index.md", "deeper/than/data.md"}}
 
 	// reset expected defaults
 	statError = nil
@@ -176,7 +176,7 @@ func TestSingle(t *testing.T) {
 }
 
 func TestGenerate(t *testing.T) {
-	g := Generator{L: &mockLogger{}}
+	g := Markdown{L: &mockLogger{}}
 
 	// set template for stand-alone execution
 	parseTemplate = template.New("test")

+ 0 - 0
staticmd.go → static.go


+ 0 - 0
staticmd_test.go → static_test.go