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 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 743 dir.renameSync(_webDocsDir.path); | 743 dir.renameSync(_webDocsDir.path); |
| 744 } | 744 } |
| 745 } else { | 745 } else { |
| 746 print('Error cloning git repository:'); | 746 print('Error cloning git repository:'); |
| 747 print('process output: ${processResult.stdout}'); | 747 print('process output: ${processResult.stdout}'); |
| 748 print('process stderr: ${processResult.stderr}'); | 748 print('process stderr: ${processResult.stderr}'); |
| 749 } | 749 } |
| 750 } | 750 } |
| 751 } | 751 } |
| 752 | 752 |
| 753 /// Move the generated json/yaml docs directory to the dartdoc-viewer | |
| 754 /// directory, to run as a webpage. | |
| 755 static void _moveDirectoryAndServe() { | |
|
kevmoo
2014/03/05 03:57:18
I just grabbed it as it was in r32632
No promises
Emily Fortuna
2014/03/05 18:30:36
Yay, thank you! :-)
| |
| 756 var processResult = Process.runSync(_Generator._pubScript, ['upgrade'], | |
| 757 runInShell: true, workingDirectory: path.join(_dartdocViewerDir.path, | |
| 758 'client')); | |
| 759 print('process output: ${processResult.stdout}'); | |
| 760 print('process stderr: ${processResult.stderr}'); | |
| 761 | |
| 762 var dir = new Directory(_Generator._outputDirectory == null? 'docs' : | |
| 763 _Generator._outputDirectory); | |
| 764 var webDocsDir = new Directory(path.join(_dartdocViewerDir.path, 'client', | |
| 765 'web', 'docs')); | |
| 766 if (dir.existsSync()) { | |
| 767 // Move the docs folder to dartdoc-viewer/client/web/docs | |
| 768 dir.renameSync(webDocsDir.path); | |
| 769 } | |
| 770 | |
| 771 if (webDocsDir.existsSync()) { | |
| 772 // Compile the code to JavaScript so we can run on any browser. | |
| 773 print('Compile app to JavaScript for viewing.'); | |
| 774 var processResult = Process.runSync(_Generator._dartBinary, | |
| 775 ['deploy.dart'], workingDirectory : path.join(_dartdocViewerDir.path, | |
| 776 'client'), runInShell: true); | |
| 777 print('process output: ${processResult.stdout}'); | |
| 778 print('process stderr: ${processResult.stderr}'); | |
| 779 _runServer(); | |
| 780 } | |
| 781 } | |
| 782 | |
| 753 static void _compile() { | 783 static void _compile() { |
| 754 if (_webDocsDir.existsSync()) { | 784 if (_webDocsDir.existsSync()) { |
| 755 // Compile the code to JavaScript so we can run on any browser. | 785 // Compile the code to JavaScript so we can run on any browser. |
| 756 print('Compile app to JavaScript for viewing.'); | 786 print('Compile app to JavaScript for viewing.'); |
| 757 var processResult = Process.runSync(_Generator._dartBinary, | 787 var processResult = Process.runSync(_Generator._dartBinary, |
| 758 ['deploy.dart'], workingDirectory: viewerCodePath, runInShell: true); | 788 ['deploy.dart'], workingDirectory: viewerCodePath, runInShell: true); |
| 759 print('process output: ${processResult.stdout}'); | 789 print('process output: ${processResult.stdout}'); |
| 760 print('process stderr: ${processResult.stderr}'); | 790 print('process stderr: ${processResult.stderr}'); |
| 761 var outputDir = path.join(viewerCodePath, 'out', 'web'); | 791 var outputDir = path.join(viewerCodePath, 'out', 'web'); |
| 762 print('Docs are available at $outputDir'); | 792 print('Docs are available at $outputDir'); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 982 return '<div class="mdn">' + content.trim() + '<p class="mdn-note">' | 1012 return '<div class="mdn">' + content.trim() + '<p class="mdn-note">' |
| 983 '<a href="' + url.trim() + '">from Mdn</a></p></div>'; | 1013 '<a href="' + url.trim() + '">from Mdn</a></p></div>'; |
| 984 } | 1014 } |
| 985 | 1015 |
| 986 /// The type of this member to be used in index.txt. | 1016 /// The type of this member to be used in index.txt. |
| 987 String get typeName => ''; | 1017 String get typeName => ''; |
| 988 | 1018 |
| 989 /// Creates a [Map] with this [Indexable]'s name and a preview comment. | 1019 /// Creates a [Map] with this [Indexable]'s name and a preview comment. |
| 990 Map get previewMap { | 1020 Map get previewMap { |
| 991 var finalMap = { 'name' : name, 'qualifiedName' : qualifiedName }; | 1021 var finalMap = { 'name' : name, 'qualifiedName' : qualifiedName }; |
| 1022 var preview = _preview; | |
| 1023 if(preview != null) finalMap['preview'] = preview; | |
| 1024 return finalMap; | |
| 1025 } | |
| 1026 | |
| 1027 String get _preview { | |
| 992 if (comment != '') { | 1028 if (comment != '') { |
| 993 var index = comment.indexOf('</p>'); | 1029 var index = comment.indexOf('</p>'); |
| 994 finalMap['preview'] = index > 0 ? | 1030 return index > 0 ? |
| 995 '${comment.substring(0, index)}</p>' : | 1031 '${comment.substring(0, index)}</p>' : |
| 996 '<p><i>Comment preview not available</i></p>'; | 1032 '<p><i>Comment preview not available</i></p>'; |
| 997 } | 1033 } |
| 998 return finalMap; | 1034 return null; |
| 999 } | 1035 } |
| 1000 | 1036 |
| 1001 /// Accessor to obtain the raw comment text for a given item, _without_ any | 1037 /// Accessor to obtain the raw comment text for a given item, _without_ any |
| 1002 /// of the links resolved. | 1038 /// of the links resolved. |
| 1003 String get _commentText { | 1039 String get _commentText { |
| 1004 String commentText; | 1040 String commentText; |
| 1005 mirror.metadata.forEach((metadata) { | 1041 mirror.metadata.forEach((metadata) { |
| 1006 if (metadata is CommentInstanceMirror) { | 1042 if (metadata is CommentInstanceMirror) { |
| 1007 CommentInstanceMirror comment = metadata; | 1043 CommentInstanceMirror comment = metadata; |
| 1008 if (comment.isDocComment) { | 1044 if (comment.isDocComment) { |
| (...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1911 } | 1947 } |
| 1912 | 1948 |
| 1913 Typedef._(TypedefMirror mirror, Library owningLibrary) : | 1949 Typedef._(TypedefMirror mirror, Library owningLibrary) : |
| 1914 super(mirror, owningLibrary) { | 1950 super(mirror, owningLibrary) { |
| 1915 returnType = Indexable.getDocgenObject(mirror.referent.returnType).docName; | 1951 returnType = Indexable.getDocgenObject(mirror.referent.returnType).docName; |
| 1916 generics = _createGenerics(mirror); | 1952 generics = _createGenerics(mirror); |
| 1917 parameters = _createParameters(mirror.referent.parameters, owningLibrary); | 1953 parameters = _createParameters(mirror.referent.parameters, owningLibrary); |
| 1918 annotations = MirrorBased._createAnnotations(mirror, owningLibrary); | 1954 annotations = MirrorBased._createAnnotations(mirror, owningLibrary); |
| 1919 } | 1955 } |
| 1920 | 1956 |
| 1921 Map toMap() => { | 1957 Map toMap() { |
| 1922 'name': name, | 1958 var map = { |
| 1923 'qualifiedName': qualifiedName, | 1959 'name': name, |
| 1924 'comment': comment, | 1960 'qualifiedName': qualifiedName, |
| 1925 'return': returnType, | 1961 'comment': comment, |
| 1926 'parameters': recurseMap(parameters), | 1962 'return': returnType, |
| 1927 'annotations': annotations.map((a) => a.toMap()).toList(), | 1963 'parameters': recurseMap(parameters), |
| 1928 'generics': recurseMap(generics) | 1964 'annotations': annotations.map((a) => a.toMap()).toList(), |
| 1929 }; | 1965 'generics': recurseMap(generics) |
| 1966 }; | |
| 1967 | |
| 1968 // Typedef is displayed on the library page as a class, so a preview is | |
| 1969 // added manually | |
| 1970 var preview = _preview; | |
| 1971 if(preview != null) map['preview'] = preview; | |
| 1972 | |
| 1973 return map; | |
| 1974 } | |
| 1930 | 1975 |
| 1931 markdown.Node fixReference(String name) => null; | 1976 markdown.Node fixReference(String name) => null; |
| 1932 | 1977 |
| 1933 String get typeName => 'typedef'; | 1978 String get typeName => 'typedef'; |
| 1934 | 1979 |
| 1935 bool _isValidMirror(DeclarationMirror mirror) => mirror is TypedefMirror; | 1980 bool _isValidMirror(DeclarationMirror mirror) => mirror is TypedefMirror; |
| 1936 } | 1981 } |
| 1937 | 1982 |
| 1938 /// A class containing properties of a Dart variable. | 1983 /// A class containing properties of a Dart variable. |
| 1939 class Variable extends OwnedIndexable { | 1984 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) | 2308 .map((e) => originalMirror.getField(e.simpleName).reflectee) |
| 2264 .where((e) => e != null) | 2309 .where((e) => e != null) |
| 2265 .toList(); | 2310 .toList(); |
| 2266 } | 2311 } |
| 2267 | 2312 |
| 2268 Map toMap() => { | 2313 Map toMap() => { |
| 2269 'name': Indexable.getDocgenObject(mirror, owningLibrary).docName, | 2314 'name': Indexable.getDocgenObject(mirror, owningLibrary).docName, |
| 2270 'parameters': parameters | 2315 'parameters': parameters |
| 2271 }; | 2316 }; |
| 2272 } | 2317 } |
| OLD | NEW |