Sha256: 79fb6f13eff4afca921f860f8ebdcdcce28508c3d6b6936fd96fd1c1f1c2a0d9

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

module YARD
  module Server
    module Commands
      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

4 entries across 4 versions & 1 rubygems

Version Path
yard-0.6.3 lib/yard/server/commands/display_object_command.rb
yard-0.6.2 lib/yard/server/commands/display_object_command.rb
yard-0.6.1 lib/yard/server/commands/display_object_command.rb
yard-0.6.0 lib/yard/server/commands/display_object_command.rb