Commit ad4d5719 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Merge branch 'master' into esprima-parser

Solved conflicts with @throws implementation and addition to CSS parser.
parents f6a5ed42 fda20f3c
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -149,3 +149,12 @@ Changelog
---------

See [Changelog](https://github.com/senchalabs/jsduck/wiki/Changelog) page in wiki.


More questions?
---------------

Feel free to [post an issue][issues], but read the [FAQ][] first.

[issues]: https://github.com/senchalabs/jsduck/issues
[FAQ]: https://github.com/senchalabs/jsduck/wiki/FAQ
+1 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ module JsDuck
      m[:html_type] = (@include_types && !is_css_tag) ? format_type(m[:type]) : m[:type] if m[:type]
      m[:params] = m[:params].map {|p| format_item(p, is_css_tag) } if m[:params]
      m[:return] = format_item(m[:return], is_css_tag) if m[:return]
      m[:throws] = m[:throws].map {|t| format_item(t, is_css_tag) } if m[:throws]
      m[:properties] = m[:properties].map {|b| format_item(b, is_css_tag) } if m[:properties]
      m[:html_meta] = format_meta_data(m)
      m
+12 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ module JsDuck
        :doc => detect_doc(docs),
        :params => detect_params(doc_map),
        :return => detect_return(doc_map, name == "constructor" ? "Object" : "undefined"),
        :throws => detect_throws(doc_map),
      }, doc_map)
    end

@@ -264,6 +265,17 @@ module JsDuck
      }
    end

    def detect_throws(doc_map)
      return unless doc_map[:throws]

      doc_map[:throws].map do |throws|
        {
          :type => throws[:type] || "Object",
          :doc => throws[:doc] || "",
        }
      end
    end

    # Combines :doc-s of most tags
    # Ignores tags that have doc comment themselves and subproperty tags
    def detect_doc(docs)
+10 −0
Original line number Diff line number Diff line
@@ -128,6 +128,8 @@ module JsDuck
          at_alias
        elsif look(/@var\b/)
          at_var
        elsif look(/@throws\b/)
          at_throws
        elsif look(/@inheritable\b/)
          boolean_at_tag(/@inheritable/, :inheritable)
        elsif look(/@accessor\b/)
@@ -272,6 +274,14 @@ module JsDuck
      skip_white
    end

    # matches @throws {type} ...
    def at_throws
      match(/@throws/)
      add_tag(:throws)
      maybe_type
      skip_white
    end

    # matches @type {type}  or  @type type
    #
    # The presence of @type implies that we are dealing with property.
+20 −0
Original line number Diff line number Diff line
@@ -318,6 +318,10 @@ module JsDuck
        doc << render_return(ret)
      end

      if item[:throws]
        doc << render_throws(item[:throws])
      end

      doc
    end

@@ -351,6 +355,22 @@ module JsDuck
        "</ul>",
      ]
    end

    def render_throws(throws)
      return [
        "<h3 class='pa'>Throws</h3>",
        "<ul>",
          throws.map do |thr|
            [
              "<li>",
                "<span class='pre'>#{thr[:html_type]}</span>",
                "<div class='sub-desc'>#{thr[:doc]}</div>",
              "</li>",
            ]
          end,
        "</ul>",
      ]
    end
  end

end
Loading