Skip to content

Commit

Permalink
prepare documentation with yuidoc
Browse files Browse the repository at this point in the history
  • Loading branch information
erossignon committed May 10, 2014
1 parent 7486a62 commit b78abbc
Show file tree
Hide file tree
Showing 19 changed files with 674 additions and 190 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ istanbul:
coveralls:
cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js


# construct the API javascript documentation
doc: lib/a.js
mkdir tmptmp/autogenerated
node code_gen/makedoc.js > tmptmp/autogenerated/a.js
autodoc tmptmp/autogenerated/a.js
jsdoc -v tmptmp/autogenerated/a.js lib/nodeid.js -d=tttt
yuidoc
112 changes: 112 additions & 0 deletions code_gen/makedoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
var _ = require("underscore");
var assert=require("assert");

console.log("/**");
console.log(" * @module toto");
console.log(" */");

dumpModule(require("../lib/variant.js"));
dumpModule(require("../lib/buildinfo.js"));
dumpModule(require("../lib/browse_service.js"));
dumpModule(require("../lib/factories.js"));
dumpModule(require("../lib/subscription_service.js"));
dumpModule(require("../lib/read_service.js"));
dumpModule(require("../lib/session_service.js"));
dumpModule(require("../lib/write_service.js"));
dumpModule(require("../lib/translate_browse_paths_to_node_ids_service.js"));
dumpModule(require("../lib/structures.js"));
dumpModule(require("../lib/secure_channel_service.js"));
dumpModule(require("../lib/register_server_service.js"));
dumpModule(require("../lib/nodeopcua.js"));
dumpModule(require("../lib/datavalue.js"));



function dumpClass(schema) {

// assert(schema.hasOwnProperty("comment"));

var className = schema.name;

var documentation = schema.documentation;
console.log("/**")
console.log(" * " + documentation);
console.log(" * @class ", className);
console.log(" * @extends ", "BaseObject");

console.log(" * @constructor ", className);


console.log(" * @param {Object} options - Options to initialize the component with");

if (true) {
_.forEach(Object.keys(schema.fields), function (b) {
var field = schema.fields[b];
var name = field.name;
var fieldType = field.fieldType;
var documentation = field.documentation;

var propertyName = name;
var propertyType = fieldType;
var s = "{{#crossLink \"" + className +"/"+ propertyName +":attribute" +"\" }}{{/crossLink }}";
console.log(" * @param {" + propertyType + "} options." + propertyName + " - " + documentation + " " + s);
});
}
console.log(" *\/");


if(false) {
_.forEach(Object.keys(schema.fields), function (b) {
var field = schema.fields[b];
var name = field.name;
var fieldType = field.fieldType;
var documentation = field.documentation;
console.log(" * @property ", " {", fieldType, "}", name, " ", documentation);
});
}
//xx console.log('function ',a + "() {");
//xx console.log("}");
if (true) {
_.forEach(Object.keys(schema.fields), function (b) {
var field = schema.fields[b];
var name = field.name;
var fieldType = field.fieldType;
var documentation = field.documentation;
console.log("/**")
console.log(" * "+ documentation);
console.log(" * @property ",name);
console.log(" * @type ",fieldType);
console.log(" *\/");
//xx console.log("this." + name, " = {};");
});
}

}
function dumpModule(module) {

assert(module);

_.forEach(Object.keys(module), function (a) {

var obj = module [a];

if (!obj) {
return;
}
//xx _.forEach(Object.keys(obj),function(b) {
//xx console.log(" ",b);
//xx });

if (obj.hasOwnProperty("prototype") && obj.prototype.hasOwnProperty("_schema")) {

var schema = obj.prototype._schema;

dumpClass(schema);

}

});
}


// ref http://stackoverflow.com/questions/10490713/how-to-document-the-properties-of-the-object-in-the-jsdoc-3-tag-this
44 changes: 12 additions & 32 deletions lib/binaryStream.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,9 @@
/**
* @module utilities
*/

var assert = require('better-assert');
var util = require("util");

