<commit_before>library discovery_api_client_generator;

import "dart:io";
import "dart:async";
import "dart:convert";
import 'package:google_discovery_v1_api/discovery_v1_api_client.dart';
import 'package:google_discovery_v1_api/discovery_v1_api_console.dart';

part "src/apis_package_generator.dart";
part "src/config.dart";
part "src/dart_api_library.dart";
part "src/dart_api_test_library.dart";
part "src/dart_comments.dart";
part "src/dart_resources.dart";
part "src/dart_schemas.dart";
part "src/namer.dart";
part "src/utils.dart";
part "src/uri_template.dart";

List<GenerateResult> generateApiPackage(
    List<RestDescription> descriptions, String outputDirectory) {
  var config = new Config('googleapis', '0.1.0-dev');
  var apisPackageGenerator = new ApisPackageGenerator(
      descriptions, config, outputDirectory);

  return apisPackageGenerator.generateApiPackage();
}

List<GenerateResult> generateAllLibraries(String inputDirectory,
                                          String outputDirectory) {
  var apiDescriptions = new Directory(inputDirectory).listSync()
      .where((fse) => fse is File && fse.path.endsWith('.json'))
      .map((File file) {
    return new RestDescription.fromJson(JSON.decode(file.readAsStringSync()));
  }).toList();
  return generateApiPackage(apiDescriptions, outputDirectory);
}

Future<List<GenerateResult>> downloadDiscoveryDocuments(String outputDir) {
  var apiDescriptions = <RestDescription>[];

  return _discoveryClient.apis.list().then((DirectoryList list) {
    var futures = <Future>[];
    for (var item in list.items) {
      futures.add(_discoveryClient.apis.getRest(item.name, item.version)
          .then((doc) {
        apiDescriptions.add(doc);
      }));
    }
    return Future.wait(futures);
  }).then((_) {
    var directory = new Directory(outputDir);
    if (directory.existsSync()) {
      print('Deleting directory $outputDir.');
      directory.deleteSync(recursive: true);
    }
    directory.createSync();

    for (var description in apiDescriptions) {
      var name = '$outputDir/${description.name}__${description.version}.json';<commit_msg>Add a few features<commit_after>library discovery_api_client_generator;

import "dart:io";
import "dart:async";
import "dart:convert";
import 'package:google_discovery_v1_api/discovery_v1_api_client.dart';
import 'package:google_discovery_v1_api/discovery_v1_api_console.dart';

part "src/apis_package_generator.dart";
part "src/config.dart";
part "src/dart_api_library.dart";
part "src/dart_api_test_library.dart";
part "src/dart_comments.dart";
part "src/dart_resources.dart";
part "src/dart_schemas.dart";
part "src/namer.dart";
part "src/utils.dart";
part "src/uri_template.dart";


Future<List<DirectoryListItems>> listAllApis() {
  return _discoveryClient.apis.list().then((DirectoryList list) {
    return list.items;
  });
}

List<GenerateResult> generateApiPackage(
    List<RestDescription> descriptions, String outputDirectory) {
  var config = new Config('googleapis', '0.1.0-dev');
  var apisPackageGenerator = new ApisPackageGenerator(
      descriptions, config, outputDirectory);

  return apisPackageGenerator.generateApiPackage();
}

List<GenerateResult> generateAllLibraries(String inputDirectory,
                                          String outputDirectory) {
  var apiDescriptions = new Directory(inputDirectory).listSync()
      .where((fse) => fse is File && fse.path.endsWith('.json'))
      .map((File file) {
    return new RestDescription.fromJson(JSON.decode(file.readAsStringSync()));
  }).toList();
  return generateApiPackage(apiDescriptions, outputDirectory);
}

Future<List<GenerateResult>> downloadDiscoveryDocuments(
    String outputDir, {List<String> ids}) {
  var apiDescriptions = <RestDescription>[];

  return _discoveryClient.apis.list().then((DirectoryList list) {
    var futures = <Future>[];
    for (var item in list.items) {
      if (ids == null || ids.contains(item.id)) {
        futures.add(_discoveryClient.apis.getRest(item.name, item.version)
            .then((doc) {
          apiDescriptions.add(doc);
        }));
      }
    }
    return Future.wait(futures);
  }).then((_) {
    var directory = new Directory(outputDir);
    if (directory.existsSync()) {
      print('Deleting directory $outputDir.');
      directory.deleteSync(recursive: true);
    }
    directory.createSync(recursive: true);

    for (var description in apiDescriptions) {
      var name = '$outputDir/${description.name}__${description.version}.json';
{'fraction_non_alphanumeric': 0.1301172825846426, 'fraction_numerical': 0.003098030537729586, 'mean_word_length': 4.4787878787878785, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7513503', 'n_tokens_mistral': 1401, 'n_tokens_neox': 1375, 'n_words': 255}