Merge "soong_docs build link error fix."
This commit is contained in:
@@ -108,14 +108,9 @@ func writeDocs(ctx *android.Context, filename string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Produce the top-level, package list page first.
|
// Produce the top-level, package list page first.
|
||||||
tmpl, err := template.New("file").Parse(packageListTemplate)
|
tmpl := template.Must(template.Must(template.New("file").Parse(packageListTemplate)).Parse(copyBaseUrl))
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
if err == nil {
|
err = tmpl.Execute(buf, packages)
|
||||||
err = tmpl.Execute(buf, packages)
|
|
||||||
}
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = ioutil.WriteFile(filename, buf.Bytes(), 0666)
|
err = ioutil.WriteFile(filename, buf.Bytes(), 0666)
|
||||||
}
|
}
|
||||||
@@ -125,18 +120,16 @@ func writeDocs(ctx *android.Context, filename string) error {
|
|||||||
// We need a module name getter/setter function because I couldn't
|
// We need a module name getter/setter function because I couldn't
|
||||||
// find a way to keep it in a variable defined within the template.
|
// find a way to keep it in a variable defined within the template.
|
||||||
currentModuleName := ""
|
currentModuleName := ""
|
||||||
tmpl, err := template.New("file").Funcs(map[string]interface{}{
|
tmpl := template.Must(
|
||||||
"setModule": func(moduleName string) string {
|
template.Must(template.New("file").Funcs(map[string]interface{}{
|
||||||
currentModuleName = moduleName
|
"setModule": func(moduleName string) string {
|
||||||
return ""
|
currentModuleName = moduleName
|
||||||
},
|
return ""
|
||||||
"getModule": func() string {
|
},
|
||||||
return currentModuleName
|
"getModule": func() string {
|
||||||
},
|
return currentModuleName
|
||||||
}).Parse(perPackageTemplate)
|
},
|
||||||
if err != nil {
|
}).Parse(perPackageTemplate)).Parse(copyBaseUrl))
|
||||||
return err
|
|
||||||
}
|
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
modules := moduleTypeDocsToTemplates(pkg.ModuleTypes)
|
modules := moduleTypeDocsToTemplates(pkg.ModuleTypes)
|
||||||
data := perPackageTemplateData{Name: pkg.Name, Modules: modules}
|
data := perPackageTemplateData{Name: pkg.Name, Modules: modules}
|
||||||
@@ -173,6 +166,7 @@ td {
|
|||||||
word-wrap:break-word;
|
word-wrap:break-word;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
{{template "copyBaseUrl"}}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="main">
|
<div id="main">
|
||||||
@@ -203,9 +197,7 @@ files for the Soong build system.
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
`
|
`
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
perPackageTemplate = `
|
perPackageTemplate = `
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@@ -243,6 +235,7 @@ li a:hover:not(.active) {
|
|||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
{{template "copyBaseUrl"}}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{{- /* Fixed sidebar with module types */ -}}
|
{{- /* Fixed sidebar with module types */ -}}
|
||||||
@@ -308,5 +301,24 @@ li a:hover:not(.active) {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
`
|
||||||
|
|
||||||
|
copyBaseUrl = `
|
||||||
|
{{define "copyBaseUrl"}}
|
||||||
|
<script type="text/javascript">
|
||||||
|
window.addEventListener('message', (e) => {
|
||||||
|
if (e != null && e.data != null && e.data.type === "SET_BASE" && e.data.base != null) {
|
||||||
|
const existingBase = document.querySelector('base');
|
||||||
|
if (existingBase != null) {
|
||||||
|
existingBase.parentElement.removeChild(existingBase);
|
||||||
|
}
|
||||||
|
|
||||||
|
const base = document.createElement('base');
|
||||||
|
base.setAttribute('href', e.data.base);
|
||||||
|
document.head.appendChild(base);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{{end}}
|
||||||
`
|
`
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user