Add capability for instance documentation, added dependency

Broke some links, going to fix those later
This commit is contained in:
Sashko Stubailo
2014-08-26 10:12:32 -07:00
parent 3cf303d8ce
commit dbaf42e6ea
8 changed files with 79 additions and 25 deletions

View File

@@ -1 +1 @@
METEOR-CORE@0.9.0-rc12
METEOR@0.9.0

View File

@@ -31,11 +31,11 @@
</template>
<template name="autoApiBox">
{{#with apiData}}
{{#with apiData this}}
<div class="api {{bare}}">
<h3 id="{{link}}">
<a class="name selflink" href="#{{link}}">
{{{longname}}}({{paramsSentence}})
{{{name}}}({{paramsSentence}})
</a>
{{#if locus}}
<span class="locus">{{locus}}</span>

View File

@@ -1,14 +1,15 @@
var apiData = function (longname) {
var root = DocsData;
_.each(longname.split("."), function (pathSegment) {
root = root[pathSegment];
});
return root;
};
Template.autoApiBox.helpers({
apiData: function () {
var longname = this;
var root = DocsData;
_.each(longname.split("."), function (pathSegment) {
root = root[pathSegment];
});
return root;
},
apiData: apiData,
typeNames: function (nameList) {
// change names if necessary
nameList = _.map(nameList, function (name) {
@@ -36,7 +37,18 @@ Template.autoApiBox.helpers({
return paramNames.join(", ");
},
name: function () {
if (this.scope === "instance") {
return "<em>" + apiData(this.memberof).instancename + "</em>." + this.name;
}
return this.longname;
},
link: function () {
if (this.scope === "instance") {
return apiData(this.memberof).instancename + "_" + this.name;
}
return this.longname.replace(".", "_").toLowerCase();
},
paramsNoOptions: function () {

View File

@@ -2869,14 +2869,14 @@ See the <a href="http://manual.meteor.com/#deps-reactivevaluewithdependency">
Meteor Manual</a> to learn how to create a reactive data source using
Deps.Dependency.
{{> api_box dependency_changed }}
{{> autoApiBox "Deps.Dependency#changed" }}
{{> api_box dependency_depend }}
{{> autoApiBox "Deps.Dependency#depend" }}
`dep.depend()` is used in reactive data source implementations to record
the fact that `dep` is being accessed from the current computation.
{{> api_box dependency_hasdependents }}
{{> autoApiBox "Deps.Dependency#hasDependents" }}
For reactive data sources that create many internal Dependencies,
this function is useful to determine whether a particular Dependency is

File diff suppressed because one or more lines are too long

View File

@@ -14,6 +14,17 @@
"sendEnrollmentEmail": {},
"sendVerificationEmail": {}
},
"Deps": {
"Dependency": {},
"Dependency#depend": {},
"Dependency#changed": {},
"Dependency#hasDependents": {},
"flush": {},
"autorun": {},
"nonreactive": {},
"onInvalidate": {},
"afterFlush": {}
},
"Meteor": {
"userId": {},
"loggingIn": {},
@@ -33,13 +44,6 @@
"clearTimeout": {},
"absoluteUrl": {}
},
"Deps": {
"flush": {},
"autorun": {},
"nonreactive": {},
"onInvalidate": {},
"afterFlush": {}
},
"EJSON": {
"newBinary": {},
"addType": {},

View File

@@ -225,7 +225,16 @@ Deps.Computation.prototype._recompute = function () {
//
// http://docs.meteor.com/#deps_dependency
//
/**
* @summary A Dependency represents an atomic unit of reactive data that a
* computation might depend on. Reactive data sources such as Session or
* Minimongo internally create different Dependency objects for different
* pieces of data, each of which may be depended on by multiple computations.
* When the data changes, the computations are invalidated.
* @class
* @instanceName dependency
*/
Deps.Dependency = function () {
this._dependentsById = {};
};
@@ -236,6 +245,16 @@ Deps.Dependency = function () {
// present. Returns true if `computation` is a new member of the set.
// If no argument, defaults to currentComputation, or does nothing
// if there is no currentComputation.
/**
* @summary Declares that the current computation (or `fromComputation` if given) depends on `dependency`. The computation will be invalidated the next time `dependency` changes.
If there is no current computation and `depend()` is called with no arguments, it does nothing and returns false.
Returns true if the computation is a new dependent of `dependency` rather than an existing one.
* @locus Client
* @param {Deps.Computation} [fromComputation] An optional computation declared to depend on `dependency` instead of the current computation.
*/
Deps.Dependency.prototype.depend = function (computation) {
if (! computation) {
if (! Deps.active)
@@ -256,6 +275,11 @@ Deps.Dependency.prototype.depend = function (computation) {
};
// http://docs.meteor.com/#dependency_changed
/**
* @summary Invalidate all dependent computations immediately and remove them as dependents.
* @locus Client
*/
Deps.Dependency.prototype.changed = function () {
var self = this;
for (var id in self._dependentsById)
@@ -263,6 +287,11 @@ Deps.Dependency.prototype.changed = function () {
};
// http://docs.meteor.com/#dependency_hasdependents
/**
* @summary True if this Dependency has one or more dependent Computations, which would be invalidated if this Dependency were to change.
* @locus Client
*/
Deps.Dependency.prototype.hasDependents = function () {
var self = this;
for(var id in self._dependentsById)

View File

@@ -67,6 +67,15 @@
}
});
var constructors = helper.find(data, {kind: "class"});
_.each(constructors, function (constructor) {
if (constructor.summary) {
addToTree(docTree, constructor.longname, constructor);
addToTree(nameTree, constructor.longname, {});
}
});
var functions = helper.find(data, {kind: "function"});
// insert all of the function data into the namespaces