code: public static ServiceSpecification generate(
              Iterable<ServiceInfo> services,
              Function<TypeSignature, ? extends NamedTypeInfo> namedTypeInfoFactory) {
          if (Iterables.isEmpty(services)) {
              return emptyServiceSpecification;
          }
  
          // Collect all named types referred by the services.
          final Set<TypeSignature> namedTypes =
                  Streams.stream(services)
                         .flatMap(s -> s.findNamedTypes().stream())
                         .collect(toImmutableSortedSet(comparing(TypeSignature::name)));
  
          final Map<String, EnumInfo> enums = new HashMap<>();
          final Map<String, StructInfo> structs = new HashMap<>();
          final Map<String, ExceptionInfo> exceptions = new HashMap<>();
  
          generateNamedTypeInfos(namedTypeInfoFactory, enums, structs, exceptions, namedTypes);
  
          return new ServiceSpecification(services, enums.values(), structs.values(), exceptions.values());
      }
docs: Generates a new {@link ServiceSpecification} from the specified {@link ServiceInfo}s and
  the factory {@link Function} that creates {@link NamedTypeInfo}s for the enum, struct or exception types
  referred by the specified {@link ServiceInfo}s.