Loading lib/jsduck/aggregator.rb +15 −5 Original line number Diff line number Diff line Loading @@ -16,20 +16,30 @@ module JsDuck @merger = Merger.new end def parse(input, filename="") # Parses chunk of JavaScript. The resulting documentation is # accumulated inside this class and can be later accessed through # #result method. # # - input the JavaScript source # - filename name of the JS file where it came from # - html_filename name of the HTML file where the source was saved. # def parse(input, filename="", html_filename="") @current_class = nil Parser.new(input).parse.each do |docset| doc = @doc_parser.parse(docset[:comment]) code = docset[:code] href = filename + "#line-" + docset[:linenr].to_s register(add_href(@merger.merge(doc, code), href)) href = html_filename + "#line-" + docset[:linenr].to_s register(add_href(@merger.merge(doc, code), href, filename)) end end # Tags doc-object with link to source code where it came from def add_href(doc, href) # Tags doc-object with link to source code where it came from. # For class we also store the name of the JavaScript file. def add_href(doc, href, filename) doc[:href] = href if doc[:tagname] == :class doc[:filename] = filename doc[:cfg].each {|cfg| cfg[:href] = href } doc[:method].each {|method| method[:href] = href } end Loading lib/jsduck/app.rb +1 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ module JsDuck puts "Parsing #{fname} ..." if @verbose code = IO.read(fname) src_fname = src.write(code, fname) agr.parse(code, File.basename(src_fname)) agr.parse(code, File.basename(fname), File.basename(src_fname)) end agr.result end Loading lib/jsduck/page.rb +5 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ module JsDuck [ "<table cellspacing='0'>", abstract_row("Extends:", @cls.parent ? class_link(@cls.parent.full_name) : "Object"), abstract_row("Defind In:", file_link), "</table>", ].join("\n") end Loading @@ -44,6 +45,10 @@ module JsDuck "<a href='output/#{name}.html' ext:cls='#{name}'>#{name}</a>" end def file_link "<a href='source/#{@cls[:href]}'>#{@cls[:filename]}</a>" end def abstract_row(label, info) "<tr><td class='label'>#{label}</td><td class='hd-info'>#{info}</td></tr>" end Loading Loading
lib/jsduck/aggregator.rb +15 −5 Original line number Diff line number Diff line Loading @@ -16,20 +16,30 @@ module JsDuck @merger = Merger.new end def parse(input, filename="") # Parses chunk of JavaScript. The resulting documentation is # accumulated inside this class and can be later accessed through # #result method. # # - input the JavaScript source # - filename name of the JS file where it came from # - html_filename name of the HTML file where the source was saved. # def parse(input, filename="", html_filename="") @current_class = nil Parser.new(input).parse.each do |docset| doc = @doc_parser.parse(docset[:comment]) code = docset[:code] href = filename + "#line-" + docset[:linenr].to_s register(add_href(@merger.merge(doc, code), href)) href = html_filename + "#line-" + docset[:linenr].to_s register(add_href(@merger.merge(doc, code), href, filename)) end end # Tags doc-object with link to source code where it came from def add_href(doc, href) # Tags doc-object with link to source code where it came from. # For class we also store the name of the JavaScript file. def add_href(doc, href, filename) doc[:href] = href if doc[:tagname] == :class doc[:filename] = filename doc[:cfg].each {|cfg| cfg[:href] = href } doc[:method].each {|method| method[:href] = href } end Loading
lib/jsduck/app.rb +1 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ module JsDuck puts "Parsing #{fname} ..." if @verbose code = IO.read(fname) src_fname = src.write(code, fname) agr.parse(code, File.basename(src_fname)) agr.parse(code, File.basename(fname), File.basename(src_fname)) end agr.result end Loading
lib/jsduck/page.rb +5 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ module JsDuck [ "<table cellspacing='0'>", abstract_row("Extends:", @cls.parent ? class_link(@cls.parent.full_name) : "Object"), abstract_row("Defind In:", file_link), "</table>", ].join("\n") end Loading @@ -44,6 +45,10 @@ module JsDuck "<a href='output/#{name}.html' ext:cls='#{name}'>#{name}</a>" end def file_link "<a href='source/#{@cls[:href]}'>#{@cls[:filename]}</a>" end def abstract_row(label, info) "<tr><td class='label'>#{label}</td><td class='hd-info'>#{info}</td></tr>" end Loading