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

Side by Side Diff: sdk/lib/_internal/dartdoc/lib/dartdoc.dart

Issue 16387004: Roll back 16364004 and 16206027. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/dartdoc/bin/dartdoc.dart ('k') | utils/compiler/compiler.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * To generate docs for a library, run this script with the path to an 6 * To generate docs for a library, run this script with the path to an
7 * entrypoint .dart file, like: 7 * entrypoint .dart file, like:
8 * 8 *
9 * $ dart dartdoc.dart foo.dart 9 * $ dart dartdoc.dart foo.dart
10 * 10 *
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 312
313 /** The member that we're currently generating docs for. */ 313 /** The member that we're currently generating docs for. */
314 MemberMirror _currentMember; 314 MemberMirror _currentMember;
315 315
316 /** The path to the file currently being written to, relative to [outdir]. */ 316 /** The path to the file currently being written to, relative to [outdir]. */
317 Path _filePath; 317 Path _filePath;
318 318
319 /** The file currently being written to. */ 319 /** The file currently being written to. */
320 StringBuffer _file; 320 StringBuffer _file;
321 321
322 /**
323 * The temporary directory used for this instance of Dartdoc.
324 * Call [cleanup] to delete it.
325 */
326 Directory _tempDir;
327
328 int _totalLibraries = 0; 322 int _totalLibraries = 0;
329 int _totalTypes = 0; 323 int _totalTypes = 0;
330 int _totalMembers = 0; 324 int _totalMembers = 0;
331 325
332 int get totalLibraries => _totalLibraries; 326 int get totalLibraries => _totalLibraries;
333 int get totalTypes => _totalTypes; 327 int get totalTypes => _totalTypes;
334 int get totalMembers => _totalMembers; 328 int get totalMembers => _totalMembers;
335 329
336 // Check if the compilation has started and finished. 330 // Check if the compilation has started and finished.
337 bool _started = false; 331 bool _started = false;
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 /** 776 /**
783 * Walks the libraries and creates a JSON object containing the data needed 777 * Walks the libraries and creates a JSON object containing the data needed
784 * to generate navigation for them. 778 * to generate navigation for them.
785 */ 779 */
786 void docNavigationJson() { 780 void docNavigationJson() {
787 startFile('nav.json'); 781 startFile('nav.json');
788 writeln(json.stringify(createNavigationInfo())); 782 writeln(json.stringify(createNavigationInfo()));
789 endFile(); 783 endFile();
790 } 784 }
791 785
792 /// Whether dartdoc is running from within the Dart SDK or the
793 /// Dart source repository.
794 bool get runningFromSdk =>
795 pathos.extension(new Options().script) == '.snapshot';
796
797 /// Gets the path to the root directory of the SDK.
798 String get rootDirectory =>
799 pathos.dirname(pathos.dirname(new Options().executable));
800
801 /// Gets the path to the dartdoc directory normalized for running in different
802 /// places.
803 String get normalizedDartdocPath => runningFromSdk ?
804 pathos.join(rootDirectory, 'lib', '_internal', 'dartdoc') :
805 dartdocPath.toString();
806
807 /// The path to the temporary directory in the SDK.
808 // TODO(amouravski): Remove this and use a REAL temporary directory.
809 String get tempPath => pathos.join(normalizedDartdocPath, 'tmp');
810
811 void docNavigationDart() { 786 void docNavigationDart() {
812 _tempDir = new Directory(tempPath); 787 final dir = new Directory.fromPath(tmpPath);
813 if (!_tempDir.existsSync()) { 788 if (!dir.existsSync()) {
814 // TODO(3914): Hack to avoid 'file already exists' exception 789 // TODO(3914): Hack to avoid 'file already exists' exception
815 // thrown due to invalid result from dir.existsSync() (probably due to 790 // thrown due to invalid result from dir.existsSync() (probably due to
816 // race conditions). 791 // race conditions).
817 try { 792 try {
818 _tempDir.createSync(); 793 dir.createSync();
819 } on DirectoryIOException catch (e) { 794 } on DirectoryIOException catch (e) {
820 // Ignore. 795 // Ignore.
821 } 796 }
822 } 797 }
823 String jsonString = json.stringify(createNavigationInfo()); 798 String jsonString = json.stringify(createNavigationInfo());
824 String dartString = jsonString.replaceAll(r"$", r"\$"); 799 String dartString = jsonString.replaceAll(r"$", r"\$");
825 800 final filePath = tmpPath.append('nav.dart');
826 var navPath = pathos.join(tempPath, 'nav.dart'); 801 writeString(new File.fromPath(filePath),
827 writeString(new File(navPath),
828 '''part of client; 802 '''part of client;
829 get json => $dartString;'''); 803 get json => $dartString;''');
830 } 804 }
831 805
806 Path get tmpPath => dartdocPath.append('tmp');
807
832 void cleanup() { 808 void cleanup() {
833 if (_tempDir.existsSync()) { 809 final dir = new Directory.fromPath(tmpPath);
834 _tempDir.deleteSync(recursive: true); 810 if (dir.existsSync()) {
811 dir.deleteSync(recursive: true);
835 } 812 }
836 } 813 }
837 814
838 List createNavigationInfo() { 815 List createNavigationInfo() {
839 final libraryList = []; 816 final libraryList = [];
840 for (final library in _sortedLibraries) { 817 for (final library in _sortedLibraries) {
841 docLibraryNavigationJson(library, libraryList); 818 docLibraryNavigationJson(library, libraryList);
842 } 819 }
843 return libraryList; 820 return libraryList;
844 } 821 }
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after
2300 return ''' 2277 return '''
2301 <div class="mdn"> 2278 <div class="mdn">
2302 $mdnComment 2279 $mdnComment
2303 <div class="mdn-note"><a href="$mdnUrl">from MDN</a></div> 2280 <div class="mdn-note"><a href="$mdnUrl">from MDN</a></div>
2304 </div> 2281 </div>
2305 '''; 2282 ''';
2306 } 2283 }
2307 2284
2308 String toString() => mdnComment; 2285 String toString() => mdnComment;
2309 } 2286 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/dartdoc/bin/dartdoc.dart ('k') | utils/compiler/compiler.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698