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

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

Issue 23596007: Remove usage of dart:json. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 7 years, 3 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
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 *
11 * This will create a "docs" directory with the docs for your libraries. To 11 * This will create a "docs" directory with the docs for your libraries. To
12 * create these beautiful docs, dartdoc parses your library and every library 12 * create these beautiful docs, dartdoc parses your library and every library
13 * it imports (recursively). From each library, it parses all classes and 13 * it imports (recursively). From each library, it parses all classes and
14 * members, finds the associated doc comments and builds crosslinked docs from 14 * members, finds the associated doc comments and builds crosslinked docs from
15 * them. 15 * them.
16 */ 16 */
17 library dartdoc; 17 library dartdoc;
18 18
19 import 'dart:async'; 19 import 'dart:async';
20 import 'dart:convert';
20 import 'dart:io'; 21 import 'dart:io';
21 import 'dart:isolate'; 22 import 'dart:isolate';
22 import 'dart:json' as json;
23 import 'dart:math'; 23 import 'dart:math';
24 24
25 import 'package:path/path.dart' as path; 25 import 'package:path/path.dart' as path;
26 26
27 import 'classify.dart'; 27 import 'classify.dart';
28 import 'markdown.dart' as md; 28 import 'markdown.dart' as md;
29 import 'universe_serializer.dart'; 29 import 'universe_serializer.dart';
30 30
31 import 'src/dartdoc/nav.dart'; 31 import 'src/dartdoc/nav.dart';
32 import 'src/dartdoc/utils.dart'; 32 import 'src/dartdoc/utils.dart';
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 void docIndexLibrary(LibraryMirror library) { 771 void docIndexLibrary(LibraryMirror library) {
772 writeln('<h4>${a(libraryUrl(library), displayName(library))}</h4>'); 772 writeln('<h4>${a(libraryUrl(library), displayName(library))}</h4>');
773 } 773 }
774 774
775 /** 775 /**
776 * Walks the libraries and creates a JSON object containing the data needed 776 * Walks the libraries and creates a JSON object containing the data needed
777 * to generate navigation for them. 777 * to generate navigation for them.
778 */ 778 */
779 void docNavigationJson() { 779 void docNavigationJson() {
780 startFile('nav.json'); 780 startFile('nav.json');
781 writeln(json.stringify(createNavigationInfo())); 781 writeln(JSON.encode(createNavigationInfo()));
782 endFile(); 782 endFile();
783 } 783 }
784 /// Whether dartdoc is running from within the Dart SDK or the 784 /// Whether dartdoc is running from within the Dart SDK or the
785 /// Dart source repository. 785 /// Dart source repository.
786 bool get runningFromSdk => 786 bool get runningFromSdk =>
787 path.extension(Platform.script) == '.snapshot'; 787 path.extension(Platform.script) == '.snapshot';
788 788
789 /// Gets the path to the root directory of the SDK. 789 /// Gets the path to the root directory of the SDK.
790 String get sdkDir => 790 String get sdkDir =>
791 path.dirname(path.dirname(Platform.executable)); 791 path.dirname(path.dirname(Platform.executable));
792 792
793 /// Gets the path to the dartdoc directory normalized for running in different 793 /// Gets the path to the dartdoc directory normalized for running in different
794 /// places. 794 /// places.
795 String get normalizedDartdocPath => path.normalize( 795 String get normalizedDartdocPath => path.normalize(
796 path.absolute(runningFromSdk ? 796 path.absolute(runningFromSdk ?
797 path.join(sdkDir, 'lib', '_internal', 'dartdoc') : 797 path.join(sdkDir, 'lib', '_internal', 'dartdoc') :
798 dartdocPath.toString())); 798 dartdocPath.toString()));
799 799
800 void docNavigationDart() { 800 void docNavigationDart() {
801 var tmpDir = new Directory(tmpPath); 801 var tmpDir = new Directory(tmpPath);
802 if (!tmpDir.existsSync()) { 802 if (!tmpDir.existsSync()) {
803 tmpDir.createSync(); 803 tmpDir.createSync();
804 } 804 }
805 String jsonString = json.stringify(createNavigationInfo()); 805 String jsonString = JSON.encode(createNavigationInfo());
806 String dartString = jsonString.replaceAll(r"$", r"\$"); 806 String dartString = jsonString.replaceAll(r"$", r"\$");
807 var filePath = path.join(tmpPath, 'client.dart'); 807 var filePath = path.join(tmpPath, 'client.dart');
808 808
809 var clientDir = path.join(normalizedDartdocPath,'lib', 'src', 'client'); 809 var clientDir = path.join(normalizedDartdocPath,'lib', 'src', 'client');
810 810
811 writeString(new File(filePath), 811 writeString(new File(filePath),
812 '''library client; 812 '''library client;
813 import 'dart:html'; 813 import 'dart:html';
814 import 'dart:json'; 814 import 'dart:json';
815 import r'${path.toUri(path.join(clientDir, 'client-shared.dart'))}'; 815 import r'${path.toUri(path.join(clientDir, 'client-shared.dart'))}';
(...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after
2320 return ''' 2320 return '''
2321 <div class="mdn"> 2321 <div class="mdn">
2322 $mdnComment 2322 $mdnComment
2323 <div class="mdn-note"><a href="$mdnUrl">from MDN</a></div> 2323 <div class="mdn-note"><a href="$mdnUrl">from MDN</a></div>
2324 </div> 2324 </div>
2325 '''; 2325 ''';
2326 } 2326 }
2327 2327
2328 String toString() => mdnComment; 2328 String toString() => mdnComment;
2329 } 2329 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698