不要怂,就是干,撸起袖子干!

Commit c0b82bd5 by Jan Aagaard Meier

Finished api docs for sequelize.js and dao.js

1 parent 9e608982
...@@ -296,6 +296,11 @@ module.exports = (function() { ...@@ -296,6 +296,11 @@ module.exports = (function() {
this.DAO.prototype.attributes = Object.keys(this.DAO.prototype.rawAttributes) this.DAO.prototype.attributes = Object.keys(this.DAO.prototype.rawAttributes)
} }
/**
* Sync this DAO to the DB.
* @see {Sequelize#sync} for options
* @return {EventEmitter}
*/
DAOFactory.prototype.sync = function(options) { DAOFactory.prototype.sync = function(options) {
options = Utils._.extend({}, this.options, options || {}) options = Utils._.extend({}, this.options, options || {})
......
var markdox = require('markdox'); var markdox = require('markdox')
, ghm = require("github-flavored-markdown")
, fs = require('fs')
, _ = require('lodash');
var getTag = function(tags, tagName) {
return _.find(tags, function (tag) {
return tag.type === tagName
});
};
// TODO multiple @see tags
var options = { var options = {
output: 'output.md', output: 'output.md',
formatter: function (docfile) { formatter: function (docfile) {
docfile = markdox.defaultFormatter(docfile); docfile = markdox.defaultFormatter(docfile);
docfile.members = [];
docfile.javadoc.forEach(function(javadoc, index){ docfile.javadoc.forEach(function(javadoc, index){
var isConstructor = false; // Find constructor tags
docfile.javadoc[index].isConstructor = getTag(javadoc.raw.tags, 'constructor') !== undefined;
javadoc.raw.tags.forEach(function(tag){
if (tag.type == 'constructor') { // Only show params without a dot in them (dots means attributes of object, so no need to clutter the co)
isConstructor = true var params = []
javadoc.paramTags.forEach(function (paramTag) {
if (paramTag.name.indexOf('.') === -1) {
params.push(paramTag.name);
} }
}); });
javadoc.paramStr = params.join(', ');
// Handle linking in comments
if (javadoc.see) {
if (javadoc.see.indexOf('{') === 0){
var see = javadoc.see.split('}')
see[0] = see[0].substring(1)
if (javadoc.see.indexOf('www') !== -1) {
javadoc.seeExternal = true
} else {
javadoc.seeExternal = false
}
javadoc.seeURL = see[0]
if (see[1] !== "") {
javadoc.seeText = see[1]
} else {
javadoc.seeText = see[0]
}
} else {
javadoc.seeURL = false
}
}
docfile.javadoc[index].isConstructor = isConstructor; // Set a name for properties
if (!javadoc.name) {
var property = getTag(javadoc.raw.tags, 'property')
if (property) {
javadoc.name = property.string
}
}
if (!javadoc.isClass) {
docfile.members.push(javadoc.name)
}
}); });
return docfile; return docfile;
...@@ -24,5 +70,8 @@ var options = { ...@@ -24,5 +70,8 @@ var options = {
}; };
markdox.process('./lib/sequelize.js', options, function(){ markdox.process('./lib/sequelize.js', options, function(){
console.log('File `all.md` generated with success'); md = fs.readFileSync('output.md').toString();
});
\ No newline at end of file fs.writeFileSync('out.html', ghm.parse(md));
});
<? docfiles.forEach(function(doc) { ?> <? docfiles.forEach(function(doc) { ?>
<!-- Start <?= doc.filename ?> -->
<? doc.javadoc.forEach(function(comment) { ?> <? doc.javadoc.forEach(function(comment) { ?>
<? if (comment.name) { ?> <? if (comment.name) { ?>
<? if (!comment.ignore) { ?> <? if (!comment.ignore) { ?>
<? if (comment.isConstructor) { ?> <a name="<?= comment.name ?>" />
## new <?= comment.name ?>() <? if (comment.isConstructor) { ?>
<? } else if (comment.isMethod || comment.isFunction) { ?> ## new <?= comment.name ?>(<?= comment.paramStr ?>)
### <?= comment.name ?>(<?= comment.paramStr ?>) <? } else if (comment.isMethod || comment.isFunction) { ?>
<? } else { ?> ### <?= comment.name ?>(<?= comment.paramStr ?>)
### <?= comment.name ?> <? } else { ?>
### <?= comment.name ?>
<? } ?>
<? } ?> <? } ?>
<? } ?>
<?= comment.description ?> <?= comment.description ?>
<? if (comment.isClass) { ?>
### Members:
<? doc.members.forEach(function (member) { ?>
* <a href="#<?= member ?>"><?= member ?></a><? }) ?>
<? } ?>
<? if (comment.deprecated) { ?> <? if (comment.deprecated) { ?>
**Deprecated** **Deprecated**
<? } ?> <? } ?>
...@@ -29,7 +33,15 @@ ...@@ -29,7 +33,15 @@
<? } ?> <? } ?>
<? if (comment.see) { ?> <? if (comment.see) { ?>
See: <?= comment.see ?> <? if (comment.seeURL !== false) { ?>
<? if (comment.seeExternal) { ?>
See: <a href="<?= comment.seeURL ?>"><?= comment.seeText ?></a>
<? } else { ?>
See: <a href="https://github.com/sequelize/sequelize/wiki/API-Reference-<?= comment.seeURL ?>"><?= comment.seeText ?></a>
<? } ?>
<? } else { ?>
See: <?= comment.see ?>
<? } ?>
<? } ?> <? } ?>
<? if (comment.paramTags.length > 0) { ?> <? if (comment.paramTags.length > 0) { ?>
...@@ -58,6 +70,8 @@ ...@@ -58,6 +70,8 @@
------ ------
<? }) ?> <? }) ?>
<!-- End <?= doc.filename ?> --> _This document is automatically generated based on source code comments. Please do not edit it directly, as your changes will be ignored. Please write on [IRC](irc://irc.freenode.net/#sequelizejs), open an issue or a create a pull request if you feel something can be improved. For help on how to write source code documentation see [JSDoc](http://usejsdoc.org), [dox](https://github.com/visionmedia/dox) and [markdox](https://github.com/cbou/markdox)_
_This documentation was automagically created on <?= new Date().toString() ?>_
<? }) ?> <? }) ?>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!