Commit 0a78d623 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Support {@img} tags in guides.

Now all images can be marked up the same way - no need for special
syntax in guides.
parent 003241df
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -155,6 +155,7 @@ module JsDuck
    # Formats each class
    def format_classes
      doc_formatter = get_doc_formatter
      doc_formatter.img_path = "images"
      class_formatter = ClassFormatter.new(@relations, doc_formatter)
      # Don't format types when exporting
      class_formatter.include_types = !@opts.export
+5 −1
Original line number Diff line number Diff line
@@ -36,6 +36,10 @@ module JsDuck
    # This will hold list of all image paths gathered from {@img} tags.
    attr_accessor :images

    # Base path to prefix images from {@img} tags.
    # Defaults to no prefix.
    attr_accessor :img_path

    # Sets up instance to work in context of particular class, so
    # that when {@link #blah} is encountered it knows that
    # Context#blah is meant.
@@ -175,7 +179,7 @@ module JsDuck
      @img_tpl.gsub(/(%\w)/) do
        case $1
        when '%u'
          "images/" + url
          @img_path ? (@img_path + "/" + url) : url
        when '%a'
          CGI.escapeHTML(alt_text||"")
        else
+2 −2
Original line number Diff line number Diff line
@@ -49,9 +49,9 @@ module JsDuck
      FileUtils.cp_r(in_dir, out_dir)

      @formatter.doc_context = {:filename => guide_file, :linenr => 0}
      html = @formatter.format(IO.read(guide_file))
      name = File.basename(in_dir)
      html.gsub!(/<img src="/, "<img src=\"guides/#{name}/")
      @formatter.img_path = "guides/#{name}"
      html = @formatter.format(IO.read(guide_file))

      JsonDuck.write_jsonp(out_dir+"/README.js", name, {:guide => html, :title => guide["title"]})
    end