Commit e381b103 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Make print page use new export format.

Remove code for using phantomjs entirely.
parent 2614dbca
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ task :sdk do
  load_sdk_vars
  run_jsduck([
    "--extjs-path", "extjs/ext-all-debug.js",
    "--seo",
    # to create symbolic links to template files instead of copying them over.
    # Useful for development.  Turn off for deployment.
    "--template-links",
+1 −7
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ module JsDuck
    # Writes JSON export or JsonP file for each class
    def write_classes
      exporter = Exporter.new(@relations, get_doc_formatter)
      renderer = Renderer.new(@opts)
      renderer = Renderer.new
      @parallel.each(@relations.classes) do |cls|
        filename = @opts.output_dir+"/output/" + cls[:name] + (@opts.export ? ".json" : ".js")
        Logger.instance.log("Writing to #{filename} ...")
@@ -172,12 +172,6 @@ module JsDuck
          JsonDuck.write_jsonp(filename, cls[:name].gsub(/\./, "_"), data)
        end
      end
      # Print export: needs to be done non-parallel
      if @opts.seo
        @relations.classes.each do |cls|
          renderer.write(exporter.export(cls))
        end
      end
    end

    # Writes formatted HTML source code for each input file
+0 −18
Original line number Diff line number Diff line
@@ -5,24 +5,6 @@ module JsDuck
  # Ruby-side implementation of class docs Renderer.
  # Uses PhantomJS to run Docs.Renderer JavaScript.
  class Renderer
    def initialize(opts)
      @opts = opts
      @basedir = @opts.output_dir + "/output-print"
      @tmp_filename = @basedir + "/data.js"
    end

    def write(classData)
      FileUtils.mkdir(@basedir) unless File.exists?(@basedir)
      # Write JSON to a file
      JsonDuck.write_assignment(@tmp_filename, "window.jsonData", classData)
      # Read it in with phantomJS and feed to Docs.Renderer
      html = IO.read("|phantomjs #{@opts.output_dir}/renderer.js #{@opts.output_dir}/print.html")
      # Write resulting HTML
      File.open("#{@basedir}/#{classData[:name]}.html", "w") {|f| f.write(html) }
      # clean up temporary file
      FileUtils.rm(@tmp_filename)
    end

    def render(cls)
        @cls = cls

+2 −2
Original line number Diff line number Diff line
@@ -31,8 +31,8 @@ if (isset($_GET["_escaped_fragment_"]) || isset($_GET["print"])) {
  try {
    if (preg_match('/^\/api\/([^-]+)/', $fragment, $m)) {
      $className = $m[1];
      $html = file_get_contents("output-print/".$className.".html");
      print_page($className, "<h1>" . $className . "</h1>\n" . $html, $fragment);
      $json = decode_file("output/".$className.".js");
      print_page($className, "<h1>" . $className . "</h1>\n" . $json["html"], $fragment);
    }
    elseif (preg_match('/^\/api\/?$/', $fragment, $m)) {
      print_index_page();
+4 −0
Original line number Diff line number Diff line
@@ -9,6 +9,10 @@
<link rel="stylesheet" href="resources/css/docs-ext.css" type="text/css" />
<link rel="stylesheet" href="resources/css/viewport.css" type="text/css" />
<!-- END CSS -->
<style type="text/css">
.description .short { display: none !important }
.description .long { display: block !important }
</style>
<title>{title} | Ext JS 4.0 API Docs | Sencha</title>
</head>
<body style="background: #fff;">
Loading