Tutorials base structure.

This commit is contained in:
Rafał Wrzeszcz 2011-12-15 10:02:05 +01:00
parent dc372e3e58
commit 13526499cf
4 changed files with 111 additions and 2 deletions

View File

@ -142,7 +142,8 @@ function main() {
opts: { opts: {
parser: require('jsdoc/opts/parser'), parser: require('jsdoc/opts/parser'),
} }
}; },
resolver;
env.opts = jsdoc.opts.parser.parse(env.args); env.opts = jsdoc.opts.parser.parse(env.args);
@ -240,6 +241,12 @@ function main() {
exit(0); exit(0);
} }
resolver = require('jsdoc/tutorial/resolver');
var Tutorial = require('jsdoc/tutorial').Tutorial;
// tutorials handling
//TODO
env.opts.template = env.opts.template || 'templates/default'; env.opts.template = env.opts.template || 'templates/default';
// should define a global "publish" function // should define a global "publish" function
@ -248,7 +255,8 @@ function main() {
if (typeof publish === 'function') { if (typeof publish === 'function') {
publish( publish(
new (require('typicaljoe/taffy'))(docs), new (require('typicaljoe/taffy'))(docs),
env.opts env.opts,
resolver.root
); );
} }
else { // TODO throw no publish warning? else { // TODO throw no publish warning?

View File

@ -25,6 +25,7 @@ argParser.addOption('r', 'recurse', false, 'Recurse into subdirectories when
argParser.addOption('h', 'help', false, 'Print this message and quit.'); argParser.addOption('h', 'help', false, 'Print this message and quit.');
argParser.addOption('X', 'explain', false, 'Dump all found doclet internals to console and quit.'); argParser.addOption('X', 'explain', false, 'Dump all found doclet internals to console and quit.');
argParser.addOption('q', 'query', true, 'Provide a querystring to define custom variable names/values to add to the options hash.'); argParser.addOption('q', 'query', true, 'Provide a querystring to define custom variable names/values to add to the options hash.');
argParser.addOption('u', 'tutorials', false, 'Directory in which JSDoc should search for tutorials.');
// TODO [-R, recurseonly] = a number representing the depth to recurse // TODO [-R, recurseonly] = a number representing the depth to recurse

View File

@ -0,0 +1,63 @@
/**
@overview
@author Rafał Wrzeszcz <rafal.wrzeszcz@wrzasq.pl>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
*/
/**
@module jsdoc/tutorial
*/
/**
@class
@classdesc Represents a single JSDoc tutorial.
@param {string} name - Tutorial name.
@param {string} content - Text content.
*/
exports.Tutorial = function(name, content) {
this.title = this.name = name;
this.content = content;
// default values
this.parent = null;
this.children = [];
this.type = exports.Tutorial.HTML;
};
/** Tutorial source types.
@enum {string}
*/
exports.Tutorial.TYPES = {
HTML: "html",
MD: "markdown"
};
/** Moves children from current parent to different one.
@param {Tutorial} parent
*/
exports.Tutorial.prototype.setParent = function(parent) {
// removes node from old parent
if (this.parent) {
this.parent.removeChild(this);
}
this.parent = parent;
this.parent.addChild(this);
};
/** Removes children from current node.
@param {Tutorial} child
*/
exports.Tutorial.prototype.removeChild = function(child) {
var index = this.children.indexOf(child);
if (index != -1) {
this.children.splice(index, 1);
}
};
/** Adds new children to current node.
@param {Tutorial} child
*/
exports.Tutorial.prototype.addChild = function(child) {
this.children.push(child);
};

View File

@ -0,0 +1,37 @@
/**
@overview
@author Rafał Wrzeszcz <rafal.wrzeszcz@wrzasq.pl>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
*/
/**
@module jsdoc/tutorial/resolver
*/
var tutorial = require('jsdoc/tutorial');
var tutorials = {},
length = 0;
/** Adds new tutorial.
@param {tutorial.Tutorial} tutorial - New tutorial.
*/
exports.addTutorial = function(tutorial) {
tutorials[tutorial.name] = tutorial;
++length;
// default temporary parent
tutorial.setParent(exports.root);
};
/** Root tutorial.
@type tutorial.Tutorial
*/
exports.root = new tutorial.Tutorial('', '');
/** Resolves hierarchical structure.
@param {object} map - Contents map.
*/
exports.resolve = function(map) {
//TODO
};