Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

One .md-file per .js-file #24

Closed
phun-ky opened this issue Mar 18, 2015 · 5 comments
Closed

One .md-file per .js-file #24

phun-ky opened this issue Mar 18, 2015 · 5 comments

Comments

@phun-ky
Copy link

phun-ky commented Mar 18, 2015

I see this code here:

var jsdoc2md = require("jsdoc-to-markdown");
var gutil = require("gulp-util");
var fs = require("fs");

gulp.task("docs", function(done){
    var src = "lib/**/*.js";
    var dest = "api.md";
    var options = {};

    gutil.log("writing documentation to " + dest);
    jsdoc2md.render(src, options)
        .on("error", function(err){
            gutil.log(gutil.colors.red("jsdoc2md failed"), err.message);
        })
        .pipe(fs.createWriteStream(dest));
});

And I am trying to make the given code produce one .md-file per .js-file.. and so far no luck.. basically, I want this behaviour:

gulp.task("docs", function(){

  var src   = 'docstarget/**/*.js';

  return  gulp.src(src)
            .pipe(jsdoc2md.render())
            .on("error", function(err){
              gutil.log(gutil.colors.red("jsdoc2md failed"), err.message);
            })
            .pipe(rename(function(path){
              path.extname = '.md'
            }))
            .pipe(gulp.dest('doxify'));

});

But that code gives me:

jsdoc2md failed Invalid non-string/buffer chunk

How can I achieve what I want? I am using @module-tag, so I cant use the gulp plugin..

I am using this version: "jsdoc-to-markdown": "^0.5.11",, getting same result in "jsdoc-to-markdown": "^0.6.4",

@phun-ky
Copy link
Author

phun-ky commented Mar 18, 2015

Found a way now, but it's nasty:

gulp.task("docs", function(){

  var src   = 'docstarget/**/*.js';

  return  gulp.src(src)
            .pipe(tap(function(file){
              fs.createReadStream(file.path)
              .pipe(jsdoc2md.render())
              .pipe(fs.createWriteStream(file.path.replace(/.js/g,'.md')));
            }))
            .on("error", function(err){
              gutil.log(gutil.colors.red("jsdoc2md failed"), err.message);
            });


});

@75lb
Copy link
Member

75lb commented Mar 18, 2015

hi, will look into this when i get a moment but i notice you're missing a return statement..

in the example here notice it is return jsdoc2md.render(src, options) - your code above lacks the return.. does adding it help in your case?

@phun-ky
Copy link
Author

phun-ky commented Mar 18, 2015

No, that does not help :/

@75lb
Copy link
Member

75lb commented Apr 12, 2015

hi! You should no longer need this hack, or the custom gulp task.. the latest plug-in version should just work, meaning you can use this method to get "one markdown out per js in".. make sure you adhere to the caveat mentioned on the plugin docs.. let me know how it goes..

@75lb
Copy link
Member

75lb commented Apr 20, 2015

inactive, assuming resolved..

@75lb 75lb closed this as completed Apr 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants