Comparing version 0.1.1 to 0.2.0
{ | ||
"name": "jsd-jekyll", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "JSDoc Plugin and Template for making a Github Pages compatable Jekyll Site", | ||
@@ -5,0 +5,0 @@ "main": "src/main.js", |
@@ -27,4 +27,6 @@ # JSDoc Jekyll | ||
#### Repository Links | ||
#### Extra opts | ||
##### `repos` { array } | ||
Optionally a link to your source code on GitHub can be added to the documentation. | ||
@@ -44,2 +46,24 @@ Under opts in the jsdoc config file add: | ||
##### `includeAll` { boolean } default false | ||
This will tag all files processed with `@module filename` if no `@module` tag is present. | ||
##### `functionFix` { boolean } default false | ||
- Removes bracket from a function names. `@function myFunction()` becomes `@function myFunction`. | ||
- Tags untagged descriptions added below the `@function` tag | ||
``` | ||
/** | ||
* @function myFunction | ||
* This is a description in the wrong place. | ||
*/ | ||
``` | ||
Changes to | ||
``` | ||
/** | ||
* @function myFunction | ||
* @description This is a description in the wrong place. | ||
*/ | ||
``` | ||
##### `folderCategory` { boolean } default false | ||
- Assigns modules to categories based on the file location `/api/main/index.js` will be tagged `@category api-main` | ||
## JSDoc | ||
@@ -46,0 +70,0 @@ Basic @jsdoc tags should work as [documented](https://jsdoc.app/). Not all currently work with this template, more will be added over time. |
@@ -9,2 +9,40 @@ /** | ||
exports.handlers = { | ||
beforeParse: function(e) { | ||
//Option to tag each file with '@module filename' | ||
if (env.opts.includeAll) { | ||
if (new RegExp('@module').test(e.source) == false){ | ||
const captures = e.filename.match(/\\(\w*)\\(\w*)\./); | ||
const file = captures[2]; | ||
e.source = `/** @module ${file} */` + e.source; | ||
} | ||
} | ||
if (env.opts.folderCategory) { | ||
//Option to assign modules to categories based on folder | ||
if (new RegExp('@module').test(e.source)){ | ||
const captures = e.filename.match(/\\(\w*)\\(\w*)\\(\w*)\./); | ||
const category = captures[2]; | ||
const moduleName = e.source.match(/(@module +\w*) ?/)[1]; | ||
const replace = `${moduleName} \n * @category ${captures[1]}-${captures[2]}` | ||
e.source = e.source.replace(/(@module +\w*) ?/, replace); | ||
} | ||
} | ||
}, | ||
jsdocCommentFound: function(e) { | ||
// Option to fix @function names with name() -> name and tag @description written after a function | ||
if (env.opts.functionFix) { | ||
const funRegEx = new RegExp(/@(?:method|function)([^@]+)/); | ||
const extraRegEx = new RegExp(/(\w+[^@]+\* )(\w+[^@]*)/); | ||
if (funRegEx.test(e.comment)) { | ||
let content = e.comment.match(funRegEx)[1]; | ||
content = content.replace(/\(\)/,""); | ||
let replacement = `@function${content}`; | ||
if (extraRegEx.test(content)) { | ||
const split = content.split('*'); | ||
split[1] = ` @description${split[1]}` | ||
replacement = `@function${split.join('*')}` | ||
} | ||
e.comment = e.comment.replace(funRegEx, replacement); | ||
} | ||
} | ||
}, | ||
newDoclet: function(e) { | ||
@@ -11,0 +49,0 @@ if (e.doclet.hasOwnProperty("params")) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33049
27
397
108