Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsdoc-plantuml

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsdoc-plantuml - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

fixBrokenNodeJS.js

56

index.js

@@ -0,1 +1,4 @@

/* eslint-env node */
'use strict';
const env = require('jsdoc/env');

@@ -7,3 +10,3 @@ const logger = require('jsdoc/util/logger');

const logPrefix = 'jsdoc-plantuml: ';
const logPrefix = 'jsdoc-plantuml:';

@@ -18,2 +21,3 @@ // lazy init if needed

createImages: true,
replaceWithImage: false,
pathPuml: './jsDoc/puml',

@@ -41,12 +45,13 @@ pathImages: './jsDoc/images',

myConfig.pathPuml = config.puml.destination;
logger.debug(logPrefix + 'got destination path from config: ' + myConfig.pathPuml);
logger.debug(`${logPrefix} got destination path from config: ${myConfig.pathPuml}`);
}
}
logger.info(logPrefix + 'using destination path for puml files: ' + myConfig.pathPuml);
logger.info(`${logPrefix} using destination path for puml files: ${myConfig.pathPuml}`);
if (config.images) {
if (typeof config.images.create === 'boolean') myConfig.createImages = config.images.create;
if (typeof config.images.replaceWithImage === 'boolean') myConfig.replaceWithImage = config.images.replaceWithImage;
if (config.images.destination) {
myConfig.pathImages = config.images.destination;
logger.debug('got destination path from config: ' + myConfig.pathImages);
logger.debug(`${logPrefix} got destination path from config: ${myConfig.pathImages}`);
}

@@ -57,3 +62,3 @@ if (config.images.defaultFormat) {

}
logger.info(logPrefix + 'using destination path for image files: ' + myConfig.pathImages);
logger.info(`${logPrefix} using destination path for image files: ${myConfig.pathImages}`);
}

@@ -72,10 +77,10 @@ // end configuration

