Class: Danger::DangerJazzy

Inherits:
Plugin
  • Object
show all
Defined in:
lib/jazzy/plugin.rb

Overview

rubocop:disable Metrics/LineLength This is a danger plugin to check for undocumented symbols via Jazzy.

rubocop:enable Metrics/LineLength

Examples:

Fail on undocumented symbols in modified files.


jazzy.check

Fail on undocumented symbols in all files.


jazzy.check fail: :all

Warn about undocumented symbols in modified files.


jazzy.check warn: :modified

Write a custom message for undocumented symbols in modified files.


jazzy.undocumented.each do |item|
    message "You forgot to document this", file:item.file, line:item.line
end

Write a custom message for undocumented symbols in all files.


jazzy.undocumented(:all).each do |item|
    message "You forgot to document this", file:item.file, line:item.line
end

See Also:

  • fwal/danger-jazzy

Constant Summary collapse

DEFAULT_MESSAGE =
'Undocumented symbol.'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pathString

Path to the docs folder, defaults to ‘docs/’.

Returns:

  • (String)


38
39
40
# File 'lib/jazzy/plugin.rb', line 38

def path
  @path
end

Instance Method Details

#check(config = {}) ⇒ void

This method returns an undefined value.

Checks files for modified symbols.

Takes a hash with the following keys:

* `fail`
* `warn`

Available scopes:

* `modified`
* `all`

Parameters:

  • config (Hash) (defaults to: {})


54
55
56
57
58
# File 'lib/jazzy/plugin.rb', line 54

def check(config = {})
  @config = config
  fail_check
  warn_check
end

#undocumented(scope = :modified) ⇒ Array of symbol

Returns a list of undocumented symbols in the current diff.

Available scopes:

* `modified`
* `all`

Parameters:

  • scope (Key) (defaults to: :modified)

Returns:

  • (Array of symbol)


69
70
71
72
73
74
# File 'lib/jazzy/plugin.rb', line 69

def undocumented(scope = :modified)
  return [] unless scope != :ignore && File.exist?(undocumented_path)
  @undocumented = { modified: [], all: [] } if @undocumented.nil?
  load_undocumented(scope) if @undocumented[scope].empty?
  @undocumented[scope]
end