Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Unified Diff: pkg/docgen/lib/src/package_helpers.dart

Issue 303153002: "Reverting 36776" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/docgen/lib/src/models/library.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/docgen/lib/src/package_helpers.dart
diff --git a/pkg/docgen/lib/src/package_helpers.dart b/pkg/docgen/lib/src/package_helpers.dart
index b496da2c5bcd25f173908633363bd9b0e6ed7abd..e8a36fc3a4d322fd23efe05c56e2252e0523b641 100644
--- a/pkg/docgen/lib/src/package_helpers.dart
+++ b/pkg/docgen/lib/src/package_helpers.dart
@@ -5,7 +5,6 @@
library docgen.package_helpers;
import 'exports/source_mirrors.dart';
-import 'generator.dart' show pubScript;
import 'dart:io';
import 'package:path/path.dart' as path;
@@ -59,54 +58,14 @@ String getPackageDirectory(LibraryMirror mirror) {
}
}
-Map _getPubspec(String directoryName) {
+/// Read a pubspec and return the library name, given a directory
+String packageNameFor(String directoryName) {
var pubspecName = path.join(directoryName, 'pubspec.yaml');
File pubspec = new File(pubspecName);
- if (!pubspec.existsSync()) return {'name': ''};
+ if (!pubspec.existsSync()) return '';
var contents = pubspec.readAsStringSync();
- return loadYaml(contents);
-}
-
-/// Read a pubspec and return the library name, given a directory
-String packageNameFor(String directoryName) =>
- _getPubspec(directoryName)['name'];
-
-/// Read a pubspec and return the library name, given a directory
-String _packageVersionFor(String directoryName) {
- var spec = _getPubspec(directoryName);
- return '${spec['name']}-${spec['version']}';
-}
-
-/// Look in the pubspec.lock to determine what version of a package we are
-/// documenting (null if not applicable).
-String packageVersion(LibraryMirror mirror) {
- if (mirror.uri.scheme == 'file') {
- String packageDirectory = getPackageDirectory(mirror);
- if (packageDirectory.contains('.pub-cache')) {
- return path.basename(packageDirectory);
- }
- String packageName = packageNameFor(packageDirectory);
- return _packageVersionFor(packageDirectory);
- } else if (mirror.uri.scheme == 'dart') {
- // If this item is from the SDK, use what version of pub we're running to
- // ascertain the SDK version.
- var pubVersion = Process.runSync(pubScript, ['--version'],
- runInShell: true);
- if (pubVersion.exitCode != 0) {
- print(pubVersion.stderr);
- }
- return pubVersion.stdout.replaceAll('Pub ', '').trim();
- }
- return '';
-}
-
-String _packageVersionHelper(String packageDirectory, String packageName) {
- var publockName = path.join(packageDirectory, 'pubspec.lock');
- File publock = new File(publockName);
- if (!publock.existsSync()) return '';
- var contents = publock.readAsStringSync();
var spec = loadYaml(contents);
- return spec['packages'][packageName];
+ return spec["name"];
}
/// Recursively walk up from directory name looking for a pubspec. Return
« no previous file with comments | « pkg/docgen/lib/src/models/library.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698