Loading lib/jsduck/app.rb +1 −1 Original line number Diff line number Diff line Loading @@ -114,7 +114,7 @@ module JsDuck def parallel_parse(filenames) @parallel.map(filenames) do |fname| Logger.instance.log("Parsing #{fname} ...") SourceFile.new(IO.read(fname), fname) SourceFile.new(IO.read(fname), fname, @opts) end end Loading lib/jsduck/js_parser.rb +16 −6 Original line number Diff line number Diff line Loading @@ -6,10 +6,11 @@ require 'jsduck/js_literal_builder' module JsDuck class JsParser < JsLiteralParser def initialize(input) def initialize(input, namespaces = nil) super(input) @doc_parser = DocParser.new @docs = [] @ext_namespaces = namespaces || ["Ext"] end # Parses the whole JavaScript block and returns array where for Loading Loading @@ -76,9 +77,9 @@ module JsDuck function elsif look("var") var_declaration elsif look("Ext", ".", "define", "(", :string) elsif ext_look(:ns, ".", "define", "(", :string) ext_define elsif look("Ext", ".", "ClassManager", ".", "create", "(", :string) elsif ext_look(:ns, ".", "ClassManager", ".", "create", "(", :string) ext_define elsif look(:ident, ":") || look(:string, ":") property_literal Loading Loading @@ -159,7 +160,7 @@ module JsDuck def expression if look("function") function elsif look("Ext", ".", "extend") elsif ext_look(:ns, ".", "extend") ext_extend else my_literal Loading Loading @@ -194,7 +195,7 @@ module JsDuck # <ext-extend> := "Ext" "." "extend" "(" <ident-chain> "," ... def ext_extend match("Ext", ".", "extend", "(") match(:ident, ".", "extend", "(") return { :type => :ext_extend, :extend => ident_chain, Loading @@ -203,7 +204,7 @@ module JsDuck # <ext-define> := "Ext" "." ["define" | "ClassManager" "." "create" ] "(" <string> "," <ext-define-cfg> def ext_define match("Ext", "."); match(:ident, "."); look("define") ? match("define") : match("ClassManager", ".", "create"); name = match("(", :string)[:value] Loading Loading @@ -338,6 +339,15 @@ module JsDuck } end # Like look() but tries to match as the first argument all the # names listed in @ext_namespaces def ext_look(placeholder, *args) @ext_namespaces.each do |ns| return true if look(ns, *args) end return false end end end lib/jsduck/options.rb +7 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ module JsDuck attr_accessor :template_links attr_accessor :extjs_path attr_accessor :local_storage_db attr_accessor :ext_namespaces def initialize @input_files = [] Loading Loading @@ -94,6 +95,7 @@ module JsDuck @template_links = false @extjs_path = "extjs/ext-all.js" @local_storage_db = "docs" @ext_namespaces = ["Ext"] end def parse!(argv) Loading Loading @@ -259,6 +261,11 @@ module JsDuck @local_storage_db = name end opts.on('--ext-namespaces=Ext,Foo', Array, "Namespace(s) of ExtJS. Defaults to 'Ext'.", " ") do |ns| @ext_namespaces = ns end opts.on('-h', '--help', "Prints this help message", " ") do puts opts exit Loading lib/jsduck/source_file.rb +3 −2 Original line number Diff line number Diff line Loading @@ -15,9 +15,10 @@ module JsDuck attr_reader :docs attr_reader :html_filename def initialize(contents, filename="") def initialize(contents, filename="", options=nil) @contents = contents @filename = filename @options = options @html_filename = "" @links = {} Loading Loading @@ -80,7 +81,7 @@ module JsDuck if @filename =~ /\.s?css$/ CssParser.new(@contents).parse else JsParser.new(@contents).parse JsParser.new(@contents, @options && @options.ext_namespaces).parse end end Loading Loading
lib/jsduck/app.rb +1 −1 Original line number Diff line number Diff line Loading @@ -114,7 +114,7 @@ module JsDuck def parallel_parse(filenames) @parallel.map(filenames) do |fname| Logger.instance.log("Parsing #{fname} ...") SourceFile.new(IO.read(fname), fname) SourceFile.new(IO.read(fname), fname, @opts) end end Loading
lib/jsduck/js_parser.rb +16 −6 Original line number Diff line number Diff line Loading @@ -6,10 +6,11 @@ require 'jsduck/js_literal_builder' module JsDuck class JsParser < JsLiteralParser def initialize(input) def initialize(input, namespaces = nil) super(input) @doc_parser = DocParser.new @docs = [] @ext_namespaces = namespaces || ["Ext"] end # Parses the whole JavaScript block and returns array where for Loading Loading @@ -76,9 +77,9 @@ module JsDuck function elsif look("var") var_declaration elsif look("Ext", ".", "define", "(", :string) elsif ext_look(:ns, ".", "define", "(", :string) ext_define elsif look("Ext", ".", "ClassManager", ".", "create", "(", :string) elsif ext_look(:ns, ".", "ClassManager", ".", "create", "(", :string) ext_define elsif look(:ident, ":") || look(:string, ":") property_literal Loading Loading @@ -159,7 +160,7 @@ module JsDuck def expression if look("function") function elsif look("Ext", ".", "extend") elsif ext_look(:ns, ".", "extend") ext_extend else my_literal Loading Loading @@ -194,7 +195,7 @@ module JsDuck # <ext-extend> := "Ext" "." "extend" "(" <ident-chain> "," ... def ext_extend match("Ext", ".", "extend", "(") match(:ident, ".", "extend", "(") return { :type => :ext_extend, :extend => ident_chain, Loading @@ -203,7 +204,7 @@ module JsDuck # <ext-define> := "Ext" "." ["define" | "ClassManager" "." "create" ] "(" <string> "," <ext-define-cfg> def ext_define match("Ext", "."); match(:ident, "."); look("define") ? match("define") : match("ClassManager", ".", "create"); name = match("(", :string)[:value] Loading Loading @@ -338,6 +339,15 @@ module JsDuck } end # Like look() but tries to match as the first argument all the # names listed in @ext_namespaces def ext_look(placeholder, *args) @ext_namespaces.each do |ns| return true if look(ns, *args) end return false end end end
lib/jsduck/options.rb +7 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ module JsDuck attr_accessor :template_links attr_accessor :extjs_path attr_accessor :local_storage_db attr_accessor :ext_namespaces def initialize @input_files = [] Loading Loading @@ -94,6 +95,7 @@ module JsDuck @template_links = false @extjs_path = "extjs/ext-all.js" @local_storage_db = "docs" @ext_namespaces = ["Ext"] end def parse!(argv) Loading Loading @@ -259,6 +261,11 @@ module JsDuck @local_storage_db = name end opts.on('--ext-namespaces=Ext,Foo', Array, "Namespace(s) of ExtJS. Defaults to 'Ext'.", " ") do |ns| @ext_namespaces = ns end opts.on('-h', '--help', "Prints this help message", " ") do puts opts exit Loading
lib/jsduck/source_file.rb +3 −2 Original line number Diff line number Diff line Loading @@ -15,9 +15,10 @@ module JsDuck attr_reader :docs attr_reader :html_filename def initialize(contents, filename="") def initialize(contents, filename="", options=nil) @contents = contents @filename = filename @options = options @html_filename = "" @links = {} Loading Loading @@ -80,7 +81,7 @@ module JsDuck if @filename =~ /\.s?css$/ CssParser.new(@contents).parse else JsParser.new(@contents).parse JsParser.new(@contents, @options && @options.ext_namespaces).parse end end Loading