From b18efb507d3be4f1a41e464b6b9559d629ca6673 Mon Sep 17 00:00:00 2001 From: switer Date: Sun, 6 Oct 2013 13:26:11 +0800 Subject: [PATCH] update md --- README.html | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++--- README.md | 6 ++--- comment.js | 42 --------------------------------- 3 files changed, 67 insertions(+), 48 deletions(-) delete mode 100644 comment.js diff --git a/README.html b/README.html index c216623..52a2d56 100644 --- a/README.html +++ b/README.html @@ -1,3 +1,4 @@ + README

comments

-

comments is a javascript comments library for generating comment string rapidly.

-
var comment = var comment = require('../comment');
+README

ciment

+

ciment is a javascript comments library for generating comment string rapidly.

+
var comment = var comment = require('../ciment');
+
+// Comment module methods
+comment.single('hello world'); // result: "// hello world"
+comment.block('hello world'); // result: "/* hello world */"
+
+// Prototype module methods
+'hello world'.single(); // result: "// hello world"
+'hello world'.block(); // result: "/* hello world */"
+
+
+ +

Install

+

For node with npm:

+
npm install comment
+
+ +

And use with var comment = require("comment")

+

API

+

Module function

+
comment.single("comment text");
+//  comment text
+
+ +

Return a single line comment string

+
comment.block("comment text");
+/*  comment text  */
+
+ +

Return a normal block comment string

+
comment.title("comment text");
+/*****  comment text  *****/
+
+ +

Return a block comment string like comment title

+
comment.banner("comment text\nhello world");
+/**
+*    comment text
+*    hello world
+**/
+
+ +

Return a banner block comment string

+

Prototype function

+
"comment text".single();
+//  comment text
+
+"comment text".block();
+/*  comment text  */
+
+
+"comment text".title();
+/*****  comment text  *****/
+
+
+"comment text".banner();
+/**
+*    comment text
+*    hello world
+**/
+
 
\ No newline at end of file diff --git a/README.md b/README.md index c58369f..7c9b007 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -comments +ciment ======== -`comments` is a javascript comments library for generating comment string rapidly. +`ciment` is a javascript comments library for generating comment string rapidly. ```javascript -var comment = var comment = require('../comment'); +var comment = var comment = require('../ciment'); // Comment module methods comment.single('hello world'); // result: "// hello world" diff --git a/comment.js b/comment.js deleted file mode 100644 index 6600b73..0000000 --- a/comment.js +++ /dev/null @@ -1,42 +0,0 @@ -var comments = { - 'single': '// @', - 'block': '/* @ */', - 'block_title': '/***** @ *****/', - 'block_banner': '/*\n@\n*/' - }, - config = { - indent: ' ', - startIndent: '* ' - } - -function wrapComment (content, commentType) { - return comments[commentType].replace('@', content); -} - -/*module export method*/ -exports.single = function (content) { - return wrapComment(content, 'single'); -} -exports.block = function (content) { - return wrapComment(content, 'block'); -} -exports.title = function (content) { - return wrapComment(content, 'block_title'); -} -exports.banner = function (content) { - return wrapComment( config.startIndent + content.split('\n').join(config.startIndent), 'block_banner'); -} - -/*prototype method*/ -String.prototype.single = function () { - return wrapComment(this, 'single'); -} -String.prototype.block = function () { - return wrapComment(this, 'block'); -} -String.prototype.title = function () { - return wrapComment(this, 'block_title'); -} -String.prototype.banner = function () { - return wrapComment( config.startIndent + this.split('\n').join(config.startIndent), 'block_banner'); -} \ No newline at end of file