Skip to content

pirosikick/gulp-comment2md

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm version david Build Status

gulp-comment2md

gulp-commnet2md is a gulp plugin that generates markdown file from JavaScript comments.

Install

$ npm install gulp-comment2md --save-dev

Example

gulp-comment2md generates markdown file from block comments which start with /**md or /*markdown:

// src/hello.js

/**md
 * # THIS FILE IS IMPORTANT!!!
 *
 * - one
 * - two
 * - three
 *
 */
function hello() {
  console.log('hello world');
}
// gulpfile.js

var gulp = require('gulp');
var comment2md = require('gulp-comment2md');

gulp.task('markdown', function () {
  gulp.src('./src/**/*.js')
    .pipe(comment2md())
    .pipe(gulp.dest('./doc')); // This task will generate `doc/hello.md`
});

Rename output file

If you want to rename output markdown files, you can pass String or Function as comment2md argument:

// String
gulp.task('markdown', function () {
  gulp.src('./src/**/*.js')
    .pipe(comment2md("new-name.md"))
    .pipe(gulp.dest('./doc')); // This task will generate `doc/new-name.md`
});

// Function
function rename (file) {
  return 'new-name.md';
}

gulp.task('markdown', function () {
  gulp.src('./src/**/*.js')
    .pipe(comment2md(rename))
    .pipe(gulp.dest('./doc')); // This task will generate `doc/new-name.md`
});

License

MIT

About

Generates markdown files from JavaScript comments

Resources

License

Stars

Watchers

Forks

Packages

No packages published