Class | YARD::Config |
In: |
lib/yard/config.rb
|
Parent: | Object |
This class maintains all system-wide configuration for YARD and handles the loading of plugins. To access options call {options}, and to load a plugin use {load_plugin}. All other public methods are used by YARD during load time.
Persistent user configuration files can be stored in the file +~/.yard/config+, which is read when YARD first loads. The file should be formatted as YAML, and should contain a map of keys and values.
Although you can specify any key-value mapping in the configuration file, YARD defines special keys specified in {DEFAULT_CONFIG_OPTIONS}.
An example of a configuration file is listed below:
!!!yaml load_plugins: true # Auto-load plugins when YARD starts ignored_plugins: - yard-broken - broken2 # yard- prefix not necessary autoload_plugins: - yard-rspec
YARD 0.6.2 will no longer automatically load all plugins by default. This option can be reset by setting ‘load_plugins’ to true in the configuration file. In addition, you can specify a set of specific plugins to load on load through the ‘autoload_plugins’ list setting. This setting is independent of the ‘load_plugins’ value and will always be processed.
YARD 0.5 and below used a +~/.yard/ignored_plugins+ file to specify plugins to be ignored at load time. Ignored plugins in 0.6.2 and above should now be specified in the main configuration file, though YARD will support the ignored_plugins file until 0.7.x.
YARD supports running in safe-mode. By doing this, it will avoid executing any user code such as require files or queries. Plugins will still be loaded with safe mode on, because plugins are properly namespaced with a ‘yard-’ prefix, must be installed as a gem, and therefore cannot be touched by the user. To specify safe mode, use the safe_mode key.
@since 0.6.2 @see options
CONFIG_DIR | = | File.expand_path('~/.yard') | The location where YARD stores user-specific settings | |
CONFIG_FILE | = | File.join(CONFIG_DIR, 'config') | The main configuration YAML file. | |
IGNORED_PLUGINS | = | File.join(CONFIG_DIR, 'ignored_plugins') | File listing all ignored plugins @deprecated Set `ignored_plugins` in the {CONFIG_FILE} instead. | |
DEFAULT_CONFIG_OPTIONS | = | { :load_plugins => false, # Whether to load plugins automatically with YARD :ignored_plugins => [], # A list of ignored plugins by name :autoload_plugins => [], # A list of plugins to be automatically loaded :safe_mode => false | Default configuration options | |
YARD_PLUGIN_PREFIX | = | /^yard[-_]/ | The prefix used for YARD plugins. Name your gem with this prefix to allow it to be used as a plugin. |
options | [RW] | The system-wide configuration options for YARD @return [SymbolHash] a map a key-value pair settings. @see DEFAULT_CONFIG_OPTIONS |
Loads an individual plugin by name. It is not necessary to include the +yard-+ plugin prefix here.
@param [String] name the name of the plugin (with or without +yard-+ prefix) @return [Boolean] whether the plugin was successfully loaded
Loads gems that match the name ‘yard-*’ (recommended) or ‘yard_*’ except those listed in +~/.yard/ignored_plugins+. This is called immediately after YARD is loaded to allow plugin support.
@return [Boolean] true if all plugins loaded successfully, false otherwise.