Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes all kinds of stuff #7

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

/.vs
67 changes: 52 additions & 15 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
This fork just updates package.json to use node >= 04.10, publishes as a new npm package "jsdoc-toolkit"

======================================================================

DESCRIPTION:
Expand Down Expand Up @@ -26,28 +28,63 @@ Node.JS interpreter http://nodejs.org

======================================================================

INSTALLATION:

`npm install jsdoc-toolkit`

or, you can install it globally and have it available for all your projects.

`npm install jsdoc-toolkit -g`

Make sure to add your global `node_modules/.bin` directory to your path for
convenient access to your global packages from the command line.

======================================================================

USAGE:

Before running the JsDoc Toolkit app you should change your current
working directory to the jsdoc-toolkit folder. Then follow the
examples below, or as shown on the project wiki.
From Scripts:

This module exports jsdoctoolkit, it has a run method that accepts a single
argument: an array of strings corresponding to the exact command line arguments
you would use, in the same order as you would give them on the command line.

```
var jsdocToolkit = require('jsdoc-toolkit').jsdoctoolkit;

jsdocToolkit.run(['--help']);
```

```
var jsdocToolkit = require('jsdoc-toolkit').jsdoctoolkit;
var argz = [
"-d=./docs/", // output directory for documentation.
"-o=./jsdoc-toolkit-log.txt" // file for logging messages like warnings.
"cli.js" // the file or directory to generate documentation for.
];
jsdocToolkit.run(argz);
```

Command line:

Given a file named mycode.js that you want documented:

if you've installed this package globally it's as easy as running

On Mac OS X or Linux the command would look like this:
`jsdoc-toolkit -a mycode.js`

$ app/run.js -a -t=templates/jsdoc mycode.js
If you have installed jsdoc-toolkit into your package instead, from the package
root run

The above assumes your current working directory contains the "app"
and "templates" subdirectories from the standard JsDoc Toolkit
distribution and that the relative path to the code you wish to
document is "mycode.js".
`node_modules/.bin/jsdoc-toolkit -a mycode.js`

The output documentation files will be saved to a new directory named
"out" (by default) in the current directory, or if you specify a
-d=somewhere_else option, to the somewhere_else directory.
In both cases the output documentation files will be saved to a new directory
named "out" (by default) in the current directory, or if you specify a
`-d=somewhere_else` option, to the somewhere_else directory.

For help (usage notes) enter this on the command line:

$ app/run.js --help
`jsdoc-toolkit --help`

More information about the various command line options used by JsDoc
Toolkit are available on the project wiki.
Expand All @@ -59,12 +96,12 @@ TESTING:
To run the suite of unit tests included with JsDoc Toolkit enter this
on the command line:

$ app/run.js -T
npm test

To see a dump of the internal data structure that JsDoc Toolkit has
built from your source files use this command:

$ app/run.js mycode.js -Z
jsdoc-toolkit mycode.js -Z

======================================================================

Expand Down
2 changes: 1 addition & 1 deletion app/lib/JSDOC.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ JSDOC.VERSION = "2.4.0";

