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

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

Issue 55453002: Fixes to find the path after changes to Platform, but now working reliably (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Pulled out into a function Created 7 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/docgen/lib/docgen.dart
diff --git a/pkg/docgen/lib/docgen.dart b/pkg/docgen/lib/docgen.dart
index 7f4dd9cde1eb0d7d70934aca6c135f7a1dbabe8d..4c1f85d558f0e8abb376058c2934ad297c7e56c4 100644
--- a/pkg/docgen/lib/docgen.dart
+++ b/pkg/docgen/lib/docgen.dart
@@ -249,13 +249,22 @@ Future<MirrorSystem> getMirrorSystem(List<String> args, {String packageRoot,
var libraries = !parseSdk ? _listLibraries(args) : _listSdk();
if (libraries.isEmpty) throw new StateError('No Libraries.');
// Finds the root of SDK library based off the location of docgen.
- var scriptDir = path.absolute(path.dirname(Platform.script.toFilePath()));
- var sdkRoot = path.relative('../../../sdk', from: scriptDir);
- sdkRoot = path.normalize(path.absolute(sdkRoot));
+
+ var root = findRootDirectory();
+ var sdkRoot = path.normalize(path.absolute(path.join(root, 'sdk')));
logger.info('SDK Root: ${sdkRoot}');
return _analyzeLibraries(libraries, sdkRoot, packageRoot: packageRoot);
}
+String findRootDirectory() {
+ var scriptDir = path.absolute(path.dirname(Platform.script.toFilePath()));
+ var root = scriptDir;
+ while(path.basename(root) != 'dart') {
+ root = path.dirname(root);
+ }
+ return root;
+}
+
/**
* Analyzes set of libraries and provides a mirror system which can be used
* for static inspection of the source code.
@@ -480,9 +489,8 @@ void _mdnComment(Indexable item) {
//Check if MDN is loaded.
if (_mdn == null) {
// Reading in MDN related json file.
- var scriptDir = path.absolute(path.dirname(Platform.script.toFilePath()));
- var mdnPath = path.relative('../../../utils/apidoc/mdn/database.json',
- from: scriptDir);
+ var root = findRootDirectory();
+ var mdnPath = path.join(root, 'utils/apidoc/mdn/database.json');
_mdn = JSON.decode(new File(mdnPath).readAsStringSync());
}
if (item.comment.isNotEmpty) return;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698