Пример #1
0
// NewContext create new Context with from,to and theme args
func NewContext(cli *cli.Context, from, to, theme string) *Context {
	c := &Context{
		cli:       cli,
		From:      from,
		To:        to,
		ThemeName: theme,
		time:      time.Now(),
	}
	c.Tree = model.NewTree(c.DstDir())
	c.Sync = sync.NewSyncer(c.DstDir())
	return c
}
Пример #2
0
func docServ(c *cli.Context) error {
	if !c.Bool("no-server") {
		builder.After(func(ctx *builder.Context) {
			if s == nil {
				s = server.New(ctx.DstDir())
				go s.Run(c.String("addr"))
			}
			if ctx.Source != nil && ctx.Source.Meta != nil {
				s.SetPrefix(ctx.Source.Meta.Path)
			}
		})
	}
	buildContext := newContext(c, false)
	buildContext.From = "doc/source"
	buildContext.To = "doc/dest"
	buildContext.ThemeName = "doc/theme"
	buildContext.Tree.Dest = buildContext.DstDir()
	buildContext.Sync = sync.NewSyncer(buildContext.DstDir())
	build(buildContext, !c.Bool("no-server"))
	return nil
}