# Class: YARD::CLI::Server

Inherits:
  Command
  - Object
  - Command
  - YARD::CLI::Server
  show all

Defined in:
  lib/yard/cli/server.rb

## Overview

A local documentation server

Since:

- 0.6.0

## Instance Attribute Summary collapse

- #adapter ⇒ YARD::Server::Adapter

  The adapter to use for loading the web server.

- #libraries ⇒ Hash

  A list of library names and yardoc files to serve.

- #options ⇒ Hash

  A list of options to pass to the doc server.

- #scripts ⇒ Array<String>

  A list of scripts to load.

- #server_options ⇒ Hash

  A list of options to pass to the web server.

- #template_paths ⇒ Array<String>

  A list of template paths to register.

## Instance Method Summary collapse

- #description ⇒ Object
- #initialize ⇒ Server constructor

  Creates a new instance of the Server command line utility.

- #run(*args) ⇒ Object

## Constructor Details

### #initialize ⇒ `Server`

Creates a new instance of the Server command line utility

Since:

- 0.6.0

    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39

    # File 'lib/yard/cli/server.rb', line 29

    def initialize
      super
      self.scripts = []
      self.template_paths = []
      self.libraries = {}
      self.options = SymbolHash.new(false).update(
        :single_library => true,
        :caching => false
      )
      self.server_options = {:Port => 8808}
    end

## Instance Attribute Details

### #adapter ⇒ `YARD::Server::Adapter`

Returns the adapter to use for loading the web server.

Returns:

- (`YARD::Server::Adapter`) —

  the adapter to use for loading the web server

Since:

- 0.6.0

    18
    19
    20

    # File 'lib/yard/cli/server.rb', line 18

    def adapter
      @adapter
    end

### #libraries ⇒ `Hash`

Returns a list of library names and yardoc files to serve.

Returns:

- (`Hash`) —

  a list of library names and yardoc files to serve

Since:

- 0.6.0

    15
    16
    17

    # File 'lib/yard/cli/server.rb', line 15

    def libraries
      @libraries
    end

### #options ⇒ `Hash`

Returns a list of options to pass to the doc server.

Returns:

- (`Hash`) —

  a list of options to pass to the doc server

Since:

- 0.6.0

    9
    10
    11

    # File 'lib/yard/cli/server.rb', line 9

    def options
      @options
    end

### #scripts ⇒ `Array<String>`

Returns a list of scripts to load.

Returns:

- (`Array<String>`) —

  a list of scripts to load

Since:

- 0.6.2

    22
    23
    24

    # File 'lib/yard/cli/server.rb', line 22

    def scripts
      @scripts
    end

### #server_options ⇒ `Hash`

Returns a list of options to pass to the web server.

Returns:

- (`Hash`) —

  a list of options to pass to the web server

Since:

- 0.6.0

    12
    13
    14

    # File 'lib/yard/cli/server.rb', line 12

    def server_options
      @server_options
    end

### #template_paths ⇒ `Array<String>`

Returns a list of template paths to register.

Returns:

- (`Array<String>`) —

  a list of template paths to register

Since:

- 0.6.2

    26
    27
    28

    # File 'lib/yard/cli/server.rb', line 26

    def template_paths
      @template_paths
    end

## Instance Method Details

### #description ⇒ `Object`

Since:

- 0.6.0

    41
    42
    43

    # File 'lib/yard/cli/server.rb', line 41

    def description
      "Runs a local documentation server"
    end

### #run(*args) ⇒ `Object`

Since:

- 0.6.0

    45
    46
    47
    48
    49
    50
    51
    52

    # File 'lib/yard/cli/server.rb', line 45

    def run(*args)
      optparse(*args)

      select_adapter.setup
      load_scripts
      load_template_paths
      adapter.new(libraries, options, server_options).start
    end