Commit 1b13fdb9 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Support @example with title and empty line after.

parent 494888d4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ module JsDuck
      @link_re = /\{@link\s+(\S*?)(?:\s+(.+?))?\}/m
      @img_re = /\{@img\s+(\S*?)(?:\s+(.+?))?\}/m
      @example_re = /\{@example\s+(\S*?)\s*\}/m
      @example_annotation_re = /<pre><code>@example\s*\n/m
      @example_annotation_re = /<pre><code>@example( +[^\n]*)?\s+/m
    end

    # Replaces {@link} and {@img} tags, auto-generates links for
+28 −10
Original line number Diff line number Diff line
@@ -301,6 +301,20 @@ describe JsDuck::DocFormatter do
      end
    end

    shared_examples_for "example" do
      it "creates <pre> with inline-example class" do
        @html.should =~ /<pre class="inline-example">/m
      end

      it "removes the line with @example markup" do
        @html.should_not =~ /@example/m
      end

      it "completely removes the first line and whitespace after it" do
        @html.should =~ /code>if/m
      end
    end

    describe "code block beginning with @example" do
      before do
        @html = @formatter.format(<<-EOS.gsub(/^ *\|/, ""))
@@ -312,18 +326,22 @@ describe JsDuck::DocFormatter do
          |    }
        EOS
      end

      it "creates <pre> with inline-example class" do
        @html.should =~ /<pre class="inline-example">/m
      it_should_behave_like "example"
    end

      it "removes the line with @example markup" do
        @html.should_not =~ /@example/m
      end

      it "completely removes the first line" do
        @html.should =~ /code>if/m
    describe "code block beginning with @example and title" do
      before do
        @html = @formatter.format(<<-EOS.gsub(/^ *\|/, ""))
          |See example:
          |
          |    @example My little example
          |
          |    if (condition) {
          |        doSomething();
          |    }
        EOS
      end
      it_should_behave_like "example"
    end

  end