dox-foundation

property

name

exports.name

    Parser name

    exports.name = pkg.name;
    property

    version

    exports.version

      Parser version

      exports.version = pkg.version;
      declaration

      templatePath

      templatePath

        Template used to produce the documentation

        var templatePath = exports.templatePath = '../views/template.jade';
        method

        render

        exports.render()

          Parse source code to produce documentation

          exports.render = function(file, files, options){
              options          = options || { title: 'Documentation' };
              file.dox         = file.dox.filter(exports.shouldPass);
              options.comments = file.dox;
              templatePath     = path.resolve(__dirname, templatePath);
              template         = fs.readFileSync(templatePath).toString();
          
              if (files) {
                options.structure = files.map(buildStructureForFile);
              } else {
                options.structure = new Array(buildStructureForFile(file));
              }
              
              return jade.compile(template, { filename:templatePath })(options);
          };
          method

          collectFiles

          exports.collectFiles()

            Create an array of all the right files in the source dir

            exports.collectFiles = function(source, options, callback) {
              var dirtyFiles = require('walkdir').sync(source,{follow_symlinks:true}), // tee hee!
                  ignore  = options.ignore || [],
                  files   = [];
            
              dirtyFiles.forEach(function(file){
                file = path.relative(source, file);
            
                var doNotIgnore = _.all(ignore, function(d){
                  // return true if no part of the path is in the ignore list
                  return (file.indexOf(d) === -1);
                });
            
                if ((file.substr(-2) === 'js') && doNotIgnore) {
                  files.push(file);
                }
              });
            
              return files;
            };
            method

            createTargetFolders

            exports.createTargetFolders()

              Make sure the folder structure in target mirrors source

              exports.createTargetFolders = function(target, files) {
                var folders = [];
                // Ensure that the target folder exists
                mkdirp.sync(target);
                
                files.forEach(function(file){
                  var folder = file.substr(0, file.lastIndexOf('/'));
              
                  if ((folder !== '') && (folders.indexOf(folder) === -1)) {
                    folders.push(folder);
                    mkdirp.sync(path.join(target, folder));
                  }
                });
              };
              method

              doxFiles

              exports.doxFiles()

                Dox all the files found by collectFiles

                exports.doxFiles = function(source, target, options, files) {
                  files = files.map(function(file) {
                    try {
                      var content = fs.readFileSync(source + '/' + file).toString();
                      return {
                        sourceFile: file,
                        targetFile: file.replace(source, target) + '.html',
                        dox:        dox.parseComments(content, options)
                      };
                    } catch(e) { console.log(e); }
                  });
                
                  return files;
                };