<commit_before>/*
Copyright (c) 2011, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://yuilibrary.com/license/
*/
var MD = require("node-markdown").Markdown,
    fs = require('graceful-fs'),
    noop = function() {},
    path = require('path'),
    DEFAULT_RETURN_TAGS = 'code|em|strong|span|a|pre|dl|dd|dt|ul|li|ol',
    TEMPLATE;

/**
* Takes the `JSON` data from the `DocParser` class, creates and parses markdown and handlebars
based templates to generate static HTML content
* @class DocBuilder
* @module yuidoc
*/

YUI.add('doc-builder', function(Y) {

    var fixType = Y.Lang.fixType,
    print = function(items) {
        var out = '<ul>';

        Y.each(items, function(i, k) {
            out += '<li>';
            if (Y.Lang.isObject(i)) {
                if (!i.path) {
                    out += k + '/' + print(i);
                } else {
                    out += '<a href="../files/' + i.name + '.html">' + k + '</a>';
                }
            }
            out += '</li>';
        });

        out += '</ul>';
        return out;
    };

    Y.Handlebars.registerHelper('buildFileTree', function(items, fn) {
        return print(items);
    });

    var DEFAULT_THEME = themeDir = path.join(__dirname, '../', 'themes', 'default');

    Y.DocBuilder = function(options, data) {
        this.options = options;
        if (options.helpers) {
            this._addHelpers(options.helpers);
        }
        if (options.themedir) {
            themeDir = options.themedir;
        }
        this.data = data;
        Y.log('Building..', 'info', 'builder');
        this.files = 0;
        var self = this;

        Y.Handlebars.registerHelper('crossLink', function(item, fn) {
            var str = '';
            if (!item) {
                item = '';
            }
            //console.log('CrossLink:', item);
            if (item.indexOf('|') > 0) {
                var parts = item.split('|'),
                p = [];
                Y.each(parts, function(i) {
                    p.push(self._parseCrossLink.call(self, i));
                });
                str = p.join(' | ');
            } else {
                str = self._parseCrossLink.call(self, item);
            }
            return str;
        });

        Y.Handlebars.registerHelper('crossLinkModule', function(item, fn) {
            var str = item;
            if (self.data.modules[item]) {
                str = '<a href="../modules/' + item + '.html">' + item + '</a>';
            }
            return str;
        });

        Y.Handlebars.registerHelper('crossLinkRaw', function(item, fn) {
            var str = '';
            if (!item) {
                item = '';
            }
            if (item.indexOf('|') > 0) {
                var parts = item.split('|'),
                p = [];
                Y.each(parts, function(i) {
                    p.push(self._parseCrossLink.call(self, i, true));
                });
                str = p.join(' | ');
            } else {
                str = self._parseCrossLink.call(self, item, true);
            }
            return str;
        });

        this.cacheTemplates = true;
        if (options.cacheTemplates === false) {
            this.cacheTemplates = false;
        }

    };

    Y.DocBuilder.prototype = {
        /**<commit_msg>Fix links for modules nested in sub-directories.<commit_after>/*
Copyright (c) 2011, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://yuilibrary.com/license/
*/
var MD = require("node-markdown").Markdown,
    fs = require('graceful-fs'),
    noop = function() {},
    path = require('path'),
    DEFAULT_RETURN_TAGS = 'code|em|strong|span|a|pre|dl|dd|dt|ul|li|ol',
    TEMPLATE;

/**
* Takes the `JSON` data from the `DocParser` class, creates and parses markdown and handlebars
based templates to generate static HTML content
* @class DocBuilder
* @module yuidoc
*/

YUI.add('doc-builder', function(Y) {

    var fixType = Y.Lang.fixType,
    print = function(items) {
        var out = '<ul>';

        Y.each(items, function(i, k) {
            out += '<li>';
            if (Y.Lang.isObject(i)) {
                if (!i.path) {
                    out += k + '/' + print(i);
                } else {
                    out += '<a href="../files/' + i.name + '.html">' + k + '</a>';
                }
            }
            out += '</li>';
        });

        out += '</ul>';
        return out;
    };

    Y.Handlebars.registerHelper('buildFileTree', function(items, fn) {
        return print(items);
    });

    var DEFAULT_THEME = themeDir = path.join(__dirname, '../', 'themes', 'default');

    Y.DocBuilder = function(options, data) {
        this.options = options;
        if (options.helpers) {
            this._addHelpers(options.helpers);
        }
        if (options.themedir) {
            themeDir = options.themedir;
        }
        this.data = data;
        Y.log('Building..', 'info', 'builder');
        this.files = 0;
        var self = this;

        Y.Handlebars.registerHelper('crossLink', function(item, fn) {
            var str = '';
            if (!item) {
                item = '';
            }
            //console.log('CrossLink:', item);
            if (item.indexOf('|') > 0) {
                var parts = item.split('|'),
                p = [];
                Y.each(parts, function(i) {
                    p.push(self._parseCrossLink.call(self, i));
                });
                str = p.join(' | ');
            } else {
                str = self._parseCrossLink.call(self, item);
            }
            return str;
        });

        Y.Handlebars.registerHelper('crossLinkModule', function(item, fn) {
            var str = item;
            if (self.data.modules[item]) {
                str = '<a href="../modules/' + item.replace('/', '_') +
                      '.html">' + item + '</a>';
            }
            return str;
        });

        Y.Handlebars.registerHelper('crossLinkRaw', function(item, fn) {
            var str = '';
            if (!item) {
                item = '';
            }
            if (item.indexOf('|') > 0) {
                var parts = item.split('|'),
                p = [];
                Y.each(parts, function(i) {
                    p.push(self._parseCrossLink.call(self, i, true));
                });
                str = p.join(' | ');
            } else {
                str = self._parseCrossLink.call(self, item, true);
            }
            return str;
        });

        this.cacheTemplates = true;
        if (options.cacheTemplates === false) {
            this.cacheTemplates = false;
        }

    };

    Y.DocBuilder.prototype = {
        /**
{'fraction_non_alphanumeric': 0.15770768547312305, 'fraction_numerical': 0.002073152672886125, 'mean_word_length': 1.4488759970993474, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3460636', 'n_tokens_mistral': 2009, 'n_tokens_neox': 1917, 'n_words': 416}