UNPKG

jsduckify

Version:

Enables the use of Sencha's JSDuck for documenting CoffeeScript projects.

64 lines (58 loc) 2.39 kB
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>The source code</title> <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="../resources/prettify/prettify.js"></script> <style type="text/css"> .highlight { display: block; background-color: #ddd; } </style> <script type="text/javascript"> function highlight() { document.getElementById(location.hash.replace(/#/, "")).className = "highlight"; } </script> </head> <body onload="prettyPrint(); highlight();"> <pre class="prettyprint lang-js">/* &lt;CoffeeScript&gt; _type = do -&gt; # from http://arcturo.github.com/library/coffeescript/07_the_bad_parts.html classToType = {} for name in &quot;Boolean Number String Function Array Date RegExp Undefined Null&quot;.split(&quot; &quot;) classToType[&quot;[object &quot; + name + &quot;]&quot;] = name.toLowerCase() (obj) -&gt; strType = Object::toString.call(obj) classToType[strType] or &quot;object&quot; _getExportsAPI = (root, exportsAPI, currentPrefix = &#39;&#39;) -&gt; for key, value of root if currentPrefix.length &gt; 0 fullName = currentPrefix + &#39;.&#39; + key else fullName = key nameArray = fullName.split(&#39;.&#39;) baseName = nameArray[nameArray.length - 1] type = _type(value) row = {fullName, baseName, type} exportsAPI.push(row) if type == &#39;object&#39; _getExportsAPI(value, exportsAPI, fullName) &lt;/CoffeeScript&gt; */ <span id='jsduckify-method-documentExportsAPI'>/** </span> * @method documentExportsAPI * @member jsduckify * @param {String} moduleDirectory * @return {Array} {baseName, fullName, type} * * This function will `require` the CoffeeScript directory under the assumption that it&#39;s a package. * That will reveal the published API (tree) of namespaces, classes, properties, functions, etc. * This function crawls that tree extracting the namespace structure for the package&#39;s API. This is * later used to make sure the jsduck documentation indicates the same namespace tree. */ /* &lt;CoffeeScript&gt; exports.documentExportsAPI = (moduleDirectory) -&gt; exportsAPI = [] _getExportsAPI(require(moduleDirectory), exportsAPI) return exportsAPI &lt;/CoffeeScript&gt; */</pre> </body> </html>