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

Unified Diff: lib/dartdoc/dartdoc.dart

Issue 9844031: add disqus comments (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: lib/dartdoc/dartdoc.dart
diff --git a/lib/dartdoc/dartdoc.dart b/lib/dartdoc/dartdoc.dart
index fd8ecd12b666d9b1e20eef1cae122632d9b5d0e9..ff7403df8479b27147cd69f4500ac73abbb90dfa 100644
--- a/lib/dartdoc/dartdoc.dart
+++ b/lib/dartdoc/dartdoc.dart
@@ -28,27 +28,6 @@
#source('utils.dart');
/**
- * Generates completely static HTML containing everything you need to browse
- * the docs. The only client side behavior is trivial stuff like syntax
- * highlighting code.
- */
-final MODE_STATIC = 0;
-
-/**
- * Generated docs do not include baked HTML navigation. Instead, a single
- * `nav.json` file is created and the appropriate navigation is generated
- * client-side by parsing that and building HTML.
- *
- * This dramatically reduces the generated size of the HTML since a large
- * fraction of each static page is just redundant navigation links.
- *
- * In this mode, the browser will do a XHR for nav.json which means that to
- * preview docs locally, you will need to enable requesting file:// links in
- * your browser or run a little local server like `python -m SimpleHTTPServer`.
- */
-final MODE_LIVE_NAV = 1;
-
-/**
* Run this from the `lib/dartdoc` directory.
*/
void main() {
@@ -56,7 +35,7 @@ void main() {
// Parse the dartdoc options.
bool includeSource;
- String mode;
+ int mode;
String outputDir;
for (int i = 0; i < args.length - 1; i++) {
@@ -68,11 +47,11 @@ void main() {
break;
case '--mode=static':
- mode = MODE_STATIC;
+ mode = Dartdoc.MODE_STATIC;
break;
case '--mode=live-nav':
- mode = MODE_LIVE_NAV;
+ mode = Dartdoc.MODE_LIVE_NAV;
break;
default:
@@ -110,7 +89,7 @@ void main() {
cleanOutputDirectory(dartdoc.outputDir);
// Compile the client-side code to JS.
- final clientScript = (dartdoc.mode == MODE_STATIC) ? 'static' : 'live-nav';
+ final clientScript = (dartdoc.mode == Dartdoc.MODE_STATIC) ? 'static' : 'live-nav';
compileScript(compilerPath, libDir, '$scriptDir/client-$clientScript.dart',
'${dartdoc.outputDir}/client-$clientScript.js');
@@ -182,12 +161,34 @@ void compileScript(String compilerPath, String libDir,
process.stdout.pipe(stdout, close: false);
process.onError = (error) {
- print('Failed to compile $dartPath. Error:');
+ print('Failed to compile $dartPath with $compilerPath. Error:');
print(error);
};
}
class Dartdoc {
+
Bob Nystrom 2012/03/28 20:01:21 Why move these here?
sethladd 2012/03/28 21:52:17 Good question, I think I was trying something else
+ /**
+ * Generates completely static HTML containing everything you need to browse
+ * the docs. The only client side behavior is trivial stuff like syntax
+ * highlighting code.
+ */
+ static final MODE_STATIC = 0;
+
+ /**
+ * Generated docs do not include baked HTML navigation. Instead, a single
+ * `nav.json` file is created and the appropriate navigation is generated
+ * client-side by parsing that and building HTML.
+ *
+ * This dramatically reduces the generated size of the HTML since a large
+ * fraction of each static page is just redundant navigation links.
+ *
+ * In this mode, the browser will do a XHR for nav.json which means that to
+ * preview docs locally, you will need to enable requesting file:// links in
+ * your browser or run a little local server like `python -m SimpleHTTPServer`.
+ */
+ static final MODE_LIVE_NAV = 1;
+
/** Set to `false` to not include the source code in the generated docs. */
bool includeSource = true;
@@ -224,6 +225,9 @@ class Dartdoc {
/** Set this to add footer text to each generated page. */
String footerText = '';
+ /** Set this to add content before the footer */
+ String preFooterText = '';
+
/**
* From exposes the set of libraries in `world.libraries`. That maps library
* *keys* to [Library] objects. The keys are *not* exactly the same as their
@@ -286,7 +290,7 @@ class Dartdoc {
});
// Generate the docs.
- if (mode == MODE_LIVE_NAV) docNavigationJson();
+ if (mode == Dartdoc.MODE_LIVE_NAV) docNavigationJson();
docIndex();
for (final library in _sortedLibraries) {
@@ -393,8 +397,8 @@ class Dartdoc {
String get clientScript() {
switch (mode) {
- case MODE_STATIC: return 'client-static';
- case MODE_LIVE_NAV: return 'client-live-nav';
+ case Dartdoc.MODE_STATIC: return 'client-static';
+ case Dartdoc.MODE_LIVE_NAV: return 'client-live-nav';
default: throw 'Unknown mode $mode.';
}
}
@@ -405,10 +409,9 @@ class Dartdoc {
<meta charset="utf-8">
<title>$title</title>
<link rel="stylesheet" type="text/css"
- href="${relativePath('styles.css')}" />
+ href="${relativePath('styles.css')}">
<link href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800" rel="stylesheet" type="text/css">
- <link rel="shortcut icon" href="${relativePath('favicon.ico')}" />
- <script src="${relativePath('$clientScript.js')}"></script>
+ <link rel="shortcut icon" href="${relativePath('favicon.ico')}">
''');
}
@@ -418,7 +421,9 @@ class Dartdoc {
</div>
<div class="clear"></div>
</div>
+ ${preFooterText}
<div class="footer">$footerText</div>
+ <script async src="${relativePath('$clientScript.js')}"></script>
Bob Nystrom 2012/03/28 20:01:21 \o/
sethladd 2012/03/28 21:52:17 Done.
</body></html>
''');
}
@@ -481,7 +486,7 @@ class Dartdoc {
<div class="nav">
''');
- if (mode == MODE_STATIC) {
+ if (mode == Dartdoc.MODE_STATIC) {
for (final library in _sortedLibraries) {
write('<h2><div class="icon-library"></div>');
« no previous file with comments | « lib/dartdoc/client-shared.dart ('k') | utils/apidoc/README.txt » ('j') | utils/apidoc/README.txt » ('J')

Powered by Google App Engine
This is Rietveld 408576698