Commit 0507abea authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

No more access options object as Hash.

Always expect it to be an object with accessor methods.
As a default (and in tests) use OpenStruct.
parent f65e13a5
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
require 'jsduck/class'
require 'jsduck/member_registry'
require 'ostruct'

module JsDuck
  module Exporter

    # Exporter for all the class docs.
    class Full
      def initialize(relations, opts={})
      def initialize(relations, opts=OpenStruct.new)
        # parameters are just for compatibility with other exporters
      end

+3 −2
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ require 'jsduck/inline/link_renderer'
require 'jsduck/inline/img'
require 'jsduck/inline/video'
require 'jsduck/inline/example'
require 'ostruct'

module JsDuck
  module Format
@@ -18,7 +19,7 @@ module JsDuck
      # Creates a formatter configured with options originating from
      # command line.  For the actual effect of the options see
      # Inline::* classes.
      def initialize(relations={}, opts={})
      def initialize(relations={}, opts=OpenStruct.new)
        @relations = relations
        @opts = opts
        @subproperties = Format::Subproperties.new(self)
@@ -104,7 +105,7 @@ module JsDuck
        # Keep track of open HTML tags. We're not auto-detecting class
        # names when inside <a>. Also we want to close down the unclosed
        # tags.
        tags = Format::HtmlStack.new(@opts[:ignore_html] || {}, @doc_context)
        tags = Format::HtmlStack.new(@opts.ignore_html || {}, @doc_context)

        while !s.eos? do
          if substitute = @inline_link.replace(s)
+3 −1
Original line number Diff line number Diff line
require 'ostruct'

module JsDuck
  module Inline

@@ -14,7 +16,7 @@ module JsDuck
    class Example
      # Constructor takes opts parameter for consistency with other
      # JsDuck::Inline::* classes.
      def initialize(opts={})
      def initialize(opts=OpenStruct.new)
        @re = /<pre><code>\s*@example( +[^\n]*)?\s+/m
      end

+3 −3
Original line number Diff line number Diff line
require 'jsduck/util/html'
require 'jsduck/logger'
require 'pp'
require 'ostruct'

module JsDuck
  module Inline
@@ -15,8 +15,8 @@ module JsDuck
      # Used for error reporting.
      attr_accessor :doc_context

      def initialize(opts={})
        @tpl = opts[:img] || '<img src="%u" alt="%a" width="%w" height="%h"/>'
      def initialize(opts=OpenStruct.new)
        @tpl = opts.img || '<img src="%u" alt="%a" width="%w" height="%h"/>'

        @re = /\{@img\s+(\S*?)(?:\s+(.+?))?\}/m
      end
+3 −2
Original line number Diff line number Diff line
require 'jsduck/util/html'
require 'ostruct'

module JsDuck
  module Inline
@@ -9,7 +10,7 @@ module JsDuck
      # Inline::AutoLink.
      attr_reader :relations

      def initialize(relations={}, opts={})
      def initialize(relations={}, opts=OpenStruct.new)
        @relations = relations

        # Template HTML that replaces {@link Class#member anchor text}.
@@ -20,7 +21,7 @@ module JsDuck
        # %# - inserts "#" if member name present
        # %- - inserts "-" if member name present
        # %a - anchor text for link
        @tpl = opts[:link] || '<a href="%c%#%m">%a</a>'
        @tpl = opts.link || '<a href="%c%#%m">%a</a>'
      end

      # Generates HTML link to class or member applying the link
Loading