2013-07-17 17:52:45 -06:00
|
|
|
// Copyright 2013 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package godoc
|
|
|
|
|
|
|
|
import (
|
2013-07-17 21:14:09 -06:00
|
|
|
"regexp"
|
|
|
|
"sync"
|
2013-07-17 17:52:45 -06:00
|
|
|
"text/template"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Presentation generates output from a corpus.
|
|
|
|
type Presentation struct {
|
|
|
|
Corpus *Corpus
|
|
|
|
|
|
|
|
// TabWidth optionally specifies the tab width.
|
|
|
|
TabWidth int
|
|
|
|
|
|
|
|
ShowTimestamps bool
|
|
|
|
ShowPlayground bool
|
|
|
|
ShowExamples bool
|
|
|
|
DeclLinks bool
|
2013-07-17 21:14:09 -06:00
|
|
|
|
|
|
|
NotesRx *regexp.Regexp
|
|
|
|
|
|
|
|
initFuncMapOnce sync.Once
|
|
|
|
funcMap template.FuncMap
|
|
|
|
templateFuncs template.FuncMap
|
2013-07-17 17:52:45 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewPresentation returns a new Presentation from a corpus.
|
|
|
|
func NewPresentation(c *Corpus) *Presentation {
|
|
|
|
if c == nil {
|
|
|
|
panic("nil Corpus")
|
|
|
|
}
|
|
|
|
return &Presentation{
|
|
|
|
Corpus: c,
|
|
|
|
TabWidth: 4,
|
|
|
|
ShowExamples: true,
|
|
|
|
DeclLinks: true,
|
|
|
|
}
|
|
|
|
}
|