Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 /// **docgen** is a tool for creating machine readable representations of Dart | 5 /// **docgen** is a tool for creating machine readable representations of Dart |
| 6 /// code metadata, including: classes, members, comments and annotations. | 6 /// code metadata, including: classes, members, comments and annotations. |
| 7 /// | 7 /// |
| 8 /// docgen is run on a `.dart` file or a directory containing `.dart` files. | 8 /// docgen is run on a `.dart` file or a directory containing `.dart` files. |
| 9 /// | 9 /// |
| 10 /// $ dart docgen.dart [OPTIONS] [FILE/DIR] | 10 /// $ dart docgen.dart [OPTIONS] [FILE/DIR] |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 710 } | 710 } |
| 711 } | 711 } |
| 712 | 712 |
| 713 /// Move the dartdoc-viewer code back into place for "webpage deployment." | 713 /// Move the dartdoc-viewer code back into place for "webpage deployment." |
| 714 static void addBackViewerCode() { | 714 static void addBackViewerCode() { |
| 715 if (movedViewerCode) _dartdocViewerDir.renameSync(_dartdocViewerString); | 715 if (movedViewerCode) _dartdocViewerDir.renameSync(_dartdocViewerString); |
| 716 } | 716 } |
| 717 | 717 |
| 718 /// Serve up our generated documentation for viewing in a browser. | 718 /// Serve up our generated documentation for viewing in a browser. |
| 719 static void _clone() { | 719 static void _clone() { |
| 720 // If the viewer code is already there, then don't clone again. | 720 // TODO(16959) _moveDirectoryAndServe was removed in 32639 without cleaning |
| 721 if (_dartdocViewerDir.existsSync()) { | 721 // up this call. |
| 722 _moveDirectoryAndServe(); | 722 // if (_dartdocViewerDir.existsSync()) { |
| 723 } | 723 // _moveDirectoryAndServe(); |
|
Emily Fortuna
2014/03/05 01:35:30
I thought you were going to add back in the functi
| |
| 724 else { | 724 // } |
| 725 var processResult = Process.runSync('git', ['clone', '-b', 'master', | |
| 726 'git://github.com/dart-lang/dartdoc-viewer.git'], | |
| 727 runInShell: true); | |
| 728 | 725 |
| 729 if (processResult.exitCode == 0) { | 726 var processResult = Process.runSync('git', ['clone', '-b', 'master', |
| 730 /// Move the generated json/yaml docs directory to the dartdoc-viewer | 727 'git://github.com/dart-lang/dartdoc-viewer.git'], |
| 731 /// directory, to run as a webpage. | 728 runInShell: true); |
| 732 var processResult = Process.runSync(_Generator._pubScript, | |
| 733 ['upgrade'], runInShell: true, | |
| 734 workingDirectory: viewerCodePath); | |
| 735 print('process output: ${processResult.stdout}'); | |
| 736 print('process stderr: ${processResult.stderr}'); | |
| 737 | 729 |
| 738 var dir = new Directory(_Generator._outputDirectory == null? 'docs' : | 730 if (processResult.exitCode == 0) { |
| 739 _Generator._outputDirectory); | 731 /// Move the generated json/yaml docs directory to the dartdoc-viewer |
| 740 _webDocsDir = new Directory(path.join(viewerCodePath, 'web', 'docs')); | 732 /// directory, to run as a webpage. |
| 741 if (dir.existsSync()) { | 733 var processResult = Process.runSync(_Generator._pubScript, |
| 742 // Move the docs folder to dartdoc-viewer/client/web/docs | 734 ['upgrade'], runInShell: true, |
| 743 dir.renameSync(_webDocsDir.path); | 735 workingDirectory: viewerCodePath); |
| 744 } | 736 print('process output: ${processResult.stdout}'); |
| 745 } else { | 737 print('process stderr: ${processResult.stderr}'); |
| 746 print('Error cloning git repository:'); | 738 |
| 747 print('process output: ${processResult.stdout}'); | 739 var dir = new Directory(_Generator._outputDirectory == null? 'docs' : |
| 748 print('process stderr: ${processResult.stderr}'); | 740 _Generator._outputDirectory); |
| 741 _webDocsDir = new Directory(path.join(viewerCodePath, 'web', 'docs')); | |
| 742 if (dir.existsSync()) { | |
| 743 // Move the docs folder to dartdoc-viewer/client/web/docs | |
| 744 dir.renameSync(_webDocsDir.path); | |
| 749 } | 745 } |
| 746 } else { | |
| 747 print('Error cloning git repository:'); | |
|
Emily Fortuna
2014/03/05 01:35:30
no please add back in moveDirectoryAndServe!
| |
| 748 print('process output: ${processResult.stdout}'); | |
| 749 print('process stderr: ${processResult.stderr}'); | |
| 750 } | 750 } |
| 751 } | 751 } |
| 752 | 752 |
| 753 static void _compile() { | 753 static void _compile() { |
| 754 if (_webDocsDir.existsSync()) { | 754 if (_webDocsDir.existsSync()) { |
| 755 // Compile the code to JavaScript so we can run on any browser. | 755 // Compile the code to JavaScript so we can run on any browser. |
| 756 print('Compile app to JavaScript for viewing.'); | 756 print('Compile app to JavaScript for viewing.'); |
| 757 var processResult = Process.runSync(_Generator._dartBinary, | 757 var processResult = Process.runSync(_Generator._dartBinary, |
| 758 ['deploy.dart'], workingDirectory: viewerCodePath, runInShell: true); | 758 ['deploy.dart'], workingDirectory: viewerCodePath, runInShell: true); |
| 759 print('process output: ${processResult.stdout}'); | 759 print('process output: ${processResult.stdout}'); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 982 return '<div class="mdn">' + content.trim() + '<p class="mdn-note">' | 982 return '<div class="mdn">' + content.trim() + '<p class="mdn-note">' |
| 983 '<a href="' + url.trim() + '">from Mdn</a></p></div>'; | 983 '<a href="' + url.trim() + '">from Mdn</a></p></div>'; |
| 984 } | 984 } |
| 985 | 985 |
| 986 /// The type of this member to be used in index.txt. | 986 /// The type of this member to be used in index.txt. |
| 987 String get typeName => ''; | 987 String get typeName => ''; |
| 988 | 988 |
| 989 /// Creates a [Map] with this [Indexable]'s name and a preview comment. | 989 /// Creates a [Map] with this [Indexable]'s name and a preview comment. |
| 990 Map get previewMap { | 990 Map get previewMap { |
| 991 var finalMap = { 'name' : name, 'qualifiedName' : qualifiedName }; | 991 var finalMap = { 'name' : name, 'qualifiedName' : qualifiedName }; |
| 992 var preview = _preview; | |
| 993 if(preview != null) finalMap['preview'] = preview; | |
| 994 return finalMap; | |
| 995 } | |
| 996 | |
| 997 String get _preview { | |
| 992 if (comment != '') { | 998 if (comment != '') { |
| 993 var index = comment.indexOf('</p>'); | 999 var index = comment.indexOf('</p>'); |
| 994 finalMap['preview'] = index > 0 ? | 1000 return index > 0 ? |
| 995 '${comment.substring(0, index)}</p>' : | 1001 '${comment.substring(0, index)}</p>' : |
| 996 '<p><i>Comment preview not available</i></p>'; | 1002 '<p><i>Comment preview not available</i></p>'; |
| 997 } | 1003 } |
| 998 return finalMap; | 1004 return null; |
| 999 } | 1005 } |
| 1000 | 1006 |
| 1001 /// Accessor to obtain the raw comment text for a given item, _without_ any | 1007 /// Accessor to obtain the raw comment text for a given item, _without_ any |
| 1002 /// of the links resolved. | 1008 /// of the links resolved. |
| 1003 String get _commentText { | 1009 String get _commentText { |
| 1004 String commentText; | 1010 String commentText; |
| 1005 mirror.metadata.forEach((metadata) { | 1011 mirror.metadata.forEach((metadata) { |
| 1006 if (metadata is CommentInstanceMirror) { | 1012 if (metadata is CommentInstanceMirror) { |
| 1007 CommentInstanceMirror comment = metadata; | 1013 CommentInstanceMirror comment = metadata; |
| 1008 if (comment.isDocComment) { | 1014 if (comment.isDocComment) { |
| (...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1911 } | 1917 } |
| 1912 | 1918 |
| 1913 Typedef._(TypedefMirror mirror, Library owningLibrary) : | 1919 Typedef._(TypedefMirror mirror, Library owningLibrary) : |
| 1914 super(mirror, owningLibrary) { | 1920 super(mirror, owningLibrary) { |
| 1915 returnType = Indexable.getDocgenObject(mirror.referent.returnType).docName; | 1921 returnType = Indexable.getDocgenObject(mirror.referent.returnType).docName; |
| 1916 generics = _createGenerics(mirror); | 1922 generics = _createGenerics(mirror); |
| 1917 parameters = _createParameters(mirror.referent.parameters, owningLibrary); | 1923 parameters = _createParameters(mirror.referent.parameters, owningLibrary); |
| 1918 annotations = MirrorBased._createAnnotations(mirror, owningLibrary); | 1924 annotations = MirrorBased._createAnnotations(mirror, owningLibrary); |
| 1919 } | 1925 } |
| 1920 | 1926 |
| 1921 Map toMap() => { | 1927 Map toMap() { |
| 1922 'name': name, | 1928 var map = { |
| 1923 'qualifiedName': qualifiedName, | 1929 'name': name, |
| 1924 'comment': comment, | 1930 'qualifiedName': qualifiedName, |
| 1925 'return': returnType, | 1931 'comment': comment, |
| 1926 'parameters': recurseMap(parameters), | 1932 'return': returnType, |
| 1927 'annotations': annotations.map((a) => a.toMap()).toList(), | 1933 'parameters': recurseMap(parameters), |
| 1928 'generics': recurseMap(generics) | 1934 'annotations': annotations.map((a) => a.toMap()).toList(), |
| 1929 }; | 1935 'generics': recurseMap(generics) |
| 1936 }; | |
| 1937 | |
| 1938 // Typedef is displayed on the library page as a class, so a preview is | |
| 1939 // added manually | |
| 1940 var preview = _preview; | |
| 1941 if(preview != null) map['preview'] = preview; | |
| 1942 | |
| 1943 return map; | |
| 1944 } | |
| 1930 | 1945 |
| 1931 markdown.Node fixReference(String name) => null; | 1946 markdown.Node fixReference(String name) => null; |
| 1932 | 1947 |
| 1933 String get typeName => 'typedef'; | 1948 String get typeName => 'typedef'; |
| 1934 | 1949 |
| 1935 bool _isValidMirror(DeclarationMirror mirror) => mirror is TypedefMirror; | 1950 bool _isValidMirror(DeclarationMirror mirror) => mirror is TypedefMirror; |
| 1936 } | 1951 } |
| 1937 | 1952 |
| 1938 /// A class containing properties of a Dart variable. | 1953 /// A class containing properties of a Dart variable. |
| 1939 class Variable extends OwnedIndexable { | 1954 class Variable extends OwnedIndexable { |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2263 .map((e) => originalMirror.getField(e.simpleName).reflectee) | 2278 .map((e) => originalMirror.getField(e.simpleName).reflectee) |
| 2264 .where((e) => e != null) | 2279 .where((e) => e != null) |
| 2265 .toList(); | 2280 .toList(); |
| 2266 } | 2281 } |
| 2267 | 2282 |
| 2268 Map toMap() => { | 2283 Map toMap() => { |
| 2269 'name': Indexable.getDocgenObject(mirror, owningLibrary).docName, | 2284 'name': Indexable.getDocgenObject(mirror, owningLibrary).docName, |
| 2270 'parameters': parameters | 2285 'parameters': parameters |
| 2271 }; | 2286 }; |
| 2272 } | 2287 } |
| OLD | NEW |