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

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() {
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) {
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 = {
output: 'output.md',
formatter: function (docfile) {
docfile = markdox.defaultFormatter(docfile);
docfile.members = [];
docfile.javadoc.forEach(function(javadoc, index){
var isConstructor = false;
javadoc.raw.tags.forEach(function(tag){
if (tag.type == 'constructor') {
isConstructor = true
// Find constructor tags
docfile.javadoc[index].isConstructor = getTag(javadoc.raw.tags, 'constructor') !== undefined;
// Only show params without a dot in them (dots means attributes of object, so no need to clutter the co)
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;
......@@ -24,5 +70,8 @@ var options = {
};
markdox.process('./lib/sequelize.js', options, function(){
console.log('File `all.md` generated with success');
});
\ No newline at end of file
md = fs.readFileSync('output.md').toString();
fs.writeFileSync('out.html', ghm.parse(md));
});
<? docfiles.forEach(function(doc) { ?>
<!-- Start <?= doc.filename ?> -->
<? doc.javadoc.forEach(function(comment) { ?>
<? if (comment.name) { ?>
<? if (comment.name) { ?>
<? if (!comment.ignore) { ?>
<? if (comment.isConstructor) { ?>
## new <?= comment.name ?>()
<? } else if (comment.isMethod || comment.isFunction) { ?>
### <?= comment.name ?>(<?= comment.paramStr ?>)
<? } else { ?>
### <?= comment.name ?>
<a name="<?= comment.name ?>" />
<? if (comment.isConstructor) { ?>
## new <?= comment.name ?>(<?= comment.paramStr ?>)
<? } else if (comment.isMethod || comment.isFunction) { ?>
### <?= comment.name ?>(<?= comment.paramStr ?>)
<? } else { ?>
### <?= comment.name ?>
<? } ?>
<? } ?>
<? } ?>
<?= comment.description ?>
<? if (comment.isClass) { ?>
### Members:
<? doc.members.forEach(function (member) { ?>
* <a href="#<?= member ?>"><?= member ?></a><? }) ?>
<? } ?>
<? if (comment.deprecated) { ?>
**Deprecated**
<? } ?>
......@@ -29,7 +33,15 @@
<? } ?>
<? 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) { ?>
......@@ -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!