From dea185aa9b62e1660cb5c6e79e90f2078db7fe6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Mon, 14 Mar 2016 15:41:03 +0100 Subject: [PATCH] hugolib: Remove unused code --- hugolib/menu_test.go | 6 ------ hugolib/page.go | 5 ----- hugolib/page_test.go | 5 ----- hugolib/pagesPrevNext_test.go | 15 -------------- hugolib/site.go | 14 ------------- hugolib/site_show_plan_test.go | 9 -------- hugolib/site_test.go | 38 ++++++++-------------------------- hugolib/site_url_test.go | 7 ------- 8 files changed, 9 insertions(+), 90 deletions(-) diff --git a/hugolib/menu_test.go b/hugolib/menu_test.go index dbfc27ad1..37e850523 100644 --- a/hugolib/menu_test.go +++ b/hugolib/menu_test.go @@ -182,12 +182,6 @@ menu: Front Matter with Menu with Identifier`, title, menu, identifier)) } -type testMenuState struct { - site *Site - oldMenu interface{} - oldBaseURL interface{} -} - // Issue 817 - identifier should trump everything func TestPageMenuWithIdentifier(t *testing.T) { diff --git a/hugolib/page.go b/hugolib/page.go index 97f696f0b..975f64a68 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -73,7 +73,6 @@ type Page struct { plain string // TODO should be []byte plainWords []string plainInit sync.Once - plainSecondaryInit sync.Once renderingConfig *helpers.Blackfriday renderingConfigInit sync.Once pageMenus PageMenus @@ -813,10 +812,6 @@ func (p *Page) guessMarkupType() string { return helpers.GuessType(p.Source.Ext()) } -func (p *Page) detectFrontMatter() (f *parser.FrontmatterType) { - return parser.DetectFrontMatter(rune(p.frontmatter[0])) -} - func (p *Page) parse(reader io.Reader) error { psr, err := parser.ReadFrom(reader) if err != nil { diff --git a/hugolib/page_test.go b/hugolib/page_test.go index 92bc7bc90..79cc58269 100644 --- a/hugolib/page_test.go +++ b/hugolib/page_test.go @@ -99,11 +99,6 @@ Content of the file goes Here "date": "2012-08-06" } Some text -` - - SIMPLE_PAGE_JSON_COMPACT = ` -{"title":"foobar","customData":{"foo":"bar"},"date":"2012-08-06"} -Text ` SIMPLE_PAGE_NOLAYOUT = `--- diff --git a/hugolib/pagesPrevNext_test.go b/hugolib/pagesPrevNext_test.go index e711cf758..4d8305523 100644 --- a/hugolib/pagesPrevNext_test.go +++ b/hugolib/pagesPrevNext_test.go @@ -34,21 +34,6 @@ var pagePNTestSources = []pagePNTestObject{ {"/section2/testpage5.md", 1, "2012-04-06"}, } -func preparePagePNTestPages(t *testing.T) Pages { - var pages Pages - for _, s := range pagePNTestSources { - p, err := NewPage(s.path) - if err != nil { - t.Fatalf("failed to prepare test page %s", s.path) - } - p.Weight = s.weight - p.Date = cast.ToTime(s.date) - p.PublishDate = cast.ToTime(s.date) - pages = append(pages, p) - } - return pages -} - func TestPrev(t *testing.T) { pages := preparePageGroupTestPages(t) assert.Equal(t, pages.Prev(pages[0]), pages[4]) diff --git a/hugolib/site.go b/hugolib/site.go index 96bd1b4dc..ba8096d12 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -87,7 +87,6 @@ type Site struct { targets targetList targetListInit sync.Once RunMode runmode - params map[string]interface{} draftCount int futureCount int Data map[string]interface{} @@ -769,14 +768,6 @@ func (s *Site) Render() (err error) { return } -func (s *Site) checkDescriptions() { - for _, p := range s.Pages { - if len(p.Description) < 60 { - jww.FEEDBACK.Println(p.Source.Path() + " ") - } - } -} - func (s *Site) Initialise() (err error) { return s.initialize() } @@ -861,11 +852,6 @@ func (s *Site) checkDirectories() (err error) { return } -type pageResult struct { - page *Page - err error -} - // ReReadFile resets file to be read from disk again func (s *Site) ReReadFile(absFilePath string) (*source.File, error) { jww.INFO.Println("rereading", absFilePath) diff --git a/hugolib/site_show_plan_test.go b/hugolib/site_show_plan_test.go index 91b0e2a1a..640a8b425 100644 --- a/hugolib/site_show_plan_test.go +++ b/hugolib/site_show_plan_test.go @@ -42,15 +42,6 @@ var fakeSource = []source.ByteSource{ }, } -func stringInSlice(a string, list []string) bool { - for _, b := range list { - if b == a { - return true - } - } - return false -} - func checkShowPlanExpected(t *testing.T, s *Site, expected string) { out := new(bytes.Buffer) diff --git a/hugolib/site_test.go b/hugolib/site_test.go index dec6cb29c..700aa8a98 100644 --- a/hugolib/site_test.go +++ b/hugolib/site_test.go @@ -41,18 +41,11 @@ title: simple template --- content` - TEMPLATE_MISSING_FUNC = "{{ .Title | funcdoesnotexists }}" - TEMPLATE_FUNC = "{{ .Title | urlize }}" - TEMPLATE_CONTENT = "{{ .Content }}" - TEMPLATE_DATE = "{{ .Date }}" - INVALID_TEMPLATE_FORMAT_DATE = "{{ .Date.Format time.RFC3339 }}" - TEMPLATE_WITH_URL_REL = "Going" - TEMPLATE_WITH_URL_ABS = "Going" - PAGE_URL_SPECIFIED = `--- -title: simple template -url: "mycategory/my-whatever-content/" ---- -content` + TEMPLATE_MISSING_FUNC = "{{ .Title | funcdoesnotexists }}" + TEMPLATE_FUNC = "{{ .Title | urlize }}" + TEMPLATE_CONTENT = "{{ .Content }}" + TEMPLATE_DATE = "{{ .Date }}" + TEMPLATE_WITH_URL_ABS = "Going" PAGE_WITH_MD = `--- title: page with md @@ -149,18 +142,6 @@ func NopCloser(w io.Writer) io.WriteCloser { return nopCloser{w} } -func matchRender(t *testing.T, s *Site, p *Page, tmplName string, expected string) { - content := new(bytes.Buffer) - err := s.renderThing(p, tmplName, NopCloser(content)) - if err != nil { - t.Fatalf("Unable to render template.") - } - - if string(content.Bytes()) != expected { - t.Fatalf("Content did not match expected: %s. got: %s", expected, content) - } -} - func TestRenderThing(t *testing.T) { tests := []struct { content string @@ -209,15 +190,14 @@ func HTML(in string) string { func TestRenderThingOrDefault(t *testing.T) { tests := []struct { - content string missing bool template string expected string }{ - {PAGE_SIMPLE_TITLE, true, TEMPLATE_TITLE, HTML("simple template")}, - {PAGE_SIMPLE_TITLE, true, TEMPLATE_FUNC, HTML("simple-template")}, - {PAGE_SIMPLE_TITLE, false, TEMPLATE_TITLE, HTML("simple template")}, - {PAGE_SIMPLE_TITLE, false, TEMPLATE_FUNC, HTML("simple-template")}, + {true, TEMPLATE_TITLE, HTML("simple template")}, + {true, TEMPLATE_FUNC, HTML("simple-template")}, + {false, TEMPLATE_TITLE, HTML("simple template")}, + {false, TEMPLATE_FUNC, HTML("simple-template")}, } hugofs.DestinationFS = new(afero.MemMapFs) diff --git a/hugolib/site_url_test.go b/hugolib/site_url_test.go index 33843ebcf..d295bac8f 100644 --- a/hugolib/site_url_test.go +++ b/hugolib/site_url_test.go @@ -43,13 +43,6 @@ func must(err error) { } } -func mustReturn(ret *Page, err error) *Page { - if err != nil { - panic(err) - } - return ret -} - type InMemoryAliasTarget struct { target.HTMLRedirectAlias files map[string][]byte