Commit 3d866c1e authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Merge pull request #18 from nick/mvc

Merge in updated mvc with history support and other fixes.
parents a5a89e0d 444eeab0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@ elsif File.exists?(app.output_dir) && !File.directory?(app.output_dir)
  puts "Oh noes!  The output directory is not really a directory at all :("
  exit(1)
elsif !File.exists?(File.dirname(app.output_dir))
  puts "Oh noes!  The parent directory for #{output_dir} doesn't exist."
  puts "Oh noes!  The parent directory for #{app.output_dir} doesn't exist."
  exit(1)
elsif !File.exists?(app.template_dir + "/extjs")
  puts "Oh noes!  The template directory does not contain extjs/ directory :("
+1 −0
Original line number Diff line number Diff line
@@ -245,6 +245,7 @@ module JsDuck
          out_dir = out_path + "/" + guide_name
          puts "Creating guide #{out_dir} ..." if @verbose
          FileUtils.cp_r(in_dir, out_dir)
          formatter.doc_context = {:filename => out_dir + "/README.md", :linenr => 0}
          guide = formatter.format(IO.read(out_dir + "/README.md"))
          guide.gsub!(/<img src="/, "<img src=\"guides/#{guide_name}/")
          write_jsonp_file(out_dir+"/README.js", guide_name, {:guide => guide})
+20 −5
Original line number Diff line number Diff line
@@ -31,7 +31,11 @@ module JsDuck
    # Sets up instance to work in context of particular class, so
    # that when {@link #blah} is encountered it knows that
    # Context#blah is meant.
    attr_accessor :context
    attr_accessor :class_context

    # Sets up instance to work in context of particular doc object.
    # Used for error reporting.
    attr_accessor :doc_context

    # Maximum length for text that doesn't get shortened, defaults to 120
    attr_accessor :max_length
@@ -44,7 +48,8 @@ module JsDuck
    attr_accessor :relations

    def initialize
      @context = ""
      @class_context = ""
      @doc_context = {}
      @max_length = 120
      @relations = {}
      @link_tpl = '<a href="%c%#%m">%a</a>'
@@ -86,7 +91,7 @@ module JsDuck
        target = $1
        text = $2
        if target =~ /^(.*)#(.*)$/
          cls = $1.empty? ? @context : $1
          cls = $1.empty? ? @class_context : $1
          member = $2
        else
          cls = target
@@ -97,14 +102,24 @@ module JsDuck
        if text
          text = text
        elsif member
          text = (cls == @context) ? member : (cls + "." + member)
          text = (cls == @class_context) ? member : (cls + "." + member)
        else
          text = cls
        end

        file = @doc_context[:filename]
        line = @doc_context[:linenr]
        if !@relations[cls]
          puts "Warning: #{file} line #{line} #{input} links to non-existing class."
          text
        elsif member && !get_member_type(cls, member)
          puts "Warning: #{file} line #{line} #{input} links to non-existing member."
          text
        else
          link(cls, member, text)
        end
      end
    end

    def replace_img_tag(input)
      input.sub(@img_re) { img($1, $2) }
+3 −1
Original line number Diff line number Diff line
@@ -35,7 +35,8 @@ module JsDuck

    # converts :doc properties from markdown to html and resolve @links
    def format_class(c)
      @formatter.context = c[:name]
      @formatter.class_context = c[:name]
      @formatter.doc_context = c
      c[:doc] = @formatter.format(c[:doc]) if c[:doc]
      [:cfg, :property, :method, :event, :cssVar, :cssMixin].each do |type|
        c[type] = c[type].map {|m| format_member(m) }
@@ -45,6 +46,7 @@ module JsDuck

    def format_member(m)
      m = m.clone
      @formatter.doc_context = m
      m[:doc] = @formatter.format(m[:doc]) if m[:doc]
      if m[:params] || @formatter.too_long?(m[:doc])
        m[:shortDoc] = @formatter.shorten(m[:doc])
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ module JsDuck
      @relations = relations
      @cache = cache
      @formatter = DocFormatter.new
      @formatter.context = cls.full_name
      @formatter.class_context = cls.full_name
      @formatter.link_tpl = '<a href="output/%c.html%M" rel="%c%M" class="docClass">%a</a>'
      @formatter.relations = relations
    end
Loading