Skip to content

Commit

Permalink
Updating examples
Browse files Browse the repository at this point in the history
  • Loading branch information
weikinhuang committed Sep 30, 2012
1 parent 88d1f11 commit 62c337a
Show file tree
Hide file tree
Showing 15 changed files with 90 additions and 156 deletions.
2 changes: 1 addition & 1 deletion build/module/doc.js
Expand Up @@ -497,7 +497,7 @@ function outputHtmlDocBlock(block, messages, examples) {
messages.push("</pre>");
} else if (block.refexample && examples[block.refexample]) {
messages.push("<pre class=\"code-block javascript\">");
messages.push(highlight(examples[block.refexample].toString().replace(/^\t/gm, "").replace(/\t/g, " ").replace(/^\s*func.+[\n\r]+/, "").replace(/[\n\r]+\s*\}\s*$/, "")));
messages.push(highlight(examples[block.refexample].toString().trim().replace(/^\t/gm, "").replace(/\t/g, " ").replace(/^\s*func.+[\n\r]+/, "").replace(/[\n\r]+\s*\}\s*$/, "")));
messages.push("</pre>");
}
}
Expand Down
103 changes: 53 additions & 50 deletions docs/README.md
Expand Up @@ -110,72 +110,75 @@ The Main interface function that returns namespaces and creates objects.

