Sha256: 2658ee2fb5c1793c08c9d2bb79eeff4c52457304bf569ea7374ddaa4e631ec0f

Contents?: true

Size: 1.42 KB

Versions: 68

Compression:

Stored size: 1.42 KB

Contents

module YARD
  module Server
    module Commands
      # Displays documentation for a specific object identified by the path
      class DisplayObjectCommand < LibraryCommand
        include DocServerHelper

        def run
          if path.empty?
            if options.readme
              url = url_for_file(options.readme)
              self.status, self.headers, self.body = *router.send(:route, url)
              cache(body.first)
              return
            else
              self.path = 'index'
            end
          end
          return index if path == 'index'

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

        def index
          Registry.load_all

          options.update(
            :object => '_index.html',
            :objects => Registry.all(:module, :class),
            :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

68 entries across 52 versions & 7 rubygems

Version Path
yard-0.8.7.6 lib/yard/server/commands/display_object_command.rb
yard-0.8.7.5 lib/yard/server/commands/display_object_command.rb
climine-0.0.7 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/server/commands/display_object_command.rb
climine-0.0.7 vendor/bundle/ruby/2.1.0/gems/yard-0.8.7.3/lib/yard/server/commands/display_object_command.rb
climine-0.0.6 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/server/commands/display_object_command.rb
climine-0.0.5 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/server/commands/display_object_command.rb
yard-0.8.7.4 lib/yard/server/commands/display_object_command.rb
climine-0.0.4 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/server/commands/display_object_command.rb
climine-0.0.3 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/server/commands/display_object_command.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/yard-0.8.7.3/lib/yard/server/commands/display_object_command.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/server/commands/display_object_command.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/server/commands/display_object_command.rb
climine-0.0.2 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/server/commands/display_object_command.rb
climine-0.0.1 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/server/commands/display_object_command.rb
yard-0.8.7.3 lib/yard/server/commands/display_object_command.rb
yard-0.8.7.2 lib/yard/server/commands/display_object_command.rb
candlepin-api-0.4.0 bundle/ruby/gems/yard-0.8.7/lib/yard/server/commands/display_object_command.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/yard-0.8.7/lib/yard/server/commands/display_object_command.rb
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/yard-0.8.7/lib/yard/server/commands/display_object_command.rb
yard-0.8.7.1 lib/yard/server/commands/display_object_command.rb