Make some updates to doc

This commit is contained in:
Garen Torikian 2012-02-07 16:22:22 -08:00
commit 554b845bb9
12 changed files with 219 additions and 157 deletions

View file

@ -46,16 +46,16 @@ var Anchor = require("./anchor").Anchor;
/**
* class Document
*
* Documentation about Document. Is this recursion? TODO
* Contains the text of the document. Documents are controlled by a single [[EditSession `EditSession`]]. At its core, `Document`s are just an array of strings, with each row in the document matching up to the array index.
*
*
**/
/**
* new Document(text)
* new Document([text])
* - text (String | Array): The starting text
*
* Creates a new `Document`. TODO
* Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty.
*
**/
var Document = function(text) {
@ -77,11 +77,11 @@ var Document = function(text) {
oop.implement(this, EventEmitter);
/**
/**
* Document.setValue(text) -> Void
* - text (String): The value to set
* - text (String): The text to use
*
*
* Replaces all the lines in the current `Document` with the value of `text`.
**/
this.setValue = function(text) {
var len = this.getLength();
@ -89,25 +89,27 @@ var Document = function(text) {
this.insert({row: 0, column:0}, text);
};
/**
/**
* Document.getValue() -> String
*
* Returns all the lines in the document, split by the new line character.
* Returns all the lines in the document as a single string, split by the new line character.
**/
this.getValue = function() {
return this.getAllLines().join(this.getNewLineCharacter());
};
/**
/**
* Document.createAnchor(row, column) -> Anchor
*
*
* - row (Number): The row number to use
* - column (Number): The column number to use
*
* Creates a new `Anchor` to define a floating point in the document.
**/
this.createAnchor = function(row, column) {
return new Anchor(this, row, column);
};
/**
/** internal
* Document.$split(text) -> Array
* - text (String): The text to work with
*
@ -130,7 +132,7 @@ var Document = function(text) {
};
/**
/** internal
* Document.$detectNewLine(text) -> Void
*
*
@ -147,7 +149,7 @@ var Document = function(text) {
/**
* Document.getNewLineCharacter() -> String
*
* Returns the new line character that's being used, depending on the value of `newLineMode`.
* Returns the newline character that's being used, depending on the value of `newLineMode`.
*
* #### Returns
*
@ -174,9 +176,9 @@ var Document = function(text) {
this.$newLineMode = "auto";
/**
* Document.setNewLineMode(newLineMode) -> Void
* - newLineMode(String): The newline mode to use; can be either `windows`, `unix`, or `auto`
* - newLineMode(String): [The newline mode to use; can be either `windows`, `unix`, or `auto`](~Document.setNewLineMode.param)
*
* Sets the new line mode.
* [Sets the new line mode.](~Document.setNewLineMode.desc)
**/
this.setNewLineMode = function(newLineMode) {
if (this.$newLineMode === newLineMode)
@ -188,7 +190,7 @@ var Document = function(text) {
/**
* Document.getNewLineMode() -> String
*
* Returns the type of newlines being used; either `windows`, `unix`, or `auto`
* [Returns the type of newlines being used; either `windows`, `unix`, or `auto`](~Document.getNewLineMode)
*
**/
this.getNewLineMode = function() {
@ -248,10 +250,10 @@ var Document = function(text) {
};
/**
* Document.getTextRange(range) -> Array
* - range (String): blah
* Document.getTextRange(range) -> String
* - range (Range): The range to work with
*
* TODO
* [Given a range within the document, this function returns all the text within that range as a single string.](~Document.getTextRange.desc)
**/
this.getTextRange = function(range) {
if (range.start.row == range.end.row) {
@ -267,11 +269,10 @@ var Document = function(text) {
}
};
/**
/** internal
* Document.$clipPosition(position) -> Number
* - position (Number): blah
*
* TODO
*
**/
this.$clipPosition = function(position) {
var length = this.getLength();
@ -529,9 +530,9 @@ var Document = function(text) {
/**
* Document.removeNewLine(row) -> Void
* - row (Number): The row to be removed
* - row (Number): The row to check
*
* TODO Removes the row from the document. This method also triggers the `'change'` event.
* Removes the new line between `row` and the row immediately following it. This method also triggers the `'change'` event.
*
**/
this.removeNewLine = function(row) {
@ -592,7 +593,7 @@ var Document = function(text) {
/**
* Document.applyDeltas(deltas) -> Void
*
* TODO
* Applies all the changes previously accumulated. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
**/
this.applyDeltas = function(deltas) {
for (var i=0; i<deltas.length; i++) {
@ -613,7 +614,7 @@ var Document = function(text) {
/**
* Document.revertDeltas(deltas) -> Void
*
* TODO
* Reverts any changes previously applied. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
**/
this.revertDeltas = function(deltas) {
for (var i=deltas.length-1; i>=0; i--) {