├── .gitignore ├── .jshintrc ├── Gruntfile.js ├── LICENSE ├── README.md ├── package.json ├── tasks └── hologram.js └── test ├── assets ├── _footer.html └── _header.html ├── expected ├── custom_options └── default_options ├── fixtures ├── 123 └── testing ├── hologram_config.yml ├── hologram_test.js └── test.css /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | tmp 4 | .idea -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "curly": true, 3 | "eqeqeq": true, 4 | "immed": true, 5 | "latedef": true, 6 | "newcap": true, 7 | "noarg": true, 8 | "sub": true, 9 | "undef": true, 10 | "boss": true, 11 | "eqnull": true, 12 | "node": true 13 | } 14 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | /* 2 | * grunt-hologram 3 | * 4 | * 5 | * Copyright (c) 2014 James Childers 6 | * Licensed under the MIT license. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | module.exports = function (grunt) { 12 | // load all npm grunt tasks 13 | require('load-grunt-tasks')(grunt); 14 | 15 | // Project configuration. 16 | grunt.initConfig({ 17 | jshint: { 18 | all: [ 19 | 'Gruntfile.js', 20 | 'tasks/*.js', 21 | '<%= nodeunit.tests %>' 22 | ], 23 | options: { 24 | jshintrc: '.jshintrc', 25 | reporter: require('jshint-stylish') 26 | } 27 | }, 28 | 29 | // Before generating any new files, remove any previously-created files. 30 | clean: { 31 | tests: ['tmp'] 32 | }, 33 | 34 | // Configuration to be run (and then tested). 35 | hologram: { 36 | generate: { 37 | options: { 38 | config: 'test/hologram_config.yml' 39 | } 40 | } 41 | }, 42 | 43 | // Unit tests. 44 | nodeunit: { 45 | tests: ['test/*_test.js'] 46 | } 47 | 48 | }); 49 | 50 | // Actually load this plugin's task(s). 51 | grunt.loadTasks('tasks'); 52 | 53 | // Whenever the "test" task is run, first clean the "tmp" dir, then run this 54 | // plugin's task(s), then test the result. 55 | grunt.registerTask('test', ['clean', 'hologram', 'nodeunit']); 56 | 57 | // By default, lint and run all tests. 58 | grunt.registerTask('default', ['jshint', 'test']); 59 | 60 | }; 61 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 James Childers 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # grunt-hologram 2 | 3 | > Generate Hologram style guides with Grunt 4 | 5 | ## Getting Started 6 | This plugin requires Grunt. 7 | 8 | If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command: 9 | 10 | ```shell 11 | npm install grunt-hologram --save-dev 12 | ``` 13 | 14 | Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript: 15 | 16 | ```js 17 | grunt.loadNpmTasks('grunt-hologram'); 18 | ``` 19 | 20 | ## The "hologram" task 21 | 22 | ### Overview 23 | In your project's Gruntfile, add a section named `hologram` to the data object passed into `grunt.initConfig()`. 24 | 25 | ```js 26 | grunt.initConfig({ 27 | hologram: { 28 | generate: { 29 | options: { 30 | config: 'path/to/hologram/config.yml' 31 | } 32 | } 33 | }, 34 | }) 35 | ``` 36 | 37 | ### Options 38 | 39 | #### options.config 40 | Type: `String` 41 | *Required* 42 | 43 | The path to your hologram config file. 44 | 45 | #### options.bin 46 | Type: `String` 47 | *Optional* 48 | 49 | The path to your hologram binary installation. 50 | 51 | ## Contributing 52 | In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/). 53 | 54 | ## Release History 55 | _(Nothing yet)_ 56 | 57 | ## License 58 | Copyright (c) 2015 James Childers. Licensed under the MIT license. 59 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grunt-hologram", 3 | "version": "0.0.6", 4 | "description": "Generate Hologram style guides with Grunt", 5 | "repository": { 6 | "type": "git", 7 | "url": "git@github.com:jchild3rs/grunt-hologram.git" 8 | }, 9 | "author": "James Childers (http://www.jchilders.com)", 10 | "keywords": [ 11 | "gruntplugin" 12 | ], 13 | "main": "Gruntfile.js", 14 | "engines": { 15 | "node": ">= 0.8.0" 16 | }, 17 | "license": "MIT", 18 | "devDependencies": { 19 | "grunt-contrib-clean": "~0.5.0", 20 | "grunt-contrib-jshint": "~0.8.0", 21 | "grunt-contrib-nodeunit": "~0.3.0", 22 | "grunt": "~0.4.5", 23 | "jshint-stylish": "~0.1.5", 24 | "load-grunt-tasks": "~0.3.0" 25 | }, 26 | "dependencies": { 27 | "which": "~1.0.5", 28 | "win-spawn": "~2.0.0" 29 | }, 30 | "scripts": { 31 | "test": "grunt test" 32 | }, 33 | "bugs": { 34 | "url": "https://github.com/jchild3rs/grunt-hologram/issues" 35 | }, 36 | "homepage": "https://github.com/jchild3rs/grunt-hologram", 37 | "directories": { 38 | "test": "test" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tasks/hologram.js: -------------------------------------------------------------------------------- 1 | /* 2 | * grunt-hologram 3 | * 4 | * 5 | * Copyright (c) 2014 James Childers 6 | * Licensed under the MIT license. 7 | */ 8 | 9 | 'use strict'; 10 | var spawn = require('win-spawn'); 11 | var which = require('which'); 12 | 13 | module.exports = function (grunt) { 14 | 15 | grunt.registerMultiTask('hologram', 'Generate Hologram style guides with Grunt', function () { 16 | 17 | var done = this.async(); 18 | var options = this.options(); 19 | var configPath; 20 | var cmd = options.bin || 'hologram'; 21 | 22 | try { 23 | grunt.file.isFile(cmd) || which.sync('hologram'); 24 | } catch (err) { 25 | return grunt.warn( 26 | '\nYou need to have Hologram installed and in your PATH for this task to work.\n' + 27 | '\nsudo gem install hologram\n' 28 | ); 29 | } 30 | 31 | // Null check config option 32 | if (options.config) { 33 | configPath = options.config; 34 | } else { 35 | return grunt.warn( 36 | '\nYou must provide a path to your hologram config file.\n' 37 | ); 38 | } 39 | 40 | // Make sure config file exists 41 | if (!grunt.file.exists(configPath)) { 42 | return grunt.warn('Config file "' + configPath + '" not found.'); 43 | } 44 | 45 | // Run hologram 46 | var cp = spawn(cmd, [configPath], {stdio: 'inherit'}); 47 | 48 | cp.on('error', function (err) { 49 | done(err); 50 | }); 51 | 52 | cp.on('close', function (code) { 53 | if (code > 0) { 54 | done(new Error('Exited with error code ' + code)); 55 | } else { 56 | done(); 57 | } 58 | }); 59 | 60 | }); 61 | 62 | }; 63 | -------------------------------------------------------------------------------- /test/assets/_footer.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchild3rs/grunt-hologram/174d7011ae55c789f19d19d5704692bca160c588/test/assets/_footer.html -------------------------------------------------------------------------------- /test/assets/_header.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchild3rs/grunt-hologram/174d7011ae55c789f19d19d5704692bca160c588/test/assets/_header.html -------------------------------------------------------------------------------- /test/expected/custom_options: -------------------------------------------------------------------------------- 1 | Testing: 1 2 3 !!! -------------------------------------------------------------------------------- /test/expected/default_options: -------------------------------------------------------------------------------- 1 | Testing, 1 2 3. -------------------------------------------------------------------------------- /test/fixtures/123: -------------------------------------------------------------------------------- 1 | 1 2 3 -------------------------------------------------------------------------------- /test/fixtures/testing: -------------------------------------------------------------------------------- 1 | Testing -------------------------------------------------------------------------------- /test/hologram_config.yml: -------------------------------------------------------------------------------- 1 | # Hologram will run from same directory where this config file resides 2 | # All paths should be relative to there 3 | 4 | # The directory containing the source files to parse recursively 5 | source: ./ 6 | 7 | # The directory that hologram will build to 8 | destination: ../tmp/style-guide 9 | 10 | # The assets needed to build the docs (includes header.html, 11 | # footer.html, etc) 12 | # You may put doc related assets here too: images, css, etc. 13 | documentation_assets: ./assets 14 | 15 | # Any other asset folders that need to be copied to the destination 16 | # folder. Typically this will include the css that you are trying to 17 | # document. May also include additional folders as needed. 18 | #dependencies: 19 | # - ../sites/all/themes/dr_zen/css 20 | 21 | # Mark which category should be the index page 22 | # Alternatively, you may have an index.md in the documenatation assets 23 | # folder instead of specifying this configu. 24 | # index: Base 25 | -------------------------------------------------------------------------------- /test/hologram_test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var grunt = require('grunt'); 4 | 5 | /* 6 | ======== A Handy Little Nodeunit Reference ======== 7 | https://github.com/caolan/nodeunit 8 | 9 | Test methods: 10 | test.expect(numAssertions) 11 | test.done() 12 | Test assertions: 13 | test.ok(value, [message]) 14 | test.equal(actual, expected, [message]) 15 | test.notEqual(actual, expected, [message]) 16 | test.deepEqual(actual, expected, [message]) 17 | test.notDeepEqual(actual, expected, [message]) 18 | test.strictEqual(actual, expected, [message]) 19 | test.notStrictEqual(actual, expected, [message]) 20 | test.throws(block, [error], [message]) 21 | test.doesNotThrow(block, [error], [message]) 22 | test.ifError(value) 23 | */ 24 | 25 | exports.hologram = { 26 | setUp: function (done) { 27 | // setup here if necessary 28 | done(); 29 | }, 30 | default_options: function (test) { 31 | test.expect(1); 32 | 33 | var actual = grunt.file.read('tmp/default_options'); 34 | var expected = grunt.file.read('test/expected/default_options'); 35 | test.equal(actual, expected, 'should describe what the default behavior is.'); 36 | 37 | test.done(); 38 | }, 39 | custom_options: function (test) { 40 | test.expect(1); 41 | 42 | var actual = grunt.file.read('tmp/custom_options'); 43 | var expected = grunt.file.read('test/expected/custom_options'); 44 | test.equal(actual, expected, 'should describe what the custom option(s) behavior is.'); 45 | 46 | test.done(); 47 | } 48 | }; 49 | -------------------------------------------------------------------------------- /test/test.css: -------------------------------------------------------------------------------- 1 | /*doc 2 | --- 3 | title: Blockquotes 4 | name: blockquote 5 | category: Objects 6 | --- 7 | 8 | ```html_example 9 |

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor.

10 | ``` 11 | */ 12 | .blockquote { 13 | font-family: "Oswald", sans-serif; 14 | font-size: 31px; 15 | line-height: 40px; 16 | padding: 30px 0; 17 | border-top: 1px solid #000; 18 | border-bottom: 1px solid #000; 19 | font-weight: 100; 20 | color: #000; 21 | } 22 | .blockquote a { 23 | color: #ff008f; 24 | } 25 | .blockquote a:hover { 26 | color: #2da8d5; 27 | } 28 | .blockquote p { 29 | margin-bottom: 0 !important; 30 | } 31 | --------------------------------------------------------------------------------