Leaflet / Leafdoc

A lightweight NaturalDocs-like LeafletJS-style documentation generator
54 stars 19 forks source link

Fix multilang parser '.mjs' support, __dirname not defined error and update scripts #53

Closed mondeja closed 4 years ago

mondeja commented 4 years ago

/home/mondeja/files/code/Leafdoc/node_modules/comment-patterns/index.js:18 throw new Error("Cannot find language definition for '" + filename + "'") ^

Error: Cannot find language definition for 'src/cli.mjs' at langIndex (/home/mondeja/files/code/Leafdoc/node_modules/comment-patterns/index.js:18:11) at Function.commentRegex [as regex] (/home/mondeja/files/code/Leafdoc/node_modules/comment-patterns/index.js:50:28) at extract (/home/mondeja/files/code/Leafdoc/node_modules/multilang-extract-comments/index.js:31:17) at multilangParser (file:///home/mondeja/files/code/Leafdoc/src/parsers/multilang.mjs:8:20) at Leafdoc.addStr (file:///home/mondeja/files/code/Leafdoc/src/leafdoc.mjs:228:24) at Leafdoc.addBuffer (file:///home/mondeja/files/code/Leafdoc/src/leafdoc.mjs:193:15) at Leafdoc.addFile (file:///home/mondeja/files/code/Leafdoc/src/leafdoc.mjs:185:15) at file:///home/mondeja/files/code/Leafdoc/src/cli.mjs:57:8 at Array.forEach () at file:///home/mondeja/files/code/Leafdoc/src/cli.mjs:52:8


- **`src/template.mjs`** `__dirname` global constant have been replaced by path resolution from working directory. This prevents next error running `npm install`:

file:///home/mondeja/files/code/Leafdoc/src/template.mjs:10 let templateDir = ${__dirname }/../templates/basic;

ReferenceError: __dirname is not defined

-  **`src/regexps.mjs`** A minor fix to prevent this:

leafdoc@1.5.1 update-markdown-leafdoc /home/mondeja/files/code/Leafdoc src/cli.mjs -t templates/markdown src/cli.js src/leafdoc.mjs --verbose -o Leafdoc.md

file:///home/mondeja/files/code/Leafdoc/src/regexps.mjs:34 leafDirective = xRegExp(\\s* ${ char } (?<directive> \\S+ ) (\\s+ (?<content> [^;\\n]+ )){0,1}, 'gnx'); ^

ReferenceError: Cannot access 'leafDirective' before initialization

mondeja commented 4 years ago

It seems that the pull to comment-patterns have been merged to the master. So, when a new version of multilang-extract-comments have been released with .mjs file detection support, I will change the version in package.json and remove the .mjs exception in src/parsers/multilang.mjs.

mondeja commented 4 years ago

He actualizado la versión de multilang-extract-comments para soportar archivos .mjs.