javadoc.dart 1.38 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';
import 'dart:io';

import 'package:archive/archive.dart';
import 'package:http/http.dart' as http;

const String kDocRoot = 'dev/docs/doc';

/// This script downloads an archive of Javadoc for the engine from the
/// artifact store and extracts it to the location used for Dartdoc.
Future<Null> main(List<String> args) async {
16
  final String engineVersion = new File('bin/internal/engine.version').readAsStringSync().trim();
17

18 19
  final String url = 'https://storage.googleapis.com/flutter_infra/flutter/$engineVersion/android-javadoc.zip';
  final http.Response response = await http.get(url);
20

21
  final Archive archive = new ZipDecoder().decodeBytes(response.bodyBytes);
22

23
  final Directory output = new Directory('$kDocRoot/javadoc');
24 25 26 27 28
  print('Extracing javadoc to ${output.path}');
  output.createSync(recursive: true);

  for (ArchiveFile af in archive) {
    if (af.isFile) {
29
      final File file = new File('${output.path}/${af.name}');
30 31 32 33 34
      file.createSync(recursive: true);
      file.writeAsBytesSync(af.content);
    }
  }

35
  final File testFile = new File('${output.path}/io/flutter/view/FlutterView.html');
36 37 38 39 40
  if (!testFile.existsSync()) {
    print('Expected file ${testFile.path} not found');
    exit(1);
  }
}