Skip to content

Commit

Permalink
Merge pull request #52 from pzuraq/bugfix/add-support-for-decorators
Browse files Browse the repository at this point in the history
[BUGFIX] Adds support for decorators
  • Loading branch information
cibernox authored Oct 31, 2019
2 parents 5d9fe8a + 5eee979 commit 02a2413
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion lib/broccoli-yuidoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,35 @@
var rsvp = require('rsvp');
var path = require('path');
var CachingWriter = require('broccoli-caching-writer');
var Y = require('yuidocjs');

var originalHandleComment = Y.DocParser.prototype.handlecomment;

var AT_PLACEHOLDER = '---AT-PLACEHOLDER---';
var AT_PLACEHOLDER_REGEX = new RegExp(AT_PLACEHOLDER, 'g');

Y.DocParser.prototype.handlecomment = function(comment, file, line) {
var lines = comment.split(/\r\n|\n/);

var inMarkdownBlock = false;

var newLines = lines.map((line) => {
if (line.match(/^(\s*\*)?\s*```/)) {
inMarkdownBlock = !inMarkdownBlock;
}

return inMarkdownBlock ? line.replace(/@/g, AT_PLACEHOLDER) : line;
});

var ret = originalHandleComment.call(this, newLines.join('\n'), file, line);
var description = ret.find(t => t.tag === 'description');

if (description) {
description.value = description.value.replace(AT_PLACEHOLDER_REGEX, '@');
}

return ret;
}

BroccoliYuidoc.prototype = Object.create(CachingWriter.prototype);
BroccoliYuidoc.prototype.constructor = BroccoliYuidoc;
Expand All @@ -15,7 +44,6 @@ function BroccoliYuidoc(inputNodes, options) {
};

BroccoliYuidoc.prototype.build = function() {
var Y = require('yuidocjs');
var options = this.options;
options.outdir = path.resolve(this.outputPath, options.outdir);

Expand Down

0 comments on commit 02a2413

Please sign in to comment.