Sha256: 9c70d136d3fe4eea0dbf2332c9eadfa334bcf387420d888fbac337c83d66d21b

Contents?: true

Size: 1.27 KB

Versions: 30

Compression:

Stored size: 1.27 KB

Contents

module YARD
  module Server
    module Commands
      # Displays documentation for a specific object identified by the path
      class DisplayObjectCommand < LibraryCommand
        def run
          return index if path.empty?

          if object = Registry.at(object_path)
            options.update(:type => :layout)
            render(object)
          else
            self.status = 404
          end
        end

        def index
          Registry.load_all

          title = options[:title]
          unless title
            title = "Documentation for #{library.name} #{library.version ? '(' + library.version + ')' : ''}"
          end
          options.update(
            :object => '_index.html',
            :objects => Registry.all(:module, :class),
            :title => title,
            :type => :layout
          )
          render
        end

        def not_found
          super
          self.body = "Could not find object: #{object_path}"
        end

        private

        def object_path
          return @object_path if @object_path
          if path == "toplevel"
            @object_path = :root
          else
            @object_path = path.sub(':', '#').gsub('/', '::').sub(/^toplevel\b/, '').sub(/\.html$/, '')
          end
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 4 rubygems

Version Path
challah-0.6.2 vendor/bundle/gems/yard-0.7.5/lib/yard/server/commands/display_object_command.rb
challah-0.6.1 vendor/bundle/gems/yard-0.7.5/lib/yard/server/commands/display_object_command.rb
challah-0.6.0 vendor/bundle/gems/yard-0.7.5/lib/yard/server/commands/display_object_command.rb
challah-0.5.4 vendor/bundle/gems/yard-0.7.5/lib/yard/server/commands/display_object_command.rb
challah-0.5.3 vendor/bundle/gems/yard-0.7.5/lib/yard/server/commands/display_object_command.rb
challah-0.5.2 vendor/bundle/gems/yard-0.7.5/lib/yard/server/commands/display_object_command.rb
challah-0.5.1 vendor/bundle/gems/yard-0.7.5/lib/yard/server/commands/display_object_command.rb
challah-0.5.0 vendor/bundle/gems/yard-0.7.5/lib/yard/server/commands/display_object_command.rb
challah-0.4.1 vendor/bundle/gems/yard-0.7.5/lib/yard/server/commands/display_object_command.rb
challah-0.4.0 vendor/bundle/gems/yard-0.7.5/lib/yard/server/commands/display_object_command.rb
challah-0.3.5 vendor/bundle/gems/yard-0.7.5/lib/yard/server/commands/display_object_command.rb
challah-0.3.4 vendor/bundle/gems/yard-0.7.5/lib/yard/server/commands/display_object_command.rb
challah-0.3.3 vendor/bundle/gems/yard-0.7.5/lib/yard/server/commands/display_object_command.rb
challah-0.3.2 vendor/bundle/gems/yard-0.7.5/lib/yard/server/commands/display_object_command.rb
challah-0.3.1 vendor/bundle/gems/yard-0.7.5/lib/yard/server/commands/display_object_command.rb
challah-0.3.0 vendor/bundle/gems/yard-0.7.5/lib/yard/server/commands/display_object_command.rb
challah-0.2.1 vendor/bundle/gems/yard-0.7.5/lib/yard/server/commands/display_object_command.rb
challah-0.2.0 vendor/bundle/gems/yard-0.7.5/lib/yard/server/commands/display_object_command.rb
yard-0.7.5 lib/yard/server/commands/display_object_command.rb
nutshell-crm-0.0.6.alpha vendor/bundle/gems/yard-0.7.4/lib/yard/server/commands/display_object_command.rb