r88915 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88914‎ | r88915 | r88916 >
Date:19:03, 26 May 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Added documentation to wiki.AnnotationRenderer
Modified paths:
  • /trunk/parsers/wikidom/lib/wiki.AnnotationRenderer.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/wiki.AnnotationRenderer.js
@@ -10,6 +10,21 @@
1111
1212 /* Methods */
1313
 14+ /**
 15+ * Adds a set of insertions around a range of text.
 16+ *
 17+ * Insertions for the same range will be nested in order of declaration.
 18+ * @example
 19+ * ar = new wiki.AnnotationRenderer();
 20+ * ar.wrapWithText( { 'offset': 1, 'length': 1 }, '[', ']' );
 21+ * ar.wrapWithText( { 'offset': 1, 'length': 1 }, '{', '}' );
 22+ * // Outputs: "a[{b}]c"
 23+ * console.log( ar.apply( 'abc' ) );
 24+ *
 25+ * @param range Object: Range to insert text around
 26+ * @param pre String: Text to insert before range
 27+ * @param post String: Text to insert after range
 28+ */
1429 this.wrapWithText = function( range, pre, post ) {
1530 var start = range.offset;
1631 if ( !( start in insertions ) ) {
@@ -25,12 +40,27 @@
2641 }
2742 };
2843
 44+ /**
 45+ * Adds a set of opening and closing XML tags around a range of text.
 46+ *
 47+ * This is a convenience function, and has the same nesting behavior as wrapWithText.
 48+ *
 49+ * @param range Object: Range to insert XML tags around
 50+ * @param tag String: XML tag name
 51+ * @param attributes Object: XML tag attributes (optional)
 52+ */
2953 this.wrapWithXml = function( range, tag, attributes ) {
3054 that.wrapWithText(
3155 range, wiki.util.xml.open( tag, attributes ), wiki.util.xml.close( tag )
3256 );
3357 };
3458
 59+ /**
 60+ * Applies insertions to text.
 61+ *
 62+ * @param text String: Text to apply insertions to
 63+ * @return String: Wrapped text
 64+ */
3565 this.apply = function( text ) {
3666 var out = '';
3767 for ( var i = 0, iMax = text.length; i <= iMax; i++ ) {

Status & tagging log