JSDOC/BuildDocs.js
[gnome.introspection-doc-generator] / JSDOC / BuildDocs.js
index 0dd7139..fac451d 100644 (file)
@@ -10,7 +10,7 @@ File = imports.File.File;
 
 Template = imports.JsTemplate.Template.Template;
 
-Options = imports.Options.Options;
+
 Parser   = imports.Parser.Parser;
 
 TokenReader = imports.TokenReader.TokenReader;
@@ -21,7 +21,7 @@ Symbol = imports.Symbol.Symbol;
 // should not realy be here -- or anywhere...??
 
 
-
+Options = false; // refer to this everywhere!
 
 
 BuildDocs = {
@@ -31,20 +31,16 @@ BuildDocs = {
     
     srcFiles : [],
     
+    
     build : function (opts)
     {
-        
-        XObject.extend(Options, opts);
-         
+        Options = opts; 
         Options.init();
         
-    
-         
-        
         Options.LOG.inform("JsDoc Toolkit main() running at "+new Date()+".");
-        Options.LOG.inform("With options: ");
+        //Options.LOG.inform("With options: ");
         
-        if (!File.isDirectory(Options.cacheDirectory)) {   
+        if (Options.cacheDirectory.length && !File.isDirectory(Options.cacheDirectory)) {   
             File.mkdir(Options.cacheDirectory)
         }
         
@@ -151,7 +147,7 @@ BuildDocs = {
         
         
         Parser.finish();
-    }
+    },
     
      
         
@@ -179,7 +175,7 @@ BuildDocs = {
         
         // used to check the details of things being linked to
         Link.symbolSet = symbolSet;
-
+        Link.base = "../";
         
         var classTemplate = new Template({
              templateFile : Options.templatesDir  + "/class.tmpl",
@@ -218,15 +214,13 @@ BuildDocs = {
         
         for (var i = 0, l = files.length; i < l; i++) {
             var file = files[i];
-            var srcDir = Options.target + "/symbols/src/";
-            this.makeSrcFile(file, srcDir);
+            var targetDir = Options.target + "/symbols/src/";
+            this.makeSrcFile(file, targetDir);
         }
         
         var classes = symbols.filter(isaClass).sort(makeSortby("alias"));
-        
-        Link.base = "../";
-        
-        publish.classesIndex = classesTemplate.process(classes); // kept in memory
+         
+       var classesIndex = classesTemplate.process(classes); // kept in memory
         
         
         
@@ -249,7 +243,7 @@ BuildDocs = {
         
         // regenrate the index with different relative links
         Link.base = "";
-        publish.classesIndex = classesTemplate.process(classes);
+        var classesIndex = classesTemplate.process(classes);
         
           
         
@@ -261,11 +255,14 @@ BuildDocs = {
         
  
         
-        var documentedFiles = symbols.filter(isaFile);
+        var documentedFiles = symbols.filter(function ($) {
+            return ($.is("FILE"))
+        });
+        
         var allFiles = [];
         
         for (var i = 0; i < files.length; i++) {
-            allFiles.push(new JSDOC.Symbol(files[i], [], "FILE", new JSDOC.DocComment("/** */")));
+            allFiles.push(new  Symbol(files[i], [], "FILE", new JSDOC.DocComment("/** */")));
         }
         
         for (var i = 0; i < documentedFiles.length; i++) {
@@ -274,13 +271,13 @@ BuildDocs = {
         }
             
         allFiles = allFiles.sort(makeSortby("name"));
+        File.write(Options.target , "/files."+Options.publishExt, 
+            fileindexTemplate.process(allFiles)
+        );
+        
+    },
 
-        var filesIndex = fileindexTemplate.process(allFiles);
-        IO.saveFile(publish.conf.outDir, "files"+publish.conf.ext, filesIndex);
-        fileindexTemplate = filesIndex = files = null;
-    }
-
-    publishJSON = function(file, data)
+    publishJSON : function(file, data)
     {
         // what we need to output to be usefull...
         // a) props..
@@ -340,27 +337,23 @@ BuildDocs = {
         
         
     },
-    makeSrcFile: function(path, srcDir, name) {
-        if (Options.outputSource) return;
+    makeSrcFile: function(sourceFile) 
+    {
         
-        return; // not done?
         
-        if (!name) {
-            name = path.replace(/\.\.?[\\\/]/g, "").replace(/[\\\/]/g, "_");
-            name = name.replace(/\:/g, "_");
-        }
+        name = sourceFile.substring(Options.baseDir.length);
+        name = name.replace(/\.\.?[\\\/]/g, "").replace(/[\\\/]/g, "_");
+        name = name.replace(/\:/g, "_"); //??
         
-        var src = {
-                path: path, 
-                name:name, 
-                charset: IO.encoding, 
-                hilited: ""
-        };
         
-         
-        if (src.hilited) {
-            IO.saveFile(srcDir, name+publish.conf.ext, src.hilited);
-        }
+        var pretty = imports.PrettyPrint.toPretty(File.read(sourceFile));
+        File.write(Options.target+"/symbols/src/" + name, 
+            '<html><head>' +
+            '<title>' + sourceFile + '</title>' +
+            '<link rel="stylesheet" type="text/css" href="../../../highlight-js.css"/>' + 
+            '</head><body class="highlightpage">' +
+            pretty +
+            '</body></html>');
     }