##### Example
```javascript
// Different ways to call Classify

// Calling Classify with a string returns a namespace
// @see Classify.getNamespace
Classify("Life") === Classify.getNamespace("Life");

// Calling Classify with a string ending in a "/" returns a namespace
// @see Classify.getNamespace
Classify("Life/") === Classify.getNamespace("Life");

// Calling Classify with a string separated by "/" returns a defined class within a namespace
// @see Classify.Namespace.get
Classify("Life/Eukaryotes") === Classify.getNamespace("Life").get("Eukaryotes");

// Calling Classify with 2 string parameters returns a defined class within a namespace
// @see Classify.Namespace.get
Classify("Life", "Eukaryotes") === Classify.getNamespace("Life").get("Eukaryotes");

// Calling Classify with first parameter as a string, and second parameter as an object, creates
// a class within the namespace
var Eukaryotes = Classify("Life/Eukaryotes", {
init : function() {
<span class="comment">// Different ways to call Classify</span>

<span class="comment">// Calling Classify with a string returns a namespace</span>
<span class="comment">// @see Classify.getNamespace</span>
Classify(<span class="string">"Life"</span>) === Classify.getNamespace(<span class="string">"Life"</span>);

<span class="comment">// Calling Classify with a string ending in a "/" returns a namespace</span>
<span class="comment">// @see Classify.getNamespace</span>
Classify(<span class="string">"Life/"</span>) === Classify.getNamespace(<span class="string">"Life"</span>);

<span class="comment">// Calling Classify with a string separated by "/" returns a defined</span>
<span class="comment">// class within a namespace</span>
<span class="comment">// @see Classify.Namespace.get</span>
Classify(<span class="string">"Life/Eukaryotes"</span>) === Classify.getNamespace(<span class="string">"Life"</span>).get(<span class="string">"Eukaryotes"</span>);

<span class="comment">// Calling Classify with 2 string parameters returns a defined class within</span>
<span class="comment">// a namespace</span>
<span class="comment">// @see Classify.Namespace.get</span>
Classify(<span class="string">"Life"</span>, <span class="string">"Eukaryotes"</span>) === Classify.getNamespace(<span class="string">"Life"</span>).get(<span class="string">"Eukaryotes"</span>);

<span class="comment">// Calling Classify with first parameter as a string, and second parameter as</span>
<span class="comment">// an object, creates a class within the namespace</span>
<span class="keyword">var</span> Eukaryotes = Classify(<span class="string">"Life/Eukaryotes"</span>, {
init : <span class="keyword">function</span>() {
}
});
// Calling Classify with first parameter as a string, second parameter as a string, and third
// parameter as an object, creates a class within the namespace
var Eukaryotes = Classify("Life", "Eukaryotes", {
init : function() {
<span class="comment">// Calling Classify with first parameter as a string, second parameter as a string, and</span>
<span class="comment">// third parameter as an object, creates a class within the namespace</span>
<span class="keyword">var</span> Eukaryotes = Classify(<span class="string">"Life"</span>, <span class="string">"Eukaryotes"</span>, {
init : <span class="keyword">function</span>() {
}
});
// The above 2 statements are the same as the following statement to create classes
// @see Classify.Namespace.create
var Eukaryotes = Classify.getNamespace("Life").create("Eukaryotes", {
init : function() {
<span class="comment">// The above 2 statements are the same as the following statement to create classes</span>
<span class="comment">// @see Classify.Namespace.create</span>
<span class="keyword">var</span> Eukaryotes = Classify.getNamespace(<span class="string">"Life"</span>).create(<span class="string">"Eukaryotes"</span>, {
init : <span class="keyword">function</span>() {
}
});

// To inherit from other classes, the first parameter is the class name, second parameter is the
// parent (can be from other namespaces with "Namespace/Class"), third parameter is the descriptor
var Plantae = Classify("Life/Plantae", "Eukaryotes", {
init : function() {
<span class="comment">// To inherit from other classes, the first parameter is the class name, second parameter</span>
<span class="comment">// is the parent (can be from other namespaces with "Namespace/Class"), third parameter</span>
<span class="comment">// is the descriptor</span>
<span class="keyword">var</span> Plantae = Classify(<span class="string">"Life/Plantae"</span>, <span class="string">"Eukaryotes"</span>, {
init : <span class="keyword">function</span>() {
}
});
// The same can be achieved with the following signature
var Plantae = Classify("Life", "Plantae", "Eukaryotes", {
init : function() {
<span class="comment">// The same can be achieved with the following signature</span>
<span class="keyword">var</span> Plantae = Classify(<span class="string">"Life"</span>, <span class="string">"Plantae"</span>, <span class="string">"Eukaryotes"</span>, {
init : <span class="keyword">function</span>() {
}
});
// The above 2 statements are the same as the following statement to create classes
// @see Classify.Namespace.create
var Plantae = Classify.getNamespace("Life").create("Plantae", "Eukaryotes", {
init : function() {
<span class="comment">// The above 2 statements are the same as the following statement to create classes</span>
<span class="comment">// @see Classify.Namespace.create</span>
<span class="keyword">var</span> Plantae = Classify.getNamespace(<span class="string">"Life"</span>).create(<span class="string">"Plantae"</span>, <span class="string">"Eukaryotes"</span>, {
init : <span class="keyword">function</span>() {
}
});

// Calling Classify with objects with create classes with the object descriptor.
// Using the Classify method in this manner is analogous to calling Classify.create()
// Please see Classify.create for documentation
// @see Classify.create
var Embryophytes = Classify({
init : function() {
<span class="comment">// Calling Classify with objects with create classes with the object descriptor.</span>
<span class="comment">// Using the Classify method in this manner is analogous to calling Classify.create()</span>
<span class="comment">// Please see Classify.create for documentation</span>
<span class="comment">// @see Classify.create</span>
<span class="keyword">var</span> Embryophytes = Classify({
init : <span class="keyword">function</span>() {
}
});
// The above statement is the same as
var Embryophytes = Classify.create({
init : function() {
<span class="comment">// The above statement is the same as</span>
<span class="keyword">var</span> Embryophytes = Classify.create({
init : <span class="keyword">function</span>() {
}
});
```
Expand Down
71 changes: 1 addition & 70 deletions docs/classify.docs.js
Expand Up @@ -13,76 +13,7 @@
* @memberOf Classify
* @returns {Classify.Class}
* @type {Classify.Class}
* @example <code>
* // Different ways to call Classify
*
* // Calling Classify with a string returns a namespace
* // @see Classify.getNamespace
* Classify("Life") === Classify.getNamespace("Life");
*
* // Calling Classify with a string ending in a "/" returns a namespace
* // @see Classify.getNamespace
* Classify("Life/") === Classify.getNamespace("Life");
*
* // Calling Classify with a string separated by "/" returns a defined class within a namespace
* // @see Classify.Namespace.get
* Classify("Life/Eukaryotes") === Classify.getNamespace("Life").get("Eukaryotes");
*
* // Calling Classify with 2 string parameters returns a defined class within a namespace
* // @see Classify.Namespace.get
* Classify("Life", "Eukaryotes") === Classify.getNamespace("Life").get("Eukaryotes");
*
* // Calling Classify with first parameter as a string, and second parameter as an object, creates
* // a class within the namespace
* var Eukaryotes = Classify("Life/Eukaryotes", {
* init : function() {
* }
* });
* // Calling Classify with first parameter as a string, second parameter as a string, and third
* // parameter as an object, creates a class within the namespace
* var Eukaryotes = Classify("Life", "Eukaryotes", {
* init : function() {
* }
* });
* // The above 2 statements are the same as the following statement to create classes
* // @see Classify.Namespace.create
* var Eukaryotes = Classify.getNamespace("Life").create("Eukaryotes", {
* init : function() {
* }
* });
*
* // To inherit from other classes, the first parameter is the class name, second parameter is the
* // parent (can be from other namespaces with "Namespace/Class"), third parameter is the descriptor
* var Plantae = Classify("Life/Plantae", "Eukaryotes", {
* init : function() {
* }
* });
* // The same can be achieved with the following signature
* var Plantae = Classify("Life", "Plantae", "Eukaryotes", {
* init : function() {
* }
* });
* // The above 2 statements are the same as the following statement to create classes
* // @see Classify.Namespace.create
* var Plantae = Classify.getNamespace("Life").create("Plantae", "Eukaryotes", {
* init : function() {
* }
* });
*
* // Calling Classify with objects with create classes with the object descriptor.
* // Using the Classify method in this manner is analogous to calling Classify.create()
* // Please see Classify.create for documentation
* // @see Classify.create
* var Embryophytes = Classify({
* init : function() {
* }
* });
* // The above statement is the same as
* var Embryophytes = Classify.create({
* init : function() {
* }
* });
* </code>
* @refexample summary-base
*/
var Classify = function() {
return new Classify.Class();
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/Classify.Class.js
@@ -1,5 +1,5 @@
var examples = module.exports = {};

examples["summary-base"] = function() {
examples["x"] = function() {

}
};
4 changes: 2 additions & 2 deletions docs/examples/Classify.Namespace.js
@@ -1,5 +1,5 @@
var examples = module.exports = {};

examples["summary-base"] = function() {
examples["x"] = function() {

}
};
4 changes: 2 additions & 2 deletions docs/examples/Classify.Observer.js
@@ -1,5 +1,5 @@
var examples = module.exports = {};

examples["summary-base"] = function() {
examples["x"] = function() {

}
};
4 changes: 2 additions & 2 deletions docs/examples/Classify.export.js
@@ -1,5 +1,5 @@
var examples = module.exports = {};

examples["summary-base"] = function() {
examples["x"] = function() {

}
};
4 changes: 2 additions & 2 deletions docs/examples/Classify.js
@@ -1,5 +1,5 @@
var examples = module.exports = {};

examples["summary-base"] = function() {
examples["x"] = function() {

}
};
26 changes: 13 additions & 13 deletions docs/examples/doc.js
Expand Up @@ -5,56 +5,56 @@ examples["summary-base"] = function() {

// Calling Classify with a string returns a namespace
// @see Classify.getNamespace
Classify("Life") === Classify.getNamespace("Life");
Classify("Vehicles") === Classify.getNamespace("Vehicles");

// Calling Classify with a string ending in a "/" returns a namespace
// @see Classify.getNamespace
Classify("Life/") === Classify.getNamespace("Life");
Classify("Vehicles") === Classify.getNamespace("Vehicles");

// Calling Classify with a string separated by "/" returns a defined
// class within a namespace
// @see Classify.Namespace.get
Classify("Life/Eukaryotes") === Classify.getNamespace("Life").get("Eukaryotes");
Classify("Vehicles/Ship") === Classify.getNamespace("Vehicles").get("Ship");

// Calling Classify with 2 string parameters returns a defined class within
// a namespace
// @see Classify.Namespace.get
Classify("Life", "Eukaryotes") === Classify.getNamespace("Life").get("Eukaryotes");
Classify("Vehicles", "Ship") === Classify.getNamespace("Vehicles").get("Ship");

// Calling Classify with first parameter as a string, and second parameter as
// an object, creates a class within the namespace
var Eukaryotes = Classify("Life/Eukaryotes", {
var Ship = Classify("Vehicles/Ship", {
init : function() {
}
});
// Calling Classify with first parameter as a string, second parameter as a string, and
// third parameter as an object, creates a class within the namespace
var Eukaryotes = Classify("Life", "Eukaryotes", {
var Ship = Classify("Vehicles", "Ship", {
init : function() {
}
});
// The above 2 statements are the same as the following statement to create classes
// @see Classify.Namespace.create
var Eukaryotes = Classify.getNamespace("Life").create("Eukaryotes", {
var Ship = Classify.getNamespace("Vehicles").create("Ship", {
init : function() {
}
});

// To inherit from other classes, the first parameter is the class name, second parameter
// is the parent (can be from other namespaces with "Namespace/Class"), third parameter
// is the descriptor
var Plantae = Classify("Life/Plantae", "Eukaryotes", {
var Battleship = Classify("Vehicles/Battleship", "Ship", {
init : function() {
}
});
// The same can be achieved with the following signature
var Plantae = Classify("Life", "Plantae", "Eukaryotes", {
var Battleship = Classify("Vehicles", "Battleship", "Ship", {
init : function() {
}
});
// The above 2 statements are the same as the following statement to create classes
// @see Classify.Namespace.create
var Plantae = Classify.getNamespace("Life").create("Plantae", "Eukaryotes", {
var Battleship = Classify.getNamespace("Vehicles").create("Battleship", "Ship", {
init : function() {
}
});
Expand All @@ -63,13 +63,13 @@ examples["summary-base"] = function() {
// Using the Classify method in this manner is analogous to calling Classify.create()
// Please see Classify.create for documentation
// @see Classify.create
var Embryophytes = Classify({
var Energy = Classify({
init : function() {
}
});
// The above statement is the same as
var Embryophytes = Classify.create({
var Energy = Classify.create({
init : function() {
}
});
}
};
4 changes: 2 additions & 2 deletions docs/examples/mutator.alias.js
@@ -1,5 +1,5 @@
var examples = module.exports = {};

examples["summary-base"] = function() {
examples["x"] = function() {

}
};
4 changes: 2 additions & 2 deletions docs/examples/mutator.bind.js
@@ -1,5 +1,5 @@
var examples = module.exports = {};

examples["summary-base"] = function() {
examples["x"] = function() {

}
};
4 changes: 2 additions & 2 deletions docs/examples/mutator.js
@@ -1,5 +1,5 @@
var examples = module.exports = {};

examples["summary-base"] = function() {
examples["x"] = function() {

}
};
4 changes: 2 additions & 2 deletions docs/examples/mutator.nowrap.js
@@ -1,5 +1,5 @@
var examples = module.exports = {};

examples["summary-base"] = function() {
examples["x"] = function() {

}
};
4 changes: 2 additions & 2 deletions docs/examples/mutator.observable.js
@@ -1,5 +1,5 @@
var examples = module.exports = {};

examples["summary-base"] = function() {
examples["x"] = function() {

}
};

0 comments on commit 62c337a

Please sign in to comment.