Sha256: 34dd61095363a69e9c66d94e4116c972a5d920f2bee7f6859ba27def7427fea0
Contents?: true
Size: 1.34 KB
Versions: 3
Compression:
Stored size: 1.34 KB
Contents
module JsDuck # Detects the type of documentation object: class, method, cfg, etc class DocType # Given parsed documentation and code, returns the tagname for # documentation item. # # @param docs Result from DocParser # @param code Result from Ast#detect or CssParser#parse # @returns One of: :class, :method, :event, :cfg, :property, :css_var, :css_mixin # def detect(docs, code) doc_map = build_doc_map(docs) if doc_map[:class] :class elsif doc_map[:event] :event elsif doc_map[:method] :method elsif doc_map[:property] || doc_map[:type] :property elsif doc_map[:css_var] :css_var elsif doc_map[:cfg] && doc_map[:cfg].length == 1 # When just one @cfg, avoid treating it as @class :cfg elsif code[:tagname] == :class :class elsif code[:tagname] == :css_mixin :css_mixin elsif doc_map[:cfg] :cfg elsif doc_map[:constructor] :method else code[:tagname] end end private # Build map of at-tags for quick lookup def build_doc_map(docs) map = {} docs.each do |tag| if map[tag[:tagname]] map[tag[:tagname]] << tag else map[tag[:tagname]] = [tag] end end map end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
jsduck-4.0.0 | lib/jsduck/doc_type.rb |
jsduck-4.0.beta2 | lib/jsduck/doc_type.rb |
jsduck-4.0.beta | lib/jsduck/doc_type.rb |