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.forEach(function(f){
                  f.currentFile = file.targetFile;
                  options.structure.push(buildStructureForFile(f));
                });
              } 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 = [],
                  ignore  = options.ignore || [],
                  files   = [];
            
              // If more paths are given with the --source flag
              if(source.split(',').length > 1){
                var dirtyPaths = source.split(',');
            
                dirtyPaths.forEach(function(dirtyPath){
                  dirtyFiles = dirtyFiles.concat(require('walkdir').sync(path.resolve(process.cwd(), dirtyPath),{follow_symlinks:true}));
                });
              }
              // Just one path given with the --source flag
              else {
                source  = path.resolve(process.cwd(), source);
                dirtyFiles = require('walkdir').sync(source,{follow_symlinks:true}); // tee hee!
              }
              
              dirtyFiles.forEach(function(file){
                file = path.relative(process.cwd(), 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) {
                  var source_to_return;
                  files = files.map(function(file) {
                
                    try {
                      // If more paths are given with the --source flag
                      if(source.split(',').length >= 1){
                        var tmpSource = source.split(',');
                
                        tmpSource.forEach(function(s){
                          if(file.indexOf(s) !== -1){
                            source_to_return = s;
                          }
                          
                        });
                      } else {
                        source_to_return = source;
                      }
                      
                      var content = fs.readFileSync(file).toString();
                      
                      return {
                        sourceFile: file,
                        targetFile: path.relative(process.cwd(),target) + path.sep + file + '.html',
                        dox:        dox.parseComments(content, options)
                      };
                
                    } catch(e) { console.log(e); }
                  });
                
                  return files;
                };