try {
plantuml = require('node-plantuml');
plantuml = require('node-plantuml-latest');
}
catch (ex) {
logger.error(logPrefix + '"createImages" is set to TRUE but package "node-plantuml" not installed');
logger.error(`${logPrefix} "createImages" is set to TRUE but package "node-plantuml" not installed`);
}
}
},
/** check all doclets creeated and extract list of uml descriptions found to either write PUML files with
/** check all doclets created and extract list of uml descriptions found to either write PUML files with
* their source or create image from them

@@ -86,8 +91,8 @@ *

processingComplete: function(e) {
logger.debug(logPrefix + 'processingComplete: doclet length=' + e.doclets.length);
logger.debug(`${logPrefix} processingComplete: doclet length=${e.doclets.length}`);
let umlTags = [];
e.doclets.filter((d) => Array.isArray(d.plantUml))
.forEach((doc) => doc.plantUml.forEach((tag) => umlTags.push(tag)));
.forEach((doc) => doc.plantUml.forEach((tag) => umlTags.push(tag)));
logger.debug(logPrefix + 'processingComplete: uml tags length=' + umlTags.length + ', ' + JSON.stringify(umlTags));
logger.debug(`${logPrefix} processingComplete: uml tags length=${umlTags.length}, ` + JSON.stringify(umlTags));
umlTags.forEach(function(umlTag) {

@@ -98,7 +103,7 @@ if (myConfig.createPuml && umlTag.outFilePuml) {

if (err && !err.EEXIST) {
logger.error(logPrefix + 'Cannot create directory to write puml files: ' + err.toString());
logger.error(`${logPrefix} Cannot create directory to write puml files: ${err.toString()}`);
return;
}
fse.outputFile(umlTag.outFilePuml, umlTag.value.description, function(err) {
if (err) logger.error(logPrefix + 'Could not write PUML file at ' + umlTag.outFilePuml + ': ' + JSON.stringify(err));
if (err) logger.error(`${logPrefix} Could not write PUML file at ${umlTag.outFilePuml}: ` + JSON.stringify(err));
});

@@ -108,6 +113,6 @@ });

if (myConfig.createImages && umlTag.outFileImage) {
logger.info(logPrefix + 'writing ' + umlTag.imageFormat + ' image file ' + umlTag.outFileImage);
logger.info(`${logPrefix} writing ${umlTag.imageFormat} image file ${umlTag.outFileImage}`);
fse.ensureDir(path.dirname(umlTag.outFileImage), function(err) {
if (err && !err.EEXIST) {
logger.error(logPrefix + 'Cannot create directory to write image files: ' + err.toString());
logger.error(`${logPrefix} Cannot create directory to write image files: ${err.toString()}`);
return;

@@ -130,3 +135,3 @@ }

mustHaveValue: true,
/** define doclet for startuml to to catch all plat uml related definitions
/** define doclet for startuml to to catch all plant uml related definitions
*

@@ -143,3 +148,3 @@ * @param {object} doclet latest doclet

let extension = path.extname(tag.value.name);
logger.debug(logPrefix + 'found uml tag with file name extension ' + extension);
logger.debug(`${logPrefix} found uml tag with file name extension ${extension}`);
switch (extension.toLowerCase()) {

@@ -152,3 +157,3 @@ case '.png':

tag.outFilePuml = path.join(process.cwd(), tag.outFilePuml);
logger.debug(logPrefix + 'new puml path not absolute - new is ' + tag.outFilePuml);
logger.debug(`${logPrefix} new puml path not absolute - new is ${tag.outFilePuml}`);
}

@@ -175,3 +180,4 @@ if (myConfig.pathImages) {

if (myConfig.pathImages) {
tag.outFileImage = path.join(myConfig.pathImages, tag.value.name.replace(new RegExp(extension + '$'), '.' + myConfig.imageFormat));
tag.outFileImage = path.join(myConfig.pathImages,
tag.value.name.replace(new RegExp(extension + '$'), '.' + myConfig.imageFormat));
if (!path.isAbsolute(tag.outFileImage)) {

@@ -185,12 +191,12 @@ tag.outFileImage = path.join(process.cwd(), tag.outFileImage);

default:
logger.warn(logPrefix + 'IGNORED: unknown image format "' + extension + '" or image name missing for @startuml tag at doclet starting line ' +
doclet.meta.lineno + ', file ' + tag.srcFile);
logger.warn(`${logPrefix} IGNORED: unknown image format "${extension}" or image name missing for @startuml tag ` +
`at doclet starting line ${doclet.meta.lineno}, file ${tag.srcFile}`);
}
}
else {
logger.warn(logPrefix + 'IGNORED: image name missing for @startuml tag at doclet starting line ' + doclet.meta.lineno +
', file ' + tag.srcFile);
logger.warn(`${logPrefix} IGNORED: image name missing for @startuml tag at doclet starting line ${doclet.meta.lineno}, ` +
`file ${tag.srcFile}`);
}
logger.debug(logPrefix + 'startuml / onTagged: tag=' + JSON.stringify(tag));
logger.debug(`${logPrefix} startuml / onTagged: tag=${JSON.stringify(tag)}`);
}

@@ -207,5 +213,5 @@ });

onTagged: function(doclet, tag) {
logger.debug(logPrefix + 'enduml / onTagged: tag=' + JSON.stringify(tag));
logger.debug(`${logPrefix} enduml / onTagged: tag=${JSON.stringify(tag)}`);
}
});
};
{
"name": "jsdoc-plantuml",
"version": "1.0.1",
"version": "1.0.2",
"description": "jsdoc3 plugin to use plantuml inside javascript documentation",
"main": "./index.js",
"scripts": {
"test": "grunt --gruntfile test/Gruntfile.js",
"fixBrokenNodeJS": "node ./fixBrokenNodeJS.js"
},
"author": {

@@ -21,9 +25,9 @@ "name": "Stefan Seide"

"engines": {
"node": ">=6.x"
"node": ">=10.x"
},
"dependencies": {
"fs-extra": "^7.0.0"
"fs-extra": "^9.0.0"
},
"optionalDependencies": {
"node-plantuml": "~0.8.1"
"node-plantuml-latest": "~2.1.0"
},

@@ -33,2 +37,7 @@ "peerDependencies": {

},
"devDependencies": {
"grunt": "^1.4.1",
"grunt-jsdoc": "^2.4.1",
"jsdoc": "^3.6.7"
},
"readmeFilename": "README.md",

@@ -35,0 +44,0 @@ "bugs": {

# jsdoc-plantuml
[![npm](https://img.shields.io/npm/v/jsdoc-plantuml.svg)](https://www.npmjs.com/package/jsdoc-plantuml)
[![Known Vulnerabilities](https://snyk.io/test/github/trilobyte-berlin/jsdoc-plantuml/badge.svg)](https://snyk.io/test/github/trilobyte-berlin/jsdoc-plantuml)
[![Dependency Status](https://david-dm.org/trilobyte-berlin/jsdoc-plantuml.svg)](https://david-dm.org/trilobyte-berlin/jsdoc-plantuml)
[![NPM](https://nodei.co/npm/jsdoc-plantuml.png?downloads=true&stars=true)](https://nodei.co/npm/jsdoc-plantuml/)
This package contains a jsdoc3 plugin to use plantuml inside javascript documentation.

@@ -17,2 +24,12 @@

## Attention
Starting with NodeJS 12.16 there was a change introduced into NodeJS that breaks using
the `plant-uml` package as nodejs library (https://github.com/nodejs/node/issues/36173).
A dirty work-around is implementet in this package script `fixBrokenNodeJS.js`.
Just run it once after package installation and before using this JSDoc plugin to generate
images from plant-uml code.
This is not done automatically - it needs to run manually once.
## Usage

@@ -19,0 +36,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc