Index: sdk/lib/_internal/dartdoc/lib/dartdoc.dart |
diff --git a/sdk/lib/_internal/dartdoc/lib/dartdoc.dart b/sdk/lib/_internal/dartdoc/lib/dartdoc.dart |
index e9882ff8fe61cec26f6448c3b1d39ba1fe53f4ea..0d00b9b397f9765dcc68092c3fb3ca63d31e71c5 100644 |
--- a/sdk/lib/_internal/dartdoc/lib/dartdoc.dart |
+++ b/sdk/lib/_internal/dartdoc/lib/dartdoc.dart |
@@ -143,6 +143,37 @@ Future<bool> compileScript(int mode, Path outputDir, Path libPath) { |
return completer.future; |
} |
+/** |
+ * Package manifest containing all information required to render the main page |
+ * for a package. |
+ * |
+ * The manifest specifies where to load the [LibraryElement]s describing each |
+ * library rather than including them directly. |
+ * For our purposes we treat the dart core libraries as a package. |
Andrei Mouravski
2013/02/08 23:36:31
Either "... the `dart:core` library..." or "... th
Jacob
2013/02/09 02:37:28
Done.
|
+ */ |
+class PackageManifest { |
+ /** Package name. */ |
+ final name; |
+ /** Package description */ |
+ final description; |
+ /** Libraries contained in this package. */ |
+ final List<String> libraries = <String>[]; |
+ /** Descriptive string describing the version# of the package. */ |
Andrei Mouravski
2013/02/08 23:36:31
What makes the string "descriptive"? Is that like,
Jacob
2013/02/09 02:37:28
* The current format for dart-sdk versions is
*
|
+ final String fullVersion; |
+ /** Source control revision # of the package. */ |
Andrei Mouravski
2013/02/08 23:36:31
What do you mean by revision #? Is this like build
Jacob
2013/02/09 02:37:28
currently 18233 for SVN. Will use hashes for git.
Jacob
2013/02/09 02:37:28
* Source control revision number for the package.
|
+ final String revision; |
+ /** Path to the directory containing data files for each library. */ |
+ String location; |
Andrei Mouravski
2013/02/08 23:36:31
Is this the lib dir or the src dir. How does this
Jacob
2013/02/09 02:37:28
This is for the serialized version (json) for the
|
+ /** |
+ * Packages depended on by this package. |
+ * We currently store the entire manifest for the depency here the manifests |
+ * are small. We may want to change this to a reference in the future. |
+ */ |
+ final List<PackageManifest> dependencies = <PackageManifest>[]; |
+ |
+ PackageManifest(this.name, this.description, this.fullVersion, this.revision); |
+} |
+ |
class Dartdoc { |
/** Set to `false` to not include the source code in the generated docs. */ |
@@ -207,6 +238,9 @@ class Dartdoc { |
/** Set this to inherit from Object. */ |
bool inheritFromObject = false; |
+ /** Version of the sdk or package docs are being generated for. */ |
+ String version; |
+ |
/** Set this to select the libraries to include in the documentation. */ |
List<String> includedLibraries = const <String>[]; |
@@ -356,11 +390,34 @@ class Dartdoc { |
generateAppCacheManifest(); |
} |
+ // TODO(jacobr): handle arbitrary pub packages rather than just the system |
+ // libraries. |
+ var revision = ''; |
+ if (version != null) { |
+ revision = new RegExp(r"_r(\d+)_").firstMatch(version).group(1); |
+ } |
+ var packageManifest = new PackageManifest('dart:', 'Dart System Libraries', |
+ version, revision); |
+ |
+ for (final lib in _sortedLibraries) { |
+ var libraryElement = new LibraryElement(lib.qualifiedName, lib) |
+ ..stripDuplicateUris(null, null); |
+ packageManifest.libraries.add(libraryElement.id); |
+ startFile("$revision/${libraryElement.id}.json"); |
+ |
+ write(json_serializer.serialize(libraryElement)); |
+ endFile(); |
+ } |
+ |
+ startFile("$revision/apidoc.json"); |
+ write(json_serializer.serialize(packageManifest)); |
+ endFile(); |
+ |
+ // Write out top level json file with a relative path to the library json |
+ // files. |
startFile("apidoc.json"); |
- var libraries = _sortedLibraries.map( |
- (lib) => new LibraryElement(lib.qualifiedName, lib)) |
- .toList(); |
- write(json_serializer.serialize(libraries)); |
+ packageManifest.location = revision; |
+ write(json_serializer.serialize(packageManifest)); |
endFile(); |
} |