Вход Регистрация
Файл: framework/thirdparty/jasmine/jsdoc-template/publish.js
Строк: 206
<?php
/** Called automatically by JsDoc Toolkit. */
function publish(symbolSet) {
    
publish.conf = {  // trailing slash expected for dirs
        
ext:         ".html",
        
outDir:      JSDOC.opt.|| SYS.pwd+"../out/jsdoc/",
        
templatesDirJSDOC.opt.|| SYS.pwd+"../templates/jsdoc/",
        
symbolsDir:  "symbols/",
        
srcDir:      "symbols/src/"
    
};
    
    
// is source output is suppressed, just display the links to the source file
    
if (JSDOC.opt.&& defined(Link) && Link.prototype._makeSrcLink) {
        
Link.prototype._makeSrcLink = function(srcFilePath) {
            return 
"&lt;"+srcFilePath+"&gt;";
        }
    }
    
    
// create the folders and subfolders to hold the output
    
IO.mkPath((publish.conf.outDir+"symbols/src").split("/"));
        
    
// used to allow Link to check the details of things being linked to
    
Link.symbolSet symbolSet;

    
// create the required templates
    
try {
        var 
classTemplate = new JSDOC.JsPlate(publish.conf.templatesDir+"class.tmpl");
        var 
classesTemplate = new JSDOC.JsPlate(publish.conf.templatesDir+"allclasses.tmpl");
    }
    catch(
e) {
        print(
"Couldn't create the required templates: "+e);
        
quit();
    }
    
    
// some ustility filters
    
function hasNoParent($) {return ($.memberOf == "")}
    function 
isaFile($) {return ($.is("FILE"))}
    function 
isaClass($) {return ($.is("CONSTRUCTOR") || $.isNamespace)}
    
    
// get an array version of the symbolset, useful for filtering
    
var symbols symbolSet.toArray();
    
    
// create the hilited source code files
    
var files JSDOC.opt.srcFiles;
     for (var 
0files.lengthli++) {
         var 
file files[i];
         var 
srcDir publish.conf.outDir "symbols/src/";
        
makeSrcFile(filesrcDir);
     }
     
     
// get a list of all the classes in the symbolset
     
var classes symbols.filter(isaClass).sort(makeSortby("alias"));
    
    
// create a class index, displayed in the left-hand column of every class page
    
Link.base "../";
     
publish.classesIndex classesTemplate.process(classes); // kept in memory
    
    // create each of the class pages
    
for (var 0classes.lengthli++) {
        var 
symbol classes[i];
        
        
symbol.events symbol.getEvents();   // 1 order matters
        
symbol.methods symbol.getMethods(); // 2
        
        
var output "";
        
output classTemplate.process(symbol);
        
        
IO.saveFile(publish.conf.outDir+"symbols/"symbol.alias+publish.conf.extoutput);
    }
    
    
// regenerate the index with different relative links, used in the index pages
    
Link.base "";
    
publish.classesIndex classesTemplate.process(classes);
    
    
// create the class index page
    
try {
        var 
classesindexTemplate = new JSDOC.JsPlate(publish.conf.templatesDir+"index.tmpl");
    }
    catch(
e) { print(e.message); quit(); }
    
    var 
classesIndex classesindexTemplate.process(classes);
    
IO.saveFile(publish.conf.outDir"index"+publish.conf.extclassesIndex);
    
classesindexTemplate classesIndex classes null;
    
    
// create the file index page
    
try {
        var 
fileindexTemplate = new JSDOC.JsPlate(publish.conf.templatesDir+"allfiles.tmpl");
    }
    catch(
e) { print(e.message); quit(); }
    
    var 
documentedFiles symbols.filter(isaFile); // files that have file-level docs
    
var allFiles = []; // not all files have file-level docs, but we need to list every one
    
    
for (var 0files.lengthi++) {
        
allFiles.push(new JSDOC.Symbol(files[i], [], "FILE", new JSDOC.DocComment("/** */")));
    }
    
    for (var 
0documentedFiles.lengthi++) {
        var 
offset files.indexOf(documentedFiles[i].alias);
        
allFiles[offset] = documentedFiles[i];
    }
        
    
allFiles allFiles.sort(makeSortby("name"));

    
// output the file index page
    
var filesIndex fileindexTemplate.process(allFiles);
    
IO.saveFile(publish.conf.outDir"files"+publish.conf.extfilesIndex);
    
fileindexTemplate filesIndex files null;
}


/** Just the first sentence (up to a full stop). Should not break on dotted variable names. */
function summarize(desc) {
    if (
typeof desc != "undefined")
        return 
desc.match(/([wW]+?.)[^a-z0-9_$]/i)? RegExp.$desc;
}

/** Make a symbol sorter by some attribute. */
function makeSortby(attribute) {
    return function(
ab) {
        if (
a[attribute] != undefined && b[attribute] != undefined) {
            
a[attribute].toLowerCase();
            
b[attribute].toLowerCase();
            if (
b) return -1;
            if (
b) return 1;
            return 
0;
        }
    }
}

/** Pull in the contents of an external file at the given path. */
function include(path) {
    var 
path publish.conf.templatesDir+path;
    return 
IO.readFile(path);
}

/** Turn a raw source file into a code-hilited page in the docs. */
function makeSrcFile(pathsrcDirname) {
    if (
JSDOC.opt.s) return;
    
    if (!
name) {
        
name path.replace(/..?[\/]/g"").replace(/[\/]/g"_");
        
name name.replace(/:/g"_");
    }
    
    var 
src = {pathpathname:namecharsetIO.encodinghilited""};
    
    if (
defined(JSDOC.PluginManager)) {
        
JSDOC.PluginManager.run("onPublishSrc"src);
    }

    if (
src.hilited) {
        
IO.saveFile(srcDirname+publish.conf.extsrc.hilited);
    }
}

/** Build output for displaying function parameters. */
function makeSignature(params) {
    if (!
params) return "()";
    var 
signature "("
    
+
    
params.filter(
        function($) {
            return $.
name.indexOf(".") == -1// don't show config params in signature
        
}
    ).
map(
        function($) {
            return $.
name;
        }
    ).
join(", ")
    +
    
")";
    return 
signature;
}

/** Find symbol {@link ...} strings in text and turn into html links */
function resolveLinks(strfrom) {
    
str str.replace(/{@link ([^} ]+) ?}/gi,
        function(
matchsymbolName) {
            return new 
Link().toSymbol(symbolName);
        }
    );
    
    return 
str;
}
?>
Онлайн: 0
Реклама