mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-16 18:54:12 +01:00
enable eslint fix and eslint-plugin-jsdoc
This commit is contained in:
committed by
Matthieu Morel
parent
c29c8bd33c
commit
4d103c14f7
@@ -251,6 +251,10 @@ export const addALink = function (actorId, text) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {any} actor
|
||||
* @param {any} links
|
||||
*/
|
||||
function insertLinks(actor, links) {
|
||||
if (actor.links == null) {
|
||||
actor.links = links;
|
||||
@@ -275,6 +279,10 @@ export const addProperties = function (actorId, text) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {any} actor
|
||||
* @param {any} properties
|
||||
*/
|
||||
function insertProperties(actor, properties) {
|
||||
if (actor.properties == null) {
|
||||
actor.properties = properties;
|
||||
|
||||
@@ -97,6 +97,9 @@ export const bounds = {
|
||||
updateBounds: function (startx, starty, stopx, stopy) {
|
||||
const _self = this;
|
||||
let cnt = 0;
|
||||
/**
|
||||
* @param {any} type
|
||||
*/
|
||||
function updateFn(type) {
|
||||
return function updateItemBounds(item) {
|
||||
cnt++;
|
||||
@@ -198,8 +201,9 @@ export const bounds = {
|
||||
|
||||
/**
|
||||
* Draws an note in the diagram with the attached line
|
||||
* @param elem - The diagram to draw to.
|
||||
* @param noteModel:{x: number, y: number, message: string, width: number} - startx: x axis start position, verticalPos: y axis position, messsage: the message to be shown, width: Set this with a custom width to override the default configured width.
|
||||
*
|
||||
* @param {any} elem - The diagram to draw to.
|
||||
* @param {{x: number, y: number, message: string, width: number}} noteModel - startx: x axis start position, verticalPos: y axis position, messsage: the message to be shown, width: Set this with a custom width to override the default configured width.
|
||||
*/
|
||||
const drawNote = function (elem, noteModel) {
|
||||
bounds.bumpVerticalPos(conf.boxMargin);
|
||||
@@ -268,8 +272,9 @@ const actorFont = (cnf) => {
|
||||
|
||||
/**
|
||||
* Draws a message
|
||||
* @param g - the parent of the message element
|
||||
* @param msgModel - the model containing fields describing a message
|
||||
*
|
||||
* @param {any} g - the parent of the message element
|
||||
* @param {any} msgModel - the model containing fields describing a message
|
||||
*/
|
||||
const drawMessage = function (g, msgModel) {
|
||||
bounds.bumpVerticalPos(10);
|
||||
@@ -499,6 +504,13 @@ const activationBounds = function (actor, actors) {
|
||||
return [left, right];
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {any} loopWidths
|
||||
* @param {any} msg
|
||||
* @param {any} preMargin
|
||||
* @param {any} postMargin
|
||||
* @param {any} addLoopFn
|
||||
*/
|
||||
function adjustLoopHeightForWrap(loopWidths, msg, preMargin, postMargin, addLoopFn) {
|
||||
bounds.bumpVerticalPos(preMargin);
|
||||
let heightAdjust = postMargin;
|
||||
@@ -521,8 +533,9 @@ function adjustLoopHeightForWrap(loopWidths, msg, preMargin, postMargin, addLoop
|
||||
|
||||
/**
|
||||
* Draws a sequenceDiagram in the tag with id: id based on the graph definition in text.
|
||||
* @param text
|
||||
* @param id
|
||||
*
|
||||
* @param {any} text
|
||||
* @param {any} id
|
||||
*/
|
||||
export const draw = function (text, id) {
|
||||
conf = configApi.getConfig().sequence;
|
||||
@@ -556,6 +569,10 @@ export const draw = function (text, id) {
|
||||
svgDraw.insertArrowFilledHead(diagram);
|
||||
svgDraw.insertSequenceNumber(diagram);
|
||||
|
||||
/**
|
||||
* @param {any} msg
|
||||
* @param {any} verticalPos
|
||||
*/
|
||||
function activeEnd(msg, verticalPos) {
|
||||
const activationData = bounds.endActivation(msg);
|
||||
if (activationData.starty + 18 > verticalPos) {
|
||||
@@ -775,8 +792,9 @@ export const draw = function (text, id) {
|
||||
* It will enumerate each given message, and will determine its text width, in relation
|
||||
* to the actor it originates from, and destined to.
|
||||
*
|
||||
* @param actors - The actors map
|
||||
* @param messages - A list of message objects to iterate
|
||||
* @param {any} actors - The actors map
|
||||
* @param {Array} messages - A list of message objects to iterate
|
||||
* @returns {any}
|
||||
*/
|
||||
const getMaxMessageWidthPerActor = function (actors, messages) {
|
||||
const maxMessageWidthPerActor = {};
|
||||
@@ -894,8 +912,8 @@ const getRequiredPopupWidth = function (actor) {
|
||||
* An actor's margin is determined by the width of the actor, the width of the
|
||||
* largest message that originates from it, and the configured conf.actorMargin.
|
||||
*
|
||||
* @param actors - The actors map to calculate margins for
|
||||
* @param actorToMessageWidth - A map of actor key -> max message width it holds
|
||||
* @param {any} actors - The actors map to calculate margins for
|
||||
* @param {any} actorToMessageWidth - A map of actor key -> max message width it holds
|
||||
*/
|
||||
const calculateActorMargins = function (actors, actorToMessageWidth) {
|
||||
let maxHeight = 0;
|
||||
|
||||
@@ -275,6 +275,14 @@ export const drawText = function (elem, textData) {
|
||||
};
|
||||
|
||||
export const drawLabel = function (elem, txtObject) {
|
||||
/**
|
||||
* @param {any} x
|
||||
* @param {any} y
|
||||
* @param {any} width
|
||||
* @param {any} height
|
||||
* @param {any} cut
|
||||
* @returns {any}
|
||||
*/
|
||||
function genPoints(x, y, width, height, cut) {
|
||||
return (
|
||||
x +
|
||||
@@ -320,9 +328,10 @@ export const fixLifeLineHeights = (diagram, bounds) => {
|
||||
|
||||
/**
|
||||
* Draws an actor in the diagram with the attached line
|
||||
* @param elem - The diagram we'll draw to.
|
||||
* @param actor - The actor to draw.
|
||||
* @param conf - drawText implementation discriminator object
|
||||
*
|
||||
* @param {any} elem - The diagram we'll draw to.
|
||||
* @param {any} actor - The actor to draw.
|
||||
* @param {any} conf - drawText implementation discriminator object
|
||||
*/
|
||||
const drawActorTypeParticipant = function (elem, actor, conf) {
|
||||
const center = actor.x + actor.width / 2;
|
||||
@@ -494,11 +503,12 @@ export const anchorElement = function (elem) {
|
||||
};
|
||||
/**
|
||||
* Draws an activation in the diagram
|
||||
* @param elem - element to append activation rect.
|
||||
* @param bounds - activation box bounds.
|
||||
* @param verticalPos - precise y cooridnate of bottom activation box edge.
|
||||
* @param conf - sequence diagram config object.
|
||||
* @param actorActivations - number of activations on the actor.
|
||||
*
|
||||
* @param {any} elem - element to append activation rect.
|
||||
* @param {any} bounds - activation box bounds.
|
||||
* @param {any} verticalPos - precise y cooridnate of bottom activation box edge.
|
||||
* @param {any} conf - sequence diagram config object.
|
||||
* @param {any} actorActivations - number of activations on the actor.
|
||||
*/
|
||||
export const drawActivation = function (elem, bounds, verticalPos, conf, actorActivations) {
|
||||
const rect = getNoteRect();
|
||||
@@ -513,10 +523,12 @@ export const drawActivation = function (elem, bounds, verticalPos, conf, actorAc
|
||||
|
||||
/**
|
||||
* Draws a loop in the diagram
|
||||
* @param elem - elemenet to append the loop to.
|
||||
* @param loopModel - loopModel of the given loop.
|
||||
* @param labelText - Text within the loop.
|
||||
* @param conf - diagrom configuration
|
||||
*
|
||||
* @param {any} elem - elemenet to append the loop to.
|
||||
* @param {any} loopModel - loopModel of the given loop.
|
||||
* @param {any} labelText - Text within the loop.
|
||||
* @param {any} conf - diagrom configuration
|
||||
* @returns {any}
|
||||
*/
|
||||
export const drawLoop = function (elem, loopModel, labelText, conf) {
|
||||
const {
|
||||
@@ -613,8 +625,9 @@ export const drawLoop = function (elem, loopModel, labelText, conf) {
|
||||
|
||||
/**
|
||||
* Draws a background rectangle
|
||||
* @param elem diagram (reference for bounds)
|
||||
* @param bounds shape of the rectangle
|
||||
*
|
||||
* @param {any} elem diagram (reference for bounds)
|
||||
* @param {any} bounds shape of the rectangle
|
||||
*/
|
||||
export const drawBackgroundRect = function (elem, bounds) {
|
||||
const rectElem = drawRect(elem, {
|
||||
@@ -675,6 +688,8 @@ export const insertClockIcon = function (elem) {
|
||||
|
||||
/**
|
||||
* Setup arrow head and define the marker. The result is appended to the svg.
|
||||
*
|
||||
* @param elem
|
||||
*/
|
||||
export const insertArrowHead = function (elem) {
|
||||
elem
|
||||
@@ -692,6 +707,8 @@ export const insertArrowHead = function (elem) {
|
||||
};
|
||||
/**
|
||||
* Setup arrow head and define the marker. The result is appended to the svg.
|
||||
*
|
||||
* @param {any} elem
|
||||
*/
|
||||
export const insertArrowFilledHead = function (elem) {
|
||||
elem
|
||||
@@ -708,6 +725,8 @@ export const insertArrowFilledHead = function (elem) {
|
||||
};
|
||||
/**
|
||||
* Setup node number. The result is appended to the svg.
|
||||
*
|
||||
* @param {any} elem
|
||||
*/
|
||||
export const insertSequenceNumber = function (elem) {
|
||||
elem
|
||||
@@ -727,6 +746,8 @@ export const insertSequenceNumber = function (elem) {
|
||||
};
|
||||
/**
|
||||
* Setup arrow head and define the marker. The result is appended to the svg.
|
||||
*
|
||||
* @param {any} elem
|
||||
*/
|
||||
export const insertArrowCrossHead = function (elem) {
|
||||
const defs = elem.append('defs');
|
||||
@@ -791,6 +812,15 @@ export const getNoteRect = function () {
|
||||
};
|
||||
|
||||
const _drawTextCandidateFunc = (function () {
|
||||
/**
|
||||
* @param {any} content
|
||||
* @param {any} g
|
||||
* @param {any} x
|
||||
* @param {any} y
|
||||
* @param {any} width
|
||||
* @param {any} height
|
||||
* @param {any} textAttrs
|
||||
*/
|
||||
function byText(content, g, x, y, width, height, textAttrs) {
|
||||
const text = g
|
||||
.append('text')
|
||||
@@ -801,6 +831,16 @@ const _drawTextCandidateFunc = (function () {
|
||||
_setTextAttrs(text, textAttrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} content
|
||||
* @param {any} g
|
||||
* @param {any} x
|
||||
* @param {any} y
|
||||
* @param {any} width
|
||||
* @param {any} height
|
||||
* @param {any} textAttrs
|
||||
* @param {any} conf
|
||||
*/
|
||||
function byTspan(content, g, x, y, width, height, textAttrs, conf) {
|
||||
const { actorFontSize, actorFontFamily, actorFontWeight } = conf;
|
||||
|
||||
@@ -830,6 +870,16 @@ const _drawTextCandidateFunc = (function () {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} content
|
||||
* @param {any} g
|
||||
* @param {any} x
|
||||
* @param {any} y
|
||||
* @param {any} width
|
||||
* @param {any} height
|
||||
* @param {any} textAttrs
|
||||
* @param {any} conf
|
||||
*/
|
||||
function byFo(content, g, x, y, width, height, textAttrs, conf) {
|
||||
const s = g.append('switch');
|
||||
const f = s
|
||||
@@ -856,6 +906,10 @@ const _drawTextCandidateFunc = (function () {
|
||||
_setTextAttrs(text, textAttrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} toText
|
||||
* @param {any} fromTextAttrsDict
|
||||
*/
|
||||
function _setTextAttrs(toText, fromTextAttrsDict) {
|
||||
for (const key in fromTextAttrsDict) {
|
||||
if (fromTextAttrsDict.hasOwnProperty(key)) { // eslint-disable-line
|
||||
@@ -870,6 +924,15 @@ const _drawTextCandidateFunc = (function () {
|
||||
})();
|
||||
|
||||
const _drawMenuItemTextCandidateFunc = (function () {
|
||||
/**
|
||||
* @param {any} content
|
||||
* @param {any} g
|
||||
* @param {any} x
|
||||
* @param {any} y
|
||||
* @param {any} width
|
||||
* @param {any} height
|
||||
* @param {any} textAttrs
|
||||
*/
|
||||
function byText(content, g, x, y, width, height, textAttrs) {
|
||||
const text = g
|
||||
.append('text')
|
||||
@@ -880,6 +943,16 @@ const _drawMenuItemTextCandidateFunc = (function () {
|
||||
_setTextAttrs(text, textAttrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} content
|
||||
* @param {any} g
|
||||
* @param {any} x
|
||||
* @param {any} y
|
||||
* @param {any} width
|
||||
* @param {any} height
|
||||
* @param {any} textAttrs
|
||||
* @param {any} conf
|
||||
*/
|
||||
function byTspan(content, g, x, y, width, height, textAttrs, conf) {
|
||||
const { actorFontSize, actorFontFamily, actorFontWeight } = conf;
|
||||
|
||||
@@ -905,6 +978,16 @@ const _drawMenuItemTextCandidateFunc = (function () {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} content
|
||||
* @param {any} g
|
||||
* @param {any} x
|
||||
* @param {any} y
|
||||
* @param {any} width
|
||||
* @param {any} height
|
||||
* @param {any} textAttrs
|
||||
* @param {any} conf
|
||||
*/
|
||||
function byFo(content, g, x, y, width, height, textAttrs, conf) {
|
||||
const s = g.append('switch');
|
||||
const f = s
|
||||
@@ -931,6 +1014,10 @@ const _drawMenuItemTextCandidateFunc = (function () {
|
||||
_setTextAttrs(text, textAttrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} toText
|
||||
* @param {any} fromTextAttrsDict
|
||||
*/
|
||||
function _setTextAttrs(toText, fromTextAttrsDict) {
|
||||
for (const key in fromTextAttrsDict) {
|
||||
if (fromTextAttrsDict.hasOwnProperty(key)) { // eslint-disable-line
|
||||
|
||||
Reference in New Issue
Block a user