var Writable = require("stream").Writable;
var Readable = require("stream").Readable;

/**
* a BinaryReader ...
*
* @class BinaryReader
*/
function BinaryReader(buffer) {
this._buffer = buffer;
Readable.call(this, {});
}
util.inherits(BinaryReader, Readable);

exports.BinaryReader = BinaryReader;

BinaryReader.prototype._read = function() {
this.push(this._buffer);
this.push(null);
};
var assert = require('assert');
/**
* a BinaryStream can be use to perform sequential read or write
* inside a buffer.
Expand Down Expand Up @@ -69,7 +47,7 @@ function BinaryStream(data) {
/**
* set the cursor to the begining of the stream
* @method BinaryStream.rewind
* _r_e_turn null
* @returns null
*/
BinaryStream.prototype.rewind = function () {
this.length = 0;
Expand Down Expand Up @@ -163,7 +141,7 @@ BinaryStream.prototype.writeDouble = function (value) {
/**
* read a single signed byte (8 bits) from the stream.
* @method readByte
* _r_e_turns {Number}
* @returns {Number}
*/
BinaryStream.prototype.readByte = function () {
var retVal = this._buffer.readInt8(this.length);
Expand All @@ -174,7 +152,7 @@ BinaryStream.prototype.readByte = function () {
/**
* read a single unsigned byte (8 bits) from the stream.
* @method readUInt8
* _r_e_turns {Number}
* @returns {Number}
*/
BinaryStream.prototype.readUInt8 = function () {
var retVal = this._buffer.readUInt8(this.length);
Expand All @@ -185,7 +163,7 @@ BinaryStream.prototype.readUInt8 = function () {
/**
* read a single signed 16-bit integer from the stream.
* @method readInt16
* _r_e_turns {Number} q
* @returns {Number}
*/
BinaryStream.prototype.readInt16 = function () {
var retVal = this._buffer.readInt16LE(this.length);
Expand All @@ -196,7 +174,7 @@ BinaryStream.prototype.readInt16 = function () {
/**
* read a single unsigned 16-bit integer from the stream.
* @method readUInt16
* _r_e_turns {Number} q
* @returns {Number} q
*/
BinaryStream.prototype.readUInt16 = function () {
var retVal = this._buffer.readUInt16LE(this.length);
Expand All @@ -207,7 +185,7 @@ BinaryStream.prototype.readUInt16 = function () {
/**
* read a single signed 32-bit integer from the stream.
* @method readInteger
* _r_e_turns {Number}
* @returns {Number}
*/
BinaryStream.prototype.readInteger = function () {
var retVal = this._buffer.readInt32LE(this.length);
Expand All @@ -218,7 +196,7 @@ BinaryStream.prototype.readInteger = function () {
/**
* read a single unsigned 32-bit integer from the stream.
* @method readUInt32
* _r_e_turn {Number} the value read from the stream
* @returns {Number} the value read from the stream
*/
BinaryStream.prototype.readUInt32 = function () {
var retVal = this._buffer.readUInt32LE(this.length);
Expand All @@ -229,7 +207,7 @@ BinaryStream.prototype.readUInt32 = function () {
/**
* read a single 32-bit floating point number from the stream.
* @method readFloat
* _r_e_turn {Number} the value read from the stream
* @returns {Number} the value read from the stream
*/
BinaryStream.prototype.readFloat = function () {
var retVal = this._buffer.readFloatLE(this.length);
Expand All @@ -240,7 +218,7 @@ BinaryStream.prototype.readFloat = function () {
/**
* read a single 64-bit floating point number from the stream.
* @method readDouble
* _r_e_turn {Number} the value read from the stream
* @returns {Number} the value read from the stream
*/
BinaryStream.prototype.readDouble = function () {
var retVal = this._buffer.readDoubleLE(this.length);
Expand Down Expand Up @@ -287,7 +265,7 @@ BinaryStream.prototype.writeByteStream = function (buf) {
* The method reads the length of the byte array from the stream as a 32 bits integer before reading the byte stream.
*
* @method readByteStream
* _r_e_turn {Buffer} qsdsdq
* @return {Buffer}
*/
BinaryStream.prototype.readByteStream = function () {
var bufLen = this.readUInt32();
Expand All @@ -314,7 +292,9 @@ exports.BinaryStream = BinaryStream;
*
* a BinaryStreamSizeCalculator has the same writeXXX methods as the BinaryStream stream
* object.
*
* @class BinaryStreamSizeCalculator
* @extends BinaryStream
* @constructor
*
*/
Expand Down
8 changes: 4 additions & 4 deletions lib/browse_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ exports.BrowseDirection = factories.registerObject(EnumBrowseDirection_Schema);

var BrowseRequest_Schema = {
name:"BrowseRequest",
comment: "Browse the references for one or more nodes from the server address space.",
documentation: "Browse the references for one or more nodes from the server address space.",
fields: [
{name:"requestHeader", fieldType:"RequestHeader", documentation: "A standard header included in all requests sent to a server."},
{name:"view", fieldType:"ViewDescription", documentation: "The view to browse." },
Expand All @@ -109,7 +109,7 @@ exports.BrowseRequest= factories.registerObject(BrowseRequest_Schema);

var BrowseResponse_Schema = {
name:"BrowseResponse",
comment: "Browse the references for one or more nodes from the server address space.",
documentation: "Browse the references for one or more nodes from the server address space.",
fields: [
{name:"responseHeader", fieldType:"ResponseHeader", documentation: "A standard header included in all responses returned by servers."},
{name:"results", isArray:true, fieldType:"BrowseResult", documentation: "The results for the browse operations." },
Expand All @@ -121,7 +121,7 @@ exports.BrowseResponse = factories.registerObject(BrowseResponse_Schema);

var BrowseNextRequest_Schema = {
name:"BrowseNextRequest",
comment: "Continues one or more browse operations.",
documentation: "Continues one or more browse operations.",
fields: [
{name:"requestHeader", fieldType:"RequestHeader", documentation: "A standard header included in all requests sent to a server."},
{name:"releaseContinuationPoints", fieldType:"Boolean", documentation: "If TRUE the continuation points are released and no results are returned." },
Expand All @@ -132,7 +132,7 @@ exports.BrowseNextRequest= factories.registerObject(BrowseNextRequest_Schema);

var BrowseNextResponse_Schema = {
name:"BrowseNextResponse",
comment: "Browse the references for one or more nodes from the server address space.",
documentation: "Browse the references for one or more nodes from the server address space.",
fields: [
{name:"responseHeader", fieldType:"ResponseHeader", documentation: "A standard header included in all responses returned by servers."},
{name:"results", isArray:true, fieldType:"BrowseResult", documentation: "The results for the browse operations." },
Expand Down
12 changes: 6 additions & 6 deletions lib/buildinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ var BuildInfo_Schema = {
documentation:'Server build Info',

fields: [
{ name: "productUri" , fieldType: "String"},
{ name: "manufacturerName" , fieldType: "String"},
{ name: "productName" , fieldType: "String"},
{ name: "softwareVersion" , fieldType: "String"},
{ name: "buildNumber" , fieldType: "String"},
{ name: "buildDate" , fieldType: "UtcTime"}
{ name: "productUri" , fieldType: "String" , documentation: "A description for the ProductUri Variable."},
{ name: "manufacturerName" , fieldType: "String" , documentation: "the name of the manufacturer"},
{ name: "productName" , fieldType: "String" , documentation: "the product name"},
{ name: "softwareVersion" , fieldType: "String" , documentation: "the software version"},
{ name: "buildNumber" , fieldType: "String" , documentation: "the software build number"},
{ name: "buildDate" , fieldType: "UtcTime", documentation: "the software build date"}
]
};
exports.BuildInfo = factories.registerObject(BuildInfo_Schema);
Expand Down

0 comments on commit b78abbc

Please sign in to comment.