| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 final Future scriptCompiled = compileScript(compilerPath, | 134 final Future scriptCompiled = compileScript(compilerPath, |
| 135 '$scriptDir/client-$clientScript.dart', | 135 '$scriptDir/client-$clientScript.dart', |
| 136 '${dartdoc.outputDir}/client-$clientScript.js'); | 136 '${dartdoc.outputDir}/client-$clientScript.js'); |
| 137 | 137 |
| 138 final Future filesCopied = copyFiles('$scriptDir/static', dartdoc.outputDir); | 138 final Future filesCopied = copyFiles('$scriptDir/static', dartdoc.outputDir); |
| 139 | 139 |
| 140 Futures.wait([scriptCompiled, filesCopied]).then((_) { | 140 Futures.wait([scriptCompiled, filesCopied]).then((_) { |
| 141 dartdoc.document(entrypoint); | 141 dartdoc.document(entrypoint); |
| 142 }); | 142 }); |
| 143 | 143 |
| 144 print('Documented ${dartdoc._totalLibraries} libraries, ' + | 144 print('Documented ${dartdoc._totalLibraries} libraries, ' |
| 145 '${dartdoc._totalTypes} types, and ' + | 145 '${dartdoc._totalTypes} types, and ' |
| 146 '${dartdoc._totalMembers} members.'); | 146 '${dartdoc._totalMembers} members.'); |
| 147 } | 147 } |
| 148 | 148 |
| 149 /** | 149 /** |
| 150 * Gets the full path to the directory containing the entrypoint of the current | 150 * Gets the full path to the directory containing the entrypoint of the current |
| 151 * script. In other words, if you invoked dartdoc, directly, it will be the | 151 * script. In other words, if you invoked dartdoc, directly, it will be the |
| 152 * path to the directory containing `dartdoc.dart`. If you're running a script | 152 * path to the directory containing `dartdoc.dart`. If you're running a script |
| 153 * that imports dartdoc, it will be the path to that script. | 153 * that imports dartdoc, it will be the path to that script. |
| 154 */ | 154 */ |
| 155 String get scriptDir() { | 155 String get scriptDir() { |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 ''' | 416 ''' |
| 417 <!DOCTYPE html> | 417 <!DOCTYPE html> |
| 418 <html${htmlAttributes == '' ? '' : ' $htmlAttributes'}> | 418 <html${htmlAttributes == '' ? '' : ' $htmlAttributes'}> |
| 419 <head> | 419 <head> |
| 420 '''); | 420 '''); |
| 421 writeHeadContents(title); | 421 writeHeadContents(title); |
| 422 | 422 |
| 423 // Add data attributes describing what the page documents. | 423 // Add data attributes describing what the page documents. |
| 424 var data = ''; | 424 var data = ''; |
| 425 if (_currentLibrary != null) { | 425 if (_currentLibrary != null) { |
| 426 data += ' data-library="${md.escapeHtml(_currentLibrary.name)}"'; | 426 data = '$data data-library="${md.escapeHtml(_currentLibrary.name)}"'; |
| 427 } | 427 } |
| 428 | 428 |
| 429 if (_currentType != null) { | 429 if (_currentType != null) { |
| 430 data += ' data-type="${md.escapeHtml(typeName(_currentType))}"'; | 430 data = '$data data-type="${md.escapeHtml(typeName(_currentType))}"'; |
| 431 } | 431 } |
| 432 | 432 |
| 433 write( | 433 write( |
| 434 ''' | 434 ''' |
| 435 </head> | 435 </head> |
| 436 <body$data> | 436 <body$data> |
| 437 <div class="page"> | 437 <div class="page"> |
| 438 <div class="header"> | 438 <div class="header"> |
| 439 ${a(mainUrl, '<div class="logo"></div>')} | 439 ${a(mainUrl, '<div class="logo"></div>')} |
| 440 ${a('index.html', mainTitle)} | 440 ${a('index.html', mainTitle)} |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 /** | 1089 /** |
| 1090 * Converts [fullPath] which is understood to be a full path from the root of | 1090 * Converts [fullPath] which is understood to be a full path from the root of |
| 1091 * the generated docs to one relative to the current file. | 1091 * the generated docs to one relative to the current file. |
| 1092 */ | 1092 */ |
| 1093 String relativePath(String fullPath) { | 1093 String relativePath(String fullPath) { |
| 1094 // Don't make it relative if it's an absolute path. | 1094 // Don't make it relative if it's an absolute path. |
| 1095 if (isAbsolute(fullPath)) return fullPath; | 1095 if (isAbsolute(fullPath)) return fullPath; |
| 1096 | 1096 |
| 1097 // TODO(rnystrom): Walks all the way up to root each time. Shouldn't do | 1097 // TODO(rnystrom): Walks all the way up to root each time. Shouldn't do |
| 1098 // this if the paths overlap. | 1098 // this if the paths overlap. |
| 1099 return repeat('../', countOccurrences(_filePath, '/')) + fullPath; | 1099 return '${repeat('../', countOccurrences(_filePath, '/'))}$fullPath'; |
| 1100 } | 1100 } |
| 1101 | 1101 |
| 1102 /** Gets whether or not the given URL is absolute or relative. */ | 1102 /** Gets whether or not the given URL is absolute or relative. */ |
| 1103 bool isAbsolute(String url) { | 1103 bool isAbsolute(String url) { |
| 1104 // TODO(rnystrom): Why don't we have a nice type in the platform for this? | 1104 // TODO(rnystrom): Why don't we have a nice type in the platform for this? |
| 1105 // TODO(rnystrom): This is a bit hackish. We consider any URL that lacks | 1105 // TODO(rnystrom): This is a bit hackish. We consider any URL that lacks |
| 1106 // a scheme to be relative. | 1106 // a scheme to be relative. |
| 1107 return const RegExp(@'^\w+:').hasMatch(url); | 1107 return const RegExp(@'^\w+:').hasMatch(url); |
| 1108 } | 1108 } |
| 1109 | 1109 |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1387 if (filename.endsWith('appcache.manifest')) { | 1387 if (filename.endsWith('appcache.manifest')) { |
| 1388 return; | 1388 return; |
| 1389 } | 1389 } |
| 1390 var relativePath = filename.substring(pathPrefixLength + 1); | 1390 var relativePath = filename.substring(pathPrefixLength + 1); |
| 1391 write("$relativePath\n"); | 1391 write("$relativePath\n"); |
| 1392 }; | 1392 }; |
| 1393 toCache.onDone = (done) => endFile(); | 1393 toCache.onDone = (done) => endFile(); |
| 1394 toCache.list(recursive: true); | 1394 toCache.list(recursive: true); |
| 1395 } | 1395 } |
| 1396 } | 1396 } |
| OLD | NEW |