~emersion/gyosu

96c85ffd6e5114197bff06855c392fb83242e1b7 — Simon Ser 2 months ago b3bcb24
Add -fsite-name option
3 files changed, 20 insertions(+), 3 deletions(-)

M main.go
M template.go
M template/unit.html
M main.go => main.go +18 -2
@@ 362,6 362,7 @@ func main() {
	var D, U, I, exportedSymbols []string
	outputDir := "out"
	var filePrefixMap [][2]string
	var siteName string
	for _, opt := range opts {
		switch opt.Option {
		case 'I':


@@ 381,6 382,8 @@ func main() {
					log.Fatal("invalid syntax in -ffile-prefix-map")
				}
				filePrefixMap = append(filePrefixMap, [2]string{old, new})
			case "site-name":
				siteName = value
			default:
				log.Fatalf("unknown -f option: %v", name)
			}


@@ 587,8 590,13 @@ func main() {
		log.Fatalf("failed to remove %q: %v", outputDir, err)
	}

	title := "Documentation"
	if siteName != "" {
		title = siteName + " documentation"
	}

	data := indexData{
		Title: "Documentation",
		Title: title,
		Decls: decls,
	}
	for filename, _ := range declByFile {


@@ 604,8 612,16 @@ func main() {

		basePath := filepath.ToSlash(filename + ".html")

		heading := "Documentation for <" + filename + ">"

		title := heading
		if siteName != "" {
			title += " · " + siteName
		}

		data := unitData{
			Title:     "Documentation for <" + filename + ">",
			Heading:   heading,
			Title:     title,
			Decls:     decls,
			IndexHref: relPath(basePath, ""),
		}

M template.go => template.go +1 -0
@@ 99,6 99,7 @@ func (decl *declData) Title() string {

type unitData struct {
	Title     string
	Heading   string
	Decls     []declData
	IndexHref string
}

M template/unit.html => template/unit.html +1 -1
@@ 1,7 1,7 @@
{{ template "head.html" . }}

<main>
	<h2>{{ .Title }}</h2>
	<h2>{{ .Heading }}</h2>

	<p>
		<a href="{{ .IndexHref }}">Back to index</a>