Skip to content

Commit cf5509b

Browse files
authored
Merge pull request #426 from derms/dev
added example for using jsdoc with ml-gradle project
2 parents 650bc1a + 480c67f commit cf5509b

File tree

5 files changed

+88
-0
lines changed

5 files changed

+88
-0
lines changed

examples/jsdoc-project/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.gradle
2+
.idea
3+
build
4+
node_modules

examples/jsdoc-project/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Overview
2+
3+
Example of how to use [jsdoc](http://usejsdoc.org/) in MarkLogic project
4+
5+
This project uses the [JSDoc Gradle Plugin](https://github.com/liferay/liferay-portal/tree/master/modules/sdk/gradle-plugins-jsdoc) to run the jsdoc task
6+
7+
8+
## Usage
9+
10+
All of the configuration is captured in the __build.gradle__ file and the __jsdoc.json__ file. To test this, clone this repoitory and execute the command below in this directory
11+
12+
```
13+
gradle generateJsDoc
14+
```
15+
16+
This will generate jsdoc for the code in __src/main/ml-modules/lib__
17+
18+
The html documentation will be generated in __build/docs/jsdoc__
19+
20+
## Customize
21+
22+
To customise the jsdoc output, you can modify the __jsdoc.json__ file. Refer to the http://usejsdoc.org/about-configuring-jsdoc.html site for details on how to configure this.
23+
24+
To customise the jsdoc task generator, please customize the __generateJsDoc__ task in the __build.gradle__ file. Refer to the [JSDoc Gradle Plugin](https://github.com/liferay/liferay-portal/tree/master/modules/sdk/gradle-plugins-jsdoc) site for details on how to configure this.
25+
26+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
buildscript {
2+
repositories {
3+
mavenCentral()
4+
}
5+
6+
dependencies {
7+
classpath 'commons-io:commons-io:2.6'
8+
}
9+
}
10+
11+
plugins {
12+
id "com.marklogic.ml-gradle" version "3.11.0"
13+
id "com.liferay.app.jsdoc" version "2.0.19"
14+
}
15+
16+
17+
task generateJsDoc(type:com.liferay.gradle.plugins.jsdoc.JSDocTask) {
18+
configuration = project.resources.text.fromFile(file("jsdoc.json"))
19+
destinationDir = "build/docs/jsdoc"
20+
sourceDirs = file("src/main/ml-modules/lib")
21+
}

examples/jsdoc-project/jsdoc.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"plugins": [],
3+
"recurseDepth": 10,
4+
"source": {
5+
"includePattern": ".+\\.s?js(doc|x)?$",
6+
"excludePattern": "(^|\\/|\\\\)_"
7+
},
8+
"sourceType": "module",
9+
"tags": {
10+
"allowUnknownTags": true,
11+
"dictionaries": ["jsdoc","closure"]
12+
},
13+
"templates": {
14+
"cleverLinks": false,
15+
"monospaceLinks": false
16+
}
17+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Sample Module
3+
*
4+
* @module "/sample.sjs"
5+
*/
6+
module.exports = {
7+
/**
8+
* Returns "Hello " plus the str parameter
9+
*
10+
* @example
11+
* const sampleLib = require("/sample.sjs")
12+
* // returns "Hello World"
13+
* sampleLib.hello("World")
14+
*
15+
* @param {string} str the string to say hello to
16+
*/
17+
hello: function(str) {
18+
return `Hello ${str}`
19+
}
20+
}

0 commit comments

Comments
 (0)