diff --git a/rfc/Makefile b/rfc/Makefile index 41dbe91..017578e 100644 --- a/rfc/Makefile +++ b/rfc/Makefile @@ -7,4 +7,4 @@ link: go run -tags link link.go -- ../*.go ../*/*.go xr: - go run xr.go -- xr-dev $$(git tag | tail -n1) ../*.go ../*/*.go + go run xr.go -- xr-dev $$(git rev-parse --short HEAD) $$(git tag | tail -n1) ../*.go ../*/*.go diff --git a/rfc/xr.go b/rfc/xr.go index 060375d..435a612 100644 --- a/rfc/xr.go +++ b/rfc/xr.go @@ -39,20 +39,23 @@ func xwritefile(path string, buf []byte) { func main() { log.SetFlags(0) + var release bool + flag.BoolVar(&release, "release", false, "generate cross-references for a release, highlighting the release version as active page") flag.Usage = func() { - log.Println("usage: go run xr.go destdir latestrelease ../*.go ../*/*.go") + log.Println("usage: go run xr.go destdir revision latestrelease ../*.go ../*/*.go") flag.PrintDefaults() os.Exit(2) } flag.Parse() args := flag.Args() - if len(args) < 2 { + if len(args) < 3 { flag.Usage() } destdir = args[0] - latestRelease := args[1] - srcfiles := args[2:] + revision := args[1] + latestRelease := args[2] + srcfiles := args[3:] // Generate code.html index. srcdirs := map[string][]string{} @@ -166,6 +169,11 @@ for (const a of document.querySelectorAll('a')) { } topics[topic] = append(topics[topic], rfc{strings.TrimSpace(t[0]), t[1]}) } + for _, l := range topics { + sort.Slice(l, func(i, j int) bool { + return l[i].File < l[j].File + }) + } var rfcBuf bytes.Buffer err = rfcTemplate.Execute(&rfcBuf, map[string]any{ "Topics": topics, @@ -261,7 +269,17 @@ for (const a of document.querySelectorAll('a')) { } // Generate overal file. - xwritefile("index.html", []byte(strings.ReplaceAll(indexHTML, "RELEASE", latestRelease))) + index := indexHTML + if release { + index = strings.ReplaceAll(index, "RELEASEWEIGHT", "bold") + index = strings.ReplaceAll(index, "REVISIONWEIGHT", "normal") + } else { + index = strings.ReplaceAll(index, "RELEASEWEIGHT", "normal") + index = strings.ReplaceAll(index, "REVISIONWEIGHT", "bold") + } + index = strings.ReplaceAll(index, "REVISION", revision) + index = strings.ReplaceAll(index, "RELEASE", latestRelease) + xwritefile("index.html", []byte(index)) } var indexHTML = ` @@ -276,7 +294,7 @@ body { margin: 0; padding: 0; font-family: 'ubuntu', 'lato', sans-serif; }