From e6aeeea8c19416cd979194537bb9b1a9ced39369 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Tue, 24 Apr 2018 16:48:32 +0100 Subject: [PATCH] Add better docs tasks --- Gruntfile.js | 24 ++++++++++++++++++++++++ jsdoc.json | 5 +++++ package.json | 6 ++++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 2be2d23c0..f88d61af0 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -407,6 +407,24 @@ module.exports = function(grunt) { cwd: '<%= paths.dist %>/', src: ['node-red-<%= pkg.version %>/**'] } + }, + jsdoc : { + runtimeAPI: { + src: 'red/runtime-api/*.js', + options: { + destination: 'docs', + configure: './jsdoc.json' + } + } + }, + jsdoc2md: { + runtimeAPI: { + options: { + separators: true + }, + src: 'red/runtime-api/*.js', + dest: 'docs/runtime-api.md' + } } }); @@ -425,6 +443,8 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-jsonlint'); grunt.loadNpmTasks('grunt-mocha-istanbul'); grunt.loadNpmTasks('grunt-webdriver'); + grunt.loadNpmTasks('grunt-jsdoc'); + grunt.loadNpmTasks('grunt-jsdoc-to-markdown'); grunt.registerMultiTask('attachCopyright', function() { var files = this.data.src; @@ -507,4 +527,8 @@ module.exports = function(grunt) { grunt.registerTask('coverage', 'Run Istanbul code test coverage task', ['build','mocha_istanbul:all']); + + grunt.registerTask('docs', + 'Generates API documentation', + ['jsdoc','jsdoc2md']); }; diff --git a/jsdoc.json b/jsdoc.json index ca6d6cdb1..87f604e60 100644 --- a/jsdoc.json +++ b/jsdoc.json @@ -1,4 +1,9 @@ { + "opts": { + "template": "./node_modules/ink-docstrap/template", + "destination": "./docs", + "recurse": true + }, "tags": { "allowUnknownTags": false, "dictionaries": ["jsdoc"] diff --git a/package.json b/package.json index 5e4eaac68..71dc6c0c9 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "start": "node red.js", "test": "grunt", "build": "grunt build", - "doc": "jsdoc --pedantic --recurse -c jsdoc.json -t ./node_modules/ink-docstrap/template" + "docs": "grunt docs" }, "bin": { "node-red": "./red.js", @@ -95,14 +95,16 @@ "grunt-contrib-jshint": "~1.1.0", "grunt-contrib-uglify": "~3.3.0", "grunt-contrib-watch": "~1.0.0", + "grunt-jsdoc": "^2.2.1", + "grunt-jsdoc-to-markdown": "^4.0.0", "grunt-jsonlint": "~1.1.0", "grunt-mocha-istanbul": "5.0.2", "grunt-nodemon": "~0.4.2", "grunt-sass": "~2.0.0", "grunt-simple-mocha": "~0.4.1", "grunt-webdriver": "^2.0.3", + "ink-docstrap": "^1.3.2", "istanbul": "0.4.5", - "jsdoc": "3.5.5", "mocha": "^5.1.1", "should": "^8.4.0", "sinon": "1.17.7",