Update Soong docs generator for blueprint changes

bootstrap.ModuleTypeDocs needs a mapping of module types to factories
to support factories that are wrapped in ModuleFactoryAdapter closures.

It also returns ModuleType objects grouped into Package objects.

Bug: 67909957
Test: m soong_docs
Change-Id: I70eac9f0f0e13075580da92d4219792ca0b18fbf
This commit is contained in:
Colin Cross
2019-01-25 22:43:35 -08:00
committed by Jaewoong Jung
parent 1b16b0e031
commit 7089c27c07
3 changed files with 32 additions and 7 deletions

View File

@@ -20,7 +20,7 @@ import (
type moduleType struct {
name string
factory blueprint.ModuleFactory
factory ModuleFactory
}
var moduleTypes []moduleType
@@ -40,8 +40,6 @@ type mutator struct {
parallel bool
}
var mutators []*mutator
type ModuleFactory func() Module
// ModuleFactoryAdaptor wraps a ModuleFactory into a blueprint.ModuleFactory by converting a Module
@@ -65,7 +63,7 @@ func SingletonFactoryAdaptor(factory SingletonFactory) blueprint.SingletonFactor
}
func RegisterModuleType(name string, factory ModuleFactory) {
moduleTypes = append(moduleTypes, moduleType{name, ModuleFactoryAdaptor(factory)})
moduleTypes = append(moduleTypes, moduleType{name, factory})
}
func RegisterSingletonType(name string, factory SingletonFactory) {
@@ -90,7 +88,7 @@ func (ctx *Context) Register() {
}
for _, t := range moduleTypes {
ctx.RegisterModuleType(t.name, t.factory)
ctx.RegisterModuleType(t.name, ModuleFactoryAdaptor(t.factory))
}
for _, t := range singletons {
@@ -105,3 +103,11 @@ func (ctx *Context) Register() {
// Register env last so that it can track all used environment variables
ctx.RegisterSingletonType("env", SingletonFactoryAdaptor(EnvSingleton))
}
func ModuleTypeFactories() map[string]ModuleFactory {
ret := make(map[string]ModuleFactory)
for _, t := range moduleTypes {
ret[t.name] = t.factory
}
return ret
}