3

I'm running Grunt and can't get docker (jsdocs) to place it's generated files in an external folder. Regardless of what "dest" I pass, it still places the generated html files in the same directory as the javascript files.

Grunt build -v logs:

Running "docker:build" (docker) task
Verifying property docker.build exists in config...OK
Files: C:/mysite/src/html/scripts/components/app-helpers.js -> jsdocs/app-helpers.js
Files: C:/mysite/src/html/scripts/components/datatables-functions.js -> jsdocs/datatables-functions.js
Files: C:/mysite/src/html/scripts/components/highcharts-functions.js -> jsdocs/highcharts-functions.js
Files: C:/mysite/src/html/scripts/components/pagination.js -> jsdocs/pagination.js
Files: C:/mysite/src/html/scripts/components/resizer.js -> jsdocs/resizer.js
Files: C:/mysite/src/html/scripts/components/slideout.js -> jsdocs/slideout.js
Files: C:/mysite/src/html/scripts/components/tabs.js -> jsdocs/tabs.js
Files: C:/mysite/src/html/scripts/components/ui.js -> jsdocs/ui.js
Files: C:/mysite/src/html/scripts/components/widget.js -> jsdocs/widget.js
Files: C:/mysite/src/html/scripts/components/widgets/cards.js -> jsdocs/cards.js
Files: C:/mysite/src/html/scripts/components/widgets/figures.js -> jsdocs/figures.js
Files: C:/mysite/src/html/scripts/components/widgets/flip-card.js -> jsdocs/flip-card.js
Files: C:/mysite/src/html/scripts/components/widgets/list-view.js -> jsdocs/list-view.js
Files: C:/mysite/src/html/scripts/components/widgets/projects.js -> jsdocs/projects.js
Options: onlyUpdated=false, colourScheme="default", ignoreHidden=false, sidebarState, exclude=false, lineNums=false, js=[], css=[], extras=[]
Options: onlyUpdated=false, colourScheme="default", ignoreHidden=false, sidebarState, exclude=false, lineNums=false, js=[], css=[], extras=[]
Destination: jsdocs/app-helpers.js
Destination: jsdocs/datatables-functions.js
Destination: jsdocs/highcharts-functions.js
Destination: jsdocs/pagination.js
Destination: jsdocs/resizer.js
Destination: jsdocs/slideout.js
Destination: jsdocs/tabs.js
Destination: jsdocs/ui.js
Destination: jsdocs/widget.js
Destination: jsdocs/cards.js
Destination: jsdocs/figures.js
Destination: jsdocs/flip-card.js
Destination: jsdocs/list-view.js
Destination: jsdocs/projects.js
Generated: C:\mysite\src\html\scripts\components\app-helpers.js.html
Generated: C:\mysite\src\html\scripts\components\datatables-functions.js.html
Generated: C:\mysite\src\html\scripts\components\highcharts-functions.js.html
Generated: C:\mysite\src\html\scripts\components\pagination.js.html
Generated: C:\mysite\src\html\scripts\components\resizer.js.html
Generated: C:\mysite\src\html\scripts\components\slideout.js.html
Generated: C:\mysite\src\html\scripts\components\tabs.js.html
Generated: C:\mysite\src\html\scripts\components\ui.js.html
Generated: C:\mysite\src\html\scripts\components\widget.js.html
Generated: C:\mysite\src\html\scripts\components\widgets\cards.js.html
Generated: C:\mysite\src\html\scripts\components\widgets\figures.js.html
Generated: C:\mysite\src\html\scripts\components\widgets\flip-card.js.html
Generated: C:\mysite\src\html\scripts\components\widgets\list-view.js.html
Generated: C:\mysite\src\html\scripts\components\widgets\projects.js.html
Saved file tree to doc-filelist.js
Copied JS to doc-script.js
Copied default.css to doc-style.css
Done.

My config

docker: {
            build: {
                expand: true,
                flatten: true,
                cwd: String(global_scripts_folder).replace(/\\\\/g, "/").replace(/\\/g, "/"),
                src: ['components/**/*.js'],
                dest: 'jsdocs',
                options: {
                    //template : "node_modules/ink-docstrap/cosmo",
                    //configure : "node_modules/ink-docstrap/template/jsdoc.conf.json"
                }
            }
        },
  • you are on a windows machine. So I am not sure about this line `cwd: String(global_scripts_folder).replace(/\\\\/g, "/").replace(/\\/g, "/")`. Unlike Linux, I think windows directory path are based on `\` forward slash. Try comment out that regular expression and see if it works – Samuel Toh Aug 06 '16 at 23:39
  • Correct, I'm on a Windows Machine. I tried removing the regular expression and got the same result. It's just strange how it prints all of the destination paths correctly and then doesn't place the generated files in them. –  Aug 08 '16 at 01:16
  • Thanks @user2094477 for getting back on me. I have written the solution out as an answer and tried to answer the question you have in your comment. Will appreciate it if you can click on the `tick` beside the answer to mark this as answered. So that we can have a closure to this. Thanks. – Samuel Toh Aug 08 '16 at 01:37

1 Answers1

0

Based on the command line logs, sounds like running that grunt file on a windows box hence this regular expression;

cwd: String(global_scripts_folder).replace(/\\\\/g, "/").replace(/\\/g, "/")

could cause you grieve simply because; Windows directory paths are based on \ forward slash.

The trouble here is that the regexpr is trying to turn all the forward slashes into back slashes which would work if this Grunt file is ported from a Windows to a Linux environment.

Q: It's just strange how it prints all of the destination paths correctly and then doesn't place the generated files in them.

A: I think the -v verbose mode from Grunt is reporting things correctly. It is just that the file is now named as jsdocs/datatables-functions.js instead of just datatables-function.js. Somehow windows must have interpret that as a full file name.

Hope this helps.

Samuel Toh
  • 18,006
  • 3
  • 24
  • 39
  • It's true, I'm on a Windows machine... not by choice ;). My entire gruntfile is using forward slashes without any issues. Removing the replace functions doesn't effect the results here and the files that are being saved do not have 'jsdocs/' in them. They have the same name with the html extension added to the end and are being placed right beside the js files. However, files named doc-filelist.js, doc-script.js, and doc-style.css are being placed in the correct directory (jsdocs). –  Aug 08 '16 at 02:22