# Already done by Ruby Language Engine 
# and generate a global variable $Transcript
#
# require 'gnustep'
# Rainbow.import("STTranscript")

Rainbow.import("ScriptManager")

scriptManager = ScriptManager.sharedScriptManager
view = scriptManager.currentCodeEditorView

if (view == nil)
  $Transcript.showLine("No document")
else
  document = view.documentName.lastPathComponent
  filename = "/tmp/"+document.to_s
  $Transcript.showLine("Save to "+filename)
  file = File.new(filename, "w")
  file.puts(view.string.to_s)
  file.close
  system("autogsdoc", "-DocumentationDirectory", "/tmp", filename)
  filename = filename.split("\.")
  filename = filename[0]+".html"
  $Transcript.showLine("Open "+filename)
  # Open mozilla in thread
  Thread.new (filename) { |name|
    system("mozilla", name)
  }
end
