How to generate a JSDoc documentation for your UI5 application in the SAP Web IDE (Grunt)

In old Web IDE projects grunt is only used in conjunction with the @sap/grunt-sapui5-bestpractice-build package. Unfortunately, this causes problems in combination with other packages like grunt-jsdoc.

If other packages or tasks are used in Gruntfile.js, the @sap/grunt-sapui5-bestpractice-build task and all dependencies should be commented out.

Adjust the package.json

Add the package grunt-jsdoc to your package.json.

{
	"name": "GBIS_Account",
	"version": "0.0.1",
	"description": "",
	"private": true,
	"devDependencies": {
		"@sap/grunt-sapui5-bestpractice-build": "1.4.15",
		"grunt-jsdoc": "2.4.1"
	}
}

Adjust the Gruntfile.js

  1. Load the grunt-jsdoc task
  2. Configurate the grunt-jsdoc task. (For more information see grunt-jsdoc – README)
  3. Register the grunt-jsdoc task
  4. comment out the relevant @sap/grunt-sapui5-bestpractice-build lines
module.exports = function (grunt) {
	"use strict";

	grunt.loadNpmTasks('grunt-jsdoc'); //load jsdoc task
	//grunt.loadNpmTasks("@sap/grunt-sapui5-bestpractice-build");

	grunt.initConfig({
		jsdoc: { //configurate jsdoc task
			account: {
				src: [
					'webapp/Component.js',
					'webapp/controller/*.js'
					//... add your files here
				],
				options: {
					destination: 'doc'
				}
			}
		}
	});

	grunt.registerTask("default", [
		"jsdoc" //register jsdoc task
		// "clean",
		// "lint",
		// "build"
	]);
};

That’s it. Before deploying the application, remember to comment everything @sap/grunt-sapui5-bestpractice-build related back in and comment out the other tasks.

If your application already has a file called ui5.yaml then forget everything you have read and check out this blog post: How to generate an JSDoc documentation for your UI5 application in the SAP Web IDE (UI5 Tooling & Grunt)

Leave a Reply

Your email address will not be published. Required fields are marked *