Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit 740d6e960ef5128b6f53949a344cafa93bc0cbfb @tkellen tkellen committed Sep 7, 2012
Showing with 368 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +3 −0 AUTHORS
  3. +22 −0 LICENSE-MIT
  4. +53 −0 README.md
  5. +89 −0 grunt.js
  6. +41 −0 package.json
  7. +70 −0 tasks/yuidoc.js
  8. +27 −0 test/fixtures/app/test.js
  9. +27 −0 test/fixtures/otherapp/test.js
  10. +33 −0 test/yuidoc_test.js
@@ -0,0 +1,3 @@
+node_modules
+npm-debug.log
+tmp
@@ -0,0 +1,3 @@
+George Pantazis (http://georgepantazis.com/)
+Tyler Kellen (http://goingslowly.com/)
+Chris Talkington (http://christalkington.com/)
@@ -0,0 +1,22 @@
+Copyright (c) 2012 "Cowboy" Ben Alman and contributors.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,53 @@
+# grunt-contrib-yuidoc
+> Compile YUIDoc Documentation (part of the [grunt-contrib](/gruntjs/grunt-contrib) collection). Submitted by [George Pantazis](/gcpantazis).
+
+## Getting Started
+Install this grunt plugin next to your project's [grunt.js gruntfile][getting_started] with: `npm install grunt-contrib-less`
+
+Then add this line to your project's `grunt.js` gruntfile:
+
+```javascript
+grunt.loadNpmTasks('grunt-contrib-yuidoc');
+```
+
+[grunt]: https://github.com/cowboy/grunt
+[getting_started]: https://github.com/cowboy/grunt/blob/master/docs/getting_started.md
+
+### Overview
+
+Inside your `grunt.js` file add a section named `yuidoc`. [Visit the YUIDoc project home](http://yui.github.com/yuidoc/) for more information on YUIDocs and commenting syntax.
+
+#### Parameters
+
+##### options ```object```
+
+This controls how this task operates and should contain key:value pairs, see options below.
+
+#### Options
+
+Options correlate to [YUIDoc config objects](http://yui.github.com/yuidoc/args/index.html).
+
+##### paths (required) ```string|array```
+
+What directory should be scanned to generate doc data.
+
+##### outdir (required) ```string```
+
+Where to save the documentation.
+
+#### Config Example
+
+``` javascript
+yuidoc: {
+ compile: {
+ "name": "Project Name",
+ "description": "Project Description",
+ "version": "1.0.2",
+ "url": "http://projecturl.com/",
+ options: {
+ paths: "path/to/source/code/",
+ outdir: "where/to/save/docs/"
+ }
+ }
+}
+```
@@ -0,0 +1,89 @@
+/*
+ * grunt-contrib-yuidoc
+ * http://gruntjs.com/
+ *
+ * Copyright (c) 2012 George Pantazis, contributors
+ * Licensed under the MIT license.
+ * https://github.com/gruntjs/grunt-contrib-yuidoc/blob/master/LICENSE-MIT
+ */
+
+module.exports = function(grunt) {
+ 'use strict';
+
+ // Project configuration.
+ grunt.initConfig({
+ pkg: {
+ name: "grunt-contrib-yuidoc",
+ version: "0.1.0"
+ },
+
+ lint: {
+ all: ['grunt.js', 'tasks/*.js', '<config:nodeunit.tasks>']
+ },
+ jshint: {
+ options: {
+ curly: true,
+ eqeqeq: true,
+ immed: true,
+ latedef: true,
+ newcap: true,
+ noarg: true,
+ sub: true,
+ undef: true,
+ boss: true,
+ eqnull: true,
+ node: true,
+ es5: true
+ }
+ },
+ // Before generating any new files, remove any previously-created files.
+ clean: {
+ test: ['tmp']
+ },
+ // Configuration to be run (and then tested).
+ yuidoc: {
+ compileA: {
+ "name": "Grunt Test",
+ "description": "Grunt Test Description",
+ "version": "1.2.1",
+ "url": "http://test.com/",
+ options: {
+ paths: "test/fixtures/app/",
+ outdir: "tmp/yuidoca/"
+ }
+ },
+ compileB: {
+ "name": "Grunt Test",
+ "description": "Grunt Test Description",
+ "version": "1.2.1",
+ "url": "http://test.com/",
+ options: {
+ paths: [
+ "test/fixtures/app/",
+ "test/fixtures/otherapp/"
+ ],
+ outdir: "tmp/yuidocb/"
+ }
+ }
+ },
+ // Unit tests.
+ nodeunit: {
+ tasks: ['test/*_test.js']
+ }
+ });
+
+ // Actually load this plugin's task(s).
+ grunt.loadTasks('tasks');
+
+ // The clean plugin helps in testing.
+ grunt.loadNpmTasks('grunt-contrib-clean');
+
+ // Whenever the "test" task is run, first clean the "tmp" dir, then run this
+ // plugin's task(s), then test the result.
+ grunt.renameTask('test', 'nodeunit');
+ grunt.registerTask('test', 'clean yuidoc nodeunit');
+
+ // By default, lint and run all tests.
+ grunt.registerTask('default', 'lint test');
+
+};
@@ -0,0 +1,41 @@
+{
+ "name": "grunt-contrib-yuidoc",
+ "description": "Compile YUIDoc Documentation.",
+ "version": "0.1.0",
+ "homepage": "https://github.com/gruntjs/grunt-contrib-yuidoc",
+ "author": {
+ "name": "George Pantazis",
+ "url": "http://georgepantazis.com/"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/gruntjs/grunt-contrib-yuidoc.git"
+ },
+ "bugs": {
+ "url": "https://github.com/gruntjs/grunt-contrib-yuidoc/issues"
+ },
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "https://github.com/gruntjs/grunt-contrib-yuidoc/blob/master/LICENSE-MIT"
+ }
+ ],
+ "main": "grunt.js",
+ "engines": {
+ "node": "*"
+ },
+ "scripts": {
+ "test": "grunt test"
+ },
+ "dependencies": {
+ "grunt-contrib-lib": "~0.1.0",
+ "yuidocjs": "~0.3.14"
+ },
+ "devDependencies": {
+ "grunt": "~0.3.15",
+ "grunt-contrib-clean": "~0.1.0"
+ },
+ "keywords": [
+ "gruntplugin"
+ ]
+}
@@ -0,0 +1,70 @@
+/*
+ * grunt-contrib-yuidoc
+ * http://gruntjs.com/
+ *
+ * Copyright (c) 2012 George Pantazis, contributors
+ * Licensed under the MIT license.
+ * https://github.com/gruntjs/grunt-contrib-yuidoc/blob/master/LICENSE-MIT
+ */
+
+module.exports = function(grunt) {
+ "use strict";
+
+ // TODO: ditch this when grunt v0.4 is released
+ grunt.util = grunt.util || grunt.utils;
+ var Y = require("yuidocjs");
+ var helpers = require("grunt-contrib-lib").init(grunt);
+ var kindOf = grunt.util.kindOf;
+
+ grunt.registerMultiTask("yuidoc", "Create YUIDocs", function() {
+
+ var done = this.async();
+ var starttime = (new Date()).getTime();
+ var json;
+
+ var options = helpers.options(this, {
+ quiet: true
+ });
+
+ // when invoking yuidocs via node, the project details
+ // are assigned under the options object using the key
+ // 'project'
+ options.project = this.data;
+
+ grunt.verbose.writeflags(options, "Options");
+
+ // Catch if required fields are not provided.
+ if ( !options.paths ) {
+ grunt.fail.warn("No path(s) provided for YUIDoc to scan.");
+ }
+ if ( !options.outdir ) {
+ grunt.fail.warn("You must specify a directory for YUIDoc output.");
+ }
+
+ // ensure destination dir is available
+ grunt.file.mkdir(options.outdir);
+
+ // Input path: array expected, but grunt conventions allows for either a string or an array.
+ if (kindOf(options.paths) === "string") {
+ options.paths = [ options.paths ];
+ }
+
+ json = (new Y.YUIDoc(options)).run();
+
+ options = Y.Project.mix(json, options);
+
+ if (!options.parseOnly) {
+ var builder = new Y.DocBuilder(options, json);
+
+ grunt.log.writeln("Start YUIDoc compile...");
+ grunt.log.writeln("Scanning: " + grunt.log.wordlist(options.paths));
+ grunt.log.writeln("Output: " + (options.outdir).cyan);
+
+ builder.compile(function() {
+ var endtime = (new Date()).getTime();
+ grunt.log.writeln("YUIDoc compile completed in " + ((endtime - starttime) / 1000) + " seconds");
+ done();
+ });
+ }
+ });
+};
@@ -0,0 +1,27 @@
+/**
+ @module App
+ @class Global
+ @static
+ */
+
+var App = App || {};
+
+App.Global = (function() {
+
+ var self = {
+
+ /**
+ This is a sample method.
+ @method App.Global.init
+ @param foo {String} A sample parameter.
+ */
+ 'init': function(foo) {
+
+ //
+
+ }
+ };
+
+ return self;
+
+})();
@@ -0,0 +1,27 @@
+/**
+ @module App
+ @class DeepClass
+ @static
+ */
+
+var App = App || {};
+
+App.DeepClass = (function() {
+
+ var self = {
+
+ /**
+ This is a sample method.
+ @method App.DeepClass.init
+ @param foo {String} A sample parameter.
+ */
+ 'init': function(foo) {
+
+ //
+
+ }
+ };
+
+ return self;
+
+})();
@@ -0,0 +1,33 @@
+var grunt = require("grunt");
+
+// TODO: ditch this when grunt v0.4 is released
+var fs = require("fs");
+var path = require("path");
+grunt.file.exists = grunt.file.exists || fs.existsSync || path.existsSync;
+
+exports['yuidoc'] = {
+ main: function(test) {
+ 'use strict';
+
+ var expect, result;
+ test.expect(4);
+
+ expect = true;
+ result = grunt.file.exists("tmp/yuidoca/data.json");
+ test.equal(result, expect, "If provided with a string path, Should generate JSON from source code");
+
+ expect = true;
+ result = grunt.file.exists("tmp/yuidoca/index.html");
+ test.equal(result, expect, "If provided with a string path, Should create template files for viewing data.json");
+
+ expect = true;
+ result = grunt.file.exists("tmp/yuidocb/data.json");
+ test.equal(result, expect, "If provided with an array of paths, should generate JSON from source code");
+
+ expect = true;
+ result = grunt.file.exists("tmp/yuidocb/index.html");
+ test.equal(result, expect, "If provided with an array of paths, should create template files for viewing data.json");
+
+ test.done();
+ }
+};

0 comments on commit 740d6e9

Please sign in to comment.