Commit 9314af2c authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Add notice box to enum classes docs.

parent 8194e4c7
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ module JsDuck
              render_meta_data(@cls[:html_meta], :top),
              render_private_class_notice,
              @cls[:doc],
              render_enum_class_notice,
              render_meta_data(@cls[:html_meta], :bottom),
            "</div>",
            "<div class='members'>",
@@ -38,6 +39,26 @@ module JsDuck
      ]
    end

    def render_enum_class_notice
      return if !@cls[:enum]

      if @cls[:enum][:type] == "String"
        first = @cls[:members][:property][0] || {:name => 'foo', :default => '"foo"'}
        [
          "<p class='enum'><strong>ENUM:</strong> ",
          "This enumeration defines a set of String values. ",
          "It exists primarily for documentation purposes - ",
          "in code use the actual string values like #{first[:default]}, ",
          "don't reference them through this class like #{@cls[:name]}.#{first[:name]}.</p>",
        ]
      else
        [
          "<p class='enum'><strong>ENUM:</strong> ",
          "This enumeration defines a set of #{@cls[:enum][:type]} values.</p>",
        ]
      end
    end

    def render_meta_data(meta_data, position)
      return if meta_data.size == 0

+7 −0
Original line number Diff line number Diff line
@@ -67,6 +67,13 @@
    background-color: #fee;
    padding: 10px 50px;
    text-align: center; }
  p.enum {
    border: 1px solid #999;
    @include border-radius(5px);
    color: #060;
    background-color: #efe;
    padding: 10px 50px;
    text-align: center; }
  .signature {
    font-weight: bold;
    text-transform: uppercase;