Future<Map<String, dynamic>> documentProject(Uri projectDirectory, String libraryName)

Source

Future<Map<String, dynamic>> documentProject(Uri projectDirectory, String libraryName) {
  var generator = new SourceGenerator(
          (List<String> args, Map<String, dynamic> values) async {
        var resolver = new PackagePathResolver(".packages");
        var config = new ApplicationConfiguration()
          ..configurationFilePath = values["configPath"];

        var document = await Application.document(
            RequestSink.defaultSinkType, config, resolver);

        document.hosts = (values["hosts"] as List<String>)
            ?.map((hostString) => new APIHost.fromURI(Uri.parse((hostString))))
            ?.toList();

        document.info.title = values["title"];
        document.info.description = values["apiDescription"];
        document.info.version = values["version"];
        document.info.termsOfServiceURL = values["termsOfServiceURL"];
        document.info.contact.email = values["contactEmail"];
        document.info.contact.name = values["contactName"];
        document.info.contact.url = values["contactURL"];
        document.info.license.url = values["licenseURL"];
        document.info.license.name = values["licenseName"];

        return document.asMap();
      }, imports: [
    "package:aqueduct/aqueduct.dart",
    "package:$libraryName/$libraryName.dart",
    "dart:isolate",
    "dart:mirrors",
    "dart:async",
    "dart:convert"
  ]);

  var executor = new IsolateExecutor(generator, [libraryName],
      message: {
        "configPath": configurationPath,
        "title": title,
        "apiDescription": apiDescription,
        "version": version,
        "termsOfServiceURL": termsOfServiceURL,
        "contactEmail": contactEmail,
        "contactName": contactName,
        "contactURL": contactURL,
        "licenseURL": licenseURL,
        "licenseName": licenseName
      },
      packageConfigURI: projectDirectory.resolve(".packages"));

  return executor.execute(projectDirectory) as Future<Map<String, dynamic>>;
}