From ca1afb003ea41fa82f39ee99d8993497c8d61310 Mon Sep 17 00:00:00 2001 From: "janicejl@google.com" Date: Wed, 3 Jul 2013 22:02:55 +0000 Subject: [PATCH] added a future for docgen docgen returns a future. R=amouravski@google.com Review URL: https://codereview.chromium.org//18653005 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24757 260f80e4-7a28-3924-810f-c04153c831b5 --- pkg/docgen/lib/docgen.dart | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pkg/docgen/lib/docgen.dart b/pkg/docgen/lib/docgen.dart index dd5ae22b266..76cb0bb6299 100644 --- a/pkg/docgen/lib/docgen.dart +++ b/pkg/docgen/lib/docgen.dart @@ -59,18 +59,28 @@ markdown.Resolver linkResolver; * also be documented. * If [parseSdk] is 'true', then all Dart SDK libraries will be documented. * This option is useful when only the SDK libraries are needed. + * + * Returns true if docgen sucessfuly completes. */ -void docgen(List files, {String packageRoot, bool outputToYaml: true, - bool includePrivate: false, bool includeSdk: false, bool parseSdk: false}) { +Future docgen(List files, {String packageRoot, + bool outputToYaml: true, bool includePrivate: false, bool includeSdk: false, + bool parseSdk: false}) { if (packageRoot == null && !parseSdk) { - packageRoot = _findPackageRoot(files.first); + // TODO(janicejl): At the moment, if a single file is passed it, it is + // assumed that it does not have a package root unless it is passed in by + // the user. In future, find a better way to find the packageRoot and also + // fully test finding the packageRoot. + if (FileSystemEntity.typeSync(files.first) + == FileSystemEntityType.DIRECTORY) { + packageRoot = _findPackageRoot(files.first); + } } logger.info('Package Root: ${packageRoot}'); linkResolver = (name) => fixReference(name, _currentLibrary, _currentClass, _currentMember); - getMirrorSystem(files, packageRoot, parseSdk: parseSdk) + return getMirrorSystem(files, packageRoot, parseSdk: parseSdk) .then((MirrorSystem mirrorSystem) { if (mirrorSystem.libraries.isEmpty) { throw new StateError('No library mirrors were created.'); @@ -78,6 +88,8 @@ void docgen(List files, {String packageRoot, bool outputToYaml: true, _documentLibraries(mirrorSystem.libraries.values, includeSdk: includeSdk, includePrivate: includePrivate, outputToYaml: outputToYaml); + + return true; }); }