/** Print out usage information and quit. */
JSDOC.usage = function() {
print("USAGE: java -jar jsrun.jar app/run.js [OPTIONS] <SRC_DIR> <SRC_FILE> ...");
print("USAGE: node app/run.js [OPTIONS] <SRC_DIR> <SRC_FILE> ...");
print("");
print("OPTIONS:");
print(" -a or --allfunctions\n Include all functions, even undocumented ones.\n");
Expand Down
5 changes: 2 additions & 3 deletions app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ function main() {
}
else {
// a template must be defined and must be a directory path
if (!JSDOC.opt.t && process.env.JSDOCTEMPLATEDIR) {
JSDOC.opt.t = process.env.JSDOCTEMPLATEDIR;
}
JSDOC.opt.t = JSDOC.opt.t || process.env.JSDOCTEMPLATEDIR;
// adds trailing slash to template dir if not present
if (JSDOC.opt.t && SYS.slash != JSDOC.opt.t.slice(-1)) {
JSDOC.opt.t += SYS.slash;
}
Expand Down
2 changes: 1 addition & 1 deletion app/noderun.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node

var toolkit = require("./nodemodule").jsdoctoolkit;
toolkit.run(process.argv);
toolkit.run(process.argv.slice(2));
78 changes: 72 additions & 6 deletions app/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
// load the node.js libraries to be abstracted
var fs = require('fs');
var path = require('path');
var Script = process.binding('evals').Script;
var Script = require('vm');

// default template directory.
process.env.JSDOCTEMPLATEDIR = path.resolve(__dirname, '../templates/jsdoc/');

// define a few globals to be compatible with jsrun.jar
global.arguments = global.internal_args || process.argv.slice(2);
Expand Down Expand Up @@ -133,7 +136,70 @@ SYS.slash = "/";
*/
SYS.pwd = __dirname+SYS.slash;


/**
* Shims java.io.FileWriter
* @class Shims java.io.FileWriter
* @author <a href="mailto:[email protected]">Matthew Kastor</a>
*/
FileWriter = function () {
this.lock = undefined;
this.writeStream = undefined;
};
/**
* Opens a file for writing only.
* @param {String} path The path to the file to write.
* @param {Boolean} [append = true] If set to false the file will be overwritten.
* @returns {FileWriter} returns a new FileWriter instance whose writeStream is
* set to the file at the given path.
* @see <a href="http://nodejs.org/api/fs.html#fs_class_fs_writestream">
* fs.WriteStream</a>
*/
FileWriter.prototype.open = function(/**string*/ path, /**boolean*/ append) {
if(append == null) append = true;
this.writeStream = fs.createWriteStream(path, {flags: (append ? "a" : "w")});
return this;
};
/**
* Closes the write stream.
*/
FileWriter.prototype.close = function () {
this.writeStream.end();
};
/**
* No op. The data is flushed when close is called.
*/
FileWriter.prototype.flush = function () {
// no op, data is flushed when the writeStream's end
// method is called.
};
/**
* Write stream is created with default encoding (utf8). If the open method is
* changed to allow specifying an encoding then it will need to be tracked and
* returned by this method.
* @returns "utf8"
*/
FileWriter.prototype.getEncoding = function () {
return "utf8";
};
/**
* Appends a substring of the given string to the file.
* @param {String} str The string to write.
* @param {Number} [from = 0] The beginning of the substring of str.
* @param {Number} [to = str.length] The end of the substring of str.
*/
FileWriter.prototype.append = function (str, from, to) {
from = from || 0;
to = to || str.length;
str = str.substr(from, to);
this.write(str, 'utf8');
};
/**
* Writes the given data to the file.
* @param {String} str The string to write.
*/
FileWriter.prototype.write = function (str) {
this.writeStream.write(str, 'utf8');
};
/**
* @namespace A collection of functions that deal with reading a writing to disk.
*/
Expand Down Expand Up @@ -162,7 +228,7 @@ IO = {
if (fileName == null) fileName = FilePath.fileName(inFile);
inFile = path.normalize(inFile);
outFile = path.normalize(outDir + "/" + fileName);
if (!path.existsSync(inFile)) {
if (!fs.existsSync(inFile)) {
// Could not find file to copy, ignoring: ' + inFile
// Should we log or safe to ignore?
return;
Expand Down Expand Up @@ -239,11 +305,11 @@ IO = {
},

/**
*
* Opens a file for writing
*/
open: function(/**string*/ path, /**boolean*/ append) {
if(append == null) append = true;
return fs.createWriteStream(path, {flags: (append ? "a" : "w")});
var file = new FileWriter();
return file.open(path, append);
},

/**
Expand Down
7 changes: 7 additions & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
== 2.4.0n1 ==
* Fixes logging to files. It works now.
* Creates files in `node_modules/.bin` so global installs just work.
* Now wrapped properly so jsdoc-toolkit can be called from scripts in node.
* Fixed scripts.test field so npm test works.
* jsdoc template is now the default so you don't have to specify it every time you use it.

== 2.4.0n ==
* Ported to run on Node.JS

Expand Down
24 changes: 16 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
{
"author": "Kaleb Hornsby <[email protected]> (kaleb.hornsby.ws)",
"name": "jsdoc",
"author": "Taka Kojima <[email protected]> ([email protected])",
"contributors": [
{
"name": "Matthew Kastor",
"email": "[email protected]",
"url": "http://matthewkastor.blogspot.com"
}
],
"name": "jsdoc-toolkit",
"description": "JSDoc Toolkit",
"version": "0.0.1",
"version": "2.5.1",
"homepage": "kaleb.hornsby.ws/jsdoc",
"repository": {
"type": "git",
"url": "git://github.com/kaleb/node-jsdoc-toolkit.git"
"url": "git://github.com/gigafied/node-jsdoc-toolkit.git"
},
"main": "app/run.js",
"main": "app/nodemodule.js",
"bin": "app/noderun.js",
"scripts": {
"test": "app/test.js"
"test": "node app/run.js -T"
},
"engines": {
"node": "0.4"
"node": ">= 0.4"
},
"dependencies": {},
"devDependencies": {}
}
}
17 changes: 17 additions & 0 deletions templates/vsdoc/allclasses.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div align="center">{+new Link().toFile("index.html").withText("Class Index")+}
| {+new Link().toFile("files.html").withText("File Index")+}</div>
<hr />
<h2>Classes</h2>
<ul class="classList">
<for each="thisClass" in="data">
<li>{!
if (thisClass.alias == "_global_") {
output += "<i>"+new Link().toClass(thisClass.alias)+"</i>";
}
else {
output += new Link().toClass(thisClass.alias);
}
!}</li>
</for>
</ul>
<hr />
56 changes: 56 additions & 0 deletions templates/vsdoc/allfiles.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset={+IO.encoding+}" />
{! Link.base = ""; /* all generated links will be relative to this */ !}
<title>JsDoc Reference - File Index</title>
<meta name="generator" content="JsDoc Toolkit" />

<style type="text/css">
{+include("static/default.css")+}
</style>
</head>

<body>
{+include("static/header.html")+}

<div id="index">
{+publish.classesIndex+}
</div>

<div id="content">
<h1 class="classTitle">File Index</h1>

<for each="item" in="data">
<div>
<h2>{+new Link().toSrc(item.alias).withText(item.name)+}</h2>
<if test="item.desc">{+resolveLinks(item.desc)+}</if>
<dl>
<if test="item.author">
<dt class="heading">Author:</dt>
<dd>{+item.author+}</dd>
</if>
<if test="item.version">
<dt class="heading">Version:</dt>
<dd>{+item.version+}</dd>
</if>
{! var locations = item.comment.getTag('location').map(function($){return $.toString().replace(/(^\$ ?| ?\$$)/g, '').replace(/^HeadURL: https:/g, 'http:');}) !}
<if test="locations.length">
<dt class="heading">Location:</dt>
<for each="location" in="locations">
<dd><a href="{+location+}">{+location+}</a></dd>
</for>
</if>
</dl>
</div>
<hr />
</for>

</div>
<div class="fineprint" style="clear:both">
<if test="JSDOC.opt.D.copyright">&copy;{+JSDOC.opt.D.copyright+}<br /></if>
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> {+JSDOC.VERSION+} on {+new Date()+}
</div>
</body>
</html>
Loading