mirror of
https://github.com/mjl-/mox.git
synced 2024-12-27 08:53:48 +03:00
tweaks to cross-referenced code/rfc html pages
- show commit hash, with a link to the commit - highlight if this is the dev or released version page - sort the rfc's, the list in rfc/index.txt has the major rfc's at the topic, but this nuance is lost in the html page
This commit is contained in:
parent
e24e1bee19
commit
bcb80c3598
2 changed files with 25 additions and 7 deletions
|
@ -7,4 +7,4 @@ link:
|
||||||
go run -tags link link.go -- ../*.go ../*/*.go
|
go run -tags link link.go -- ../*.go ../*/*.go
|
||||||
|
|
||||||
xr:
|
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
|
||||||
|
|
30
rfc/xr.go
30
rfc/xr.go
|
@ -39,20 +39,23 @@ func xwritefile(path string, buf []byte) {
|
||||||
func main() {
|
func main() {
|
||||||
log.SetFlags(0)
|
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() {
|
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()
|
flag.PrintDefaults()
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
args := flag.Args()
|
args := flag.Args()
|
||||||
if len(args) < 2 {
|
if len(args) < 3 {
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
}
|
}
|
||||||
|
|
||||||
destdir = args[0]
|
destdir = args[0]
|
||||||
latestRelease := args[1]
|
revision := args[1]
|
||||||
srcfiles := args[2:]
|
latestRelease := args[2]
|
||||||
|
srcfiles := args[3:]
|
||||||
|
|
||||||
// Generate code.html index.
|
// Generate code.html index.
|
||||||
srcdirs := map[string][]string{}
|
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]})
|
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
|
var rfcBuf bytes.Buffer
|
||||||
err = rfcTemplate.Execute(&rfcBuf, map[string]any{
|
err = rfcTemplate.Execute(&rfcBuf, map[string]any{
|
||||||
"Topics": topics,
|
"Topics": topics,
|
||||||
|
@ -261,7 +269,17 @@ for (const a of document.querySelectorAll('a')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate overal file.
|
// 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 = `<!doctype html>
|
var indexHTML = `<!doctype html>
|
||||||
|
@ -276,7 +294,7 @@ body { margin: 0; padding: 0; font-family: 'ubuntu', 'lato', sans-serif; }
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div style="display: flex; flex-direction: column; height: 100vh">
|
<div style="display: flex; flex-direction: column; height: 100vh">
|
||||||
<div style="padding: .5em"><a href="../../">mox</a>, <span title="The mox code contains references to RFCs, often with specific line numbers. RFCs are generated that point back to the source code. This page shows code and RFCs side by side, with cross-references hyperlinked.">cross-referenced code and RFCs</span>: <a href="../dev/" title="branch main">dev</a> <a href="../RELEASE/" title="released version">RELEASE</a></div>
|
<div style="padding: .5em"><a href="../../">mox</a>, <span title="The mox code contains references to RFCs, often with specific line numbers. RFCs are generated that point back to the source code. This page shows code and RFCs side by side, with cross-references hyperlinked.">cross-referenced code and RFCs</span>: <a href="../RELEASE/" style="font-weight: RELEASEWEIGHT" title="released version">RELEASE</a> <a href="../dev/" style="font-weight: REVISIONWEIGHT" title="branch main">dev</a> (<a href="https://github.com/mjl-/mox/commit/REVISION" title="Source code commit for this revision.">commit REVISION</a>)</div>
|
||||||
<div style="flex-grow: 1; display: flex; align-items: stretch">
|
<div style="flex-grow: 1; display: flex; align-items: stretch">
|
||||||
<div style="flex-grow: 1; margin: 1ex; position: relative; display: flex; flex-direction: column">
|
<div style="flex-grow: 1; margin: 1ex; position: relative; display: flex; flex-direction: column">
|
||||||
<div style="margin-bottom: .5ex"><span id="codefile" style="font-weight: bold">...</span>, <a href="code.html" target="code">index</a></div>
|
<div style="margin-bottom: .5ex"><span id="codefile" style="font-weight: bold">...</span>, <a href="code.html" target="code">index</a></div>
|
||||||
|
|
Loading…
Reference in a new issue