All of the code refers to jsdocCommentFound but the documentation and
comments in the code refer to jsDocCommentFound. This confused someone
for understandable reasons. I've fixed the typos.
Filenames provided by fs.ls already use slashes instead of backslashes so the replace(fromDir, toDir) does nothing and the file is truncated. (Issue #190)
This was causing it to mis-calculate the paths, and end up losing the
output directory entirely, and overwrite the template static files
with themselves, resulting in truncation to zero-length. Of course,
they were also missing in the output.
It was expecting to be able to split paths on
System.getProperty("path.separator"), but that describes how to put a
path together, not how to take one apart, which is more complicated.
In particular, in windows, / is as valid a separator as \ in all but a
few UI contexts.
And since we need to pass / in paths that may get turned into URI's,
it's important to handle this correctly.
Java already provides a File facility to handle these sorts of operations.
This patch makes use of java.io.File to:
1) Find the parent of a File for dirname.
2) Find the name of a File for basename.
It also now makes use of substring for removing the ext for basename,
rather than Array.prototype.slice + join(""). I'm not sure what that
was all about... It does have the effect of ensuring it's a Javascript
String, but calling String() has the same benefit and is much more clear.
You can put that back if there was a reason for it, but it looks just
confused to me.
Under Cygwin, we need to be a bit more aggressive with replacing \ with /
to avoid \ in URIs internally. This shows up when running the tests with -T,
but not when running files directly, for reasons I don't fully understand.
This patch replaces the previous replacement of \ => / with one that happens
earlier and applies to all references, not just the URIs we construct.
Cygwin now passes jsdoc -T from any directory.