gulp-jsdoc
Version:
A jsdoc plugin for Gulp
154 lines (117 loc) • 3.66 kB
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: lib/parser.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: lib/parser.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/**
* @file Parser
*
* @summary This is a wrapper around jsdoc parsing infrastructure that generates doc description
*
* @version ${ pkg.version }
* @author ${ pkg.author.name }
*
* @license ${ pkg.license }.
* @copyright ${ pkg.author.name }
* @name parser.js
* @unknownTag tag
*/
(function(){
'use strict';
// Dependencies
var augment = require('jsdoc/lib/jsdoc/augment');
var borrow = require('jsdoc/lib/jsdoc/borrow');
var parser = require('jsdoc/lib/jsdoc/src/parser');
var path = require('path');
var Parser = function(infs){
// Start by resolving defaults for the infos object
infs = infs || {};
var informations = {
name: '',
kind: 'package',
longname: '',
description: '',
version: '',
licenses: [],
tags: {
allowUnknownTags: true
},
plugins: false
};
Object.keys(informations).forEach(function(key){
if(key in infs)
informations[key] = infs[key];
});
// Validator XXX
global.env.conf = global.env.conf || {};
global.env.conf.tags = informations.tags;
if(!informations.longname)
informations.longname = informations.kind + ':' + informations.name;
// Create actual jsdoc parser
var innerParser = new parser.Parser();
if (informations.plugins) {
var plugins = require('jsdoc/lib/jsdoc/plugins');
informations.plugins = informations.plugins.map(function(item){
return path.resolve(path.join(__dirname, '..', 'node_modules', 'jsdoc'), item);
});
plugins.installPlugins(informations.plugins, innerParser);
}
// Attach handles
var handlers = require('jsdoc/lib/jsdoc/src/handlers');
handlers.attachTo(innerParser);
// Set file list up
var parsedFiles = informations.files = [];
// Do parse
this.parse = function(vinyl){
var data = vinyl.contents.toString('utf8');
// Don't treat empty files
if (data.length) {
// XXX butt-ugly hack - see #5 and 3.3.0-alpha5 release of jsdoc
env.sourceFiles = [vinyl.base];
innerParser._parseSourceCode(data, vinyl.path);
parsedFiles.push(vinyl.path);
}
};
this.complete = function(){
// Get buffer
var buf = innerParser._resultBuffer;
// Push generic package infos
buf.push(informations);
// Borrow and augment shit
borrow.indexAll(buf);
augment.addInherited(buf);
borrow.resolveBorrows(buf);
// Return buf
return buf;
};
};
module.exports = Parser;
}());
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Index</a></h2>
</nav>
<br clear="both">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Sun Mar 30 2014 22:58:29 GMT+0200 (CEST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>