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

Don't skip type parsing when doing export.

Why are we skipping it on that case?  Possibly to avoid creating
the :html_type field, but currently we are creating it anyway, which
defeats the whole purpose of skipping the parsing, plus we lose warnings
of bad typedefs.

Now we get the type warnings also when doing export. And the code
is simpler. Win-win.
parent c7b0f17d
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ module JsDuck
      def initialize(relations={}, opts={})
        @relations = relations
        @opts = opts
        @subproperties = Format::Subproperties.new(self, !!opts[:export])
        @subproperties = Format::Subproperties.new(self)
        @link_renderer = Inline::LinkRenderer.new(relations, opts)
        @inline_link = Inline::Link.new(@link_renderer)
        @auto_link = Inline::AutoLink.new(@link_renderer)
@@ -147,11 +147,8 @@ module JsDuck
      # Turns type parsing on or off.
      #
      # Used to skipping parsing of CSS var and mixin types.
      #
      # Won't have any effect when performing export -
      # type parsing is then automatically turned off.
      def skip_type_parsing=(skip)
        @subproperties.skip_types = !!@opts[:export] || skip
        @subproperties.skip_type_parsing = skip
      end

      # Recursively formats a subproperty.
+5 −5
Original line number Diff line number Diff line
@@ -8,14 +8,14 @@ module JsDuck
    # Helper for recursively formatting subproperties.
    class Subproperties

      def initialize(formatter, skip_types=false)
      def initialize(formatter)
        @formatter = formatter
        @skip_types = skip_types
        @skip_type_parsing = false
      end

      # Set to true to skip parsing and formatting of types.
      # Used when doing export and to skip parsing of CSS typesdefs.
      attr_accessor :skip_types
      # Used to skip parsing of CSS typesdefs.
      attr_accessor :skip_type_parsing

      # Takes a hash of param, return value, throws value or subproperty.
      #
@@ -42,7 +42,7 @@ module JsDuck
      #
      def format_type(type)
        # Skip the formatting entirely when type-parsing is turned off.
        return Util::HTML.escape(type) if @skip_types
        return Util::HTML.escape(type) if @skip_type_parsing

        tp = TypeParser.new(@formatter)
        if tp.parse(type)