bridgetown-core 2.0.0.beta1 → 2.0.0.beta3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/Rakefile +2 -1
  4. data/bridgetown-core.gemspec +2 -2
  5. data/lib/bridgetown-core/cache.rb +3 -19
  6. data/lib/bridgetown-core/cleaner.rb +17 -19
  7. data/lib/bridgetown-core/collection.rb +9 -2
  8. data/lib/bridgetown-core/commands/build.rb +6 -17
  9. data/lib/bridgetown-core/commands/concerns/actions.rb +4 -0
  10. data/lib/bridgetown-core/commands/esbuild/esbuild.config.js +7 -6
  11. data/lib/bridgetown-core/commands/esbuild/esbuild.defaults.js.erb +14 -13
  12. data/lib/bridgetown-core/commands/esbuild/migrate-from-webpack.rb +1 -1
  13. data/lib/bridgetown-core/commands/esbuild/update.rb +17 -3
  14. data/lib/bridgetown-core/commands/esbuild.rb +1 -1
  15. data/lib/bridgetown-core/component.rb +1 -1
  16. data/lib/bridgetown-core/concerns/layout_placeable.rb +1 -1
  17. data/lib/bridgetown-core/concerns/publishable.rb +2 -0
  18. data/lib/bridgetown-core/concerns/site/content.rb +4 -1
  19. data/lib/bridgetown-core/concerns/site/extensible.rb +6 -1
  20. data/lib/bridgetown-core/concerns/site/fast_refreshable.rb +20 -13
  21. data/lib/bridgetown-core/concerns/site/localizable.rb +2 -0
  22. data/lib/bridgetown-core/concerns/site/processable.rb +2 -0
  23. data/lib/bridgetown-core/concerns/site/renderable.rb +3 -0
  24. data/lib/bridgetown-core/concerns/site/ssr.rb +0 -1
  25. data/lib/bridgetown-core/configuration.rb +8 -14
  26. data/lib/bridgetown-core/converter.rb +2 -7
  27. data/lib/bridgetown-core/converters/identity.rb +3 -11
  28. data/lib/bridgetown-core/converters/liquid_templates.rb +3 -5
  29. data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +1 -1
  30. data/lib/bridgetown-core/converters/markdown.rb +11 -14
  31. data/lib/bridgetown-core/converters/serbea_templates.rb +3 -4
  32. data/lib/bridgetown-core/drops/drop.rb +29 -42
  33. data/lib/bridgetown-core/drops/resource_drop.rb +3 -12
  34. data/lib/bridgetown-core/errors.rb +2 -8
  35. data/lib/bridgetown-core/filters/condition_helpers.rb +6 -9
  36. data/lib/bridgetown-core/filters/date_filters.rb +22 -35
  37. data/lib/bridgetown-core/filters/grouping_filters.rb +11 -11
  38. data/lib/bridgetown-core/filters.rb +53 -72
  39. data/lib/bridgetown-core/front_matter/defaults.rb +8 -13
  40. data/lib/bridgetown-core/generated_page.rb +6 -6
  41. data/lib/bridgetown-core/generators/prototype_generator.rb +0 -2
  42. data/lib/bridgetown-core/hooks.rb +0 -1
  43. data/lib/bridgetown-core/layout.rb +3 -4
  44. data/lib/bridgetown-core/liquid_extensions.rb +3 -5
  45. data/lib/bridgetown-core/log_adapter.rb +37 -56
  46. data/lib/bridgetown-core/plugin_manager.rb +18 -3
  47. data/lib/bridgetown-core/rack/logger.rb +0 -2
  48. data/lib/bridgetown-core/resource/base.rb +8 -8
  49. data/lib/bridgetown-core/resource/permalink_processor.rb +1 -1
  50. data/lib/bridgetown-core/ruby_template_view.rb +0 -1
  51. data/lib/bridgetown-core/static_file.rb +15 -20
  52. data/lib/bridgetown-core/tags/class_map.rb +1 -1
  53. data/lib/bridgetown-core/tags/post_url.rb +2 -32
  54. data/lib/bridgetown-core/utils/require_gems.rb +1 -3
  55. data/lib/bridgetown-core/utils.rb +41 -44
  56. data/lib/bridgetown-core/watcher.rb +2 -3
  57. data/lib/bridgetown-core.rb +1 -2
  58. data/lib/roda/plugins/bridgetown_server.rb +2 -3
  59. data/lib/site_template/package.json.erb +1 -0
  60. data/lib/site_template/postcss.config.js.erb +1 -1
  61. data/lib/site_template/src/posts.md.erb +8 -8
  62. metadata +6 -7
  63. data/lib/bridgetown-core/version.rb +0 -6
@@ -3,6 +3,7 @@
3
3
  class Bridgetown::Site
4
4
  module Localizable
5
5
  # Returns the current and/or default configured locale
6
+ #
6
7
  # @return String
7
8
  def locale
8
9
  @locale ||= begin
@@ -16,6 +17,7 @@ class Bridgetown::Site
16
17
  end
17
18
 
18
19
  # Sets the current locale for the site
20
+ #
19
21
  # @param new_locale [String] for example: "en" for English, "es" for Spanish
20
22
  def locale=(new_locale)
21
23
  I18n.locale = @locale = new_locale.to_sym
@@ -3,6 +3,7 @@
3
3
  class Bridgetown::Site
4
4
  module Processable
5
5
  # Reset, Read, Generate, Render, Cleanup, Process, and Write this Site to output.
6
+ #
6
7
  # @return [void]
7
8
  # @see #reset
8
9
  # @see #read
@@ -67,6 +68,7 @@ class Bridgetown::Site
67
68
  end
68
69
 
69
70
  # Read data from disk and load it into internal memory.
71
+ #
70
72
  # @return [void]
71
73
  def read
72
74
  Bridgetown::Hooks.trigger :site, :pre_read, self
@@ -3,6 +3,7 @@
3
3
  class Bridgetown::Site
4
4
  module Renderable
5
5
  # Render all pages & documents so they're ready to be written out to disk.
6
+ #
6
7
  # @return [void]
7
8
  # @see Page
8
9
  # @see Document
@@ -97,6 +98,7 @@ class Bridgetown::Site
97
98
  end
98
99
 
99
100
  # Renders all resources
101
+ #
100
102
  # @return [void]
101
103
  def render_resources
102
104
  collections.each_value do |collection|
@@ -109,6 +111,7 @@ class Bridgetown::Site
109
111
  end
110
112
 
111
113
  # Renders a content item while ensuring site locale is set if the data is available.
114
+ #
112
115
  # @param item [Bridgetown::Resource::Base] The item to render
113
116
  # @yield Runs the block in between locale setting and resetting
114
117
  # @return [void]
@@ -45,7 +45,6 @@ class Bridgetown::Site
45
45
  end
46
46
 
47
47
  def ssr_first_read
48
- # TODO: this shouldn't be running twice, right?!
49
48
  Bridgetown::Hooks.trigger :site, :pre_read, self
50
49
  defaults_reader.tap do |d|
51
50
  d.path_defaults.clear
@@ -111,12 +111,11 @@ module Bridgetown
111
111
  attr_writer :source_manifests, :roda_initializers
112
112
 
113
113
  class << self
114
- # Static: Produce a Configuration ready for use in a Site.
114
+ # Produce a Configuration ready for use in a Site.
115
115
  # It takes the input, fills in the defaults where values do not exist.
116
116
  #
117
- # user_config - a Hash or Configuration of overrides.
118
- #
119
- # Returns a Configuration filled with defaults.
117
+ # @param user_config [Hash, Configuration]
118
+ # @return [Configuration] filled with defaults
120
119
  def from(user_config, starting_defaults = DEFAULTS)
121
120
  Utils.deep_merge_hashes(starting_defaults.deep_dup, Configuration.new(user_config))
122
121
  .merge_environment_specific_options!
@@ -177,16 +176,14 @@ module Bridgetown
177
176
  # Directory of the top-level root where config files are located
178
177
  #
179
178
  # @param override [Hash] options hash which will override value if key is present
180
- #
181
179
  # @return [String] path to the Bridgetown root directory
182
180
  def root_dir(override = {})
183
181
  get_config_value_with_override("root_dir", override)
184
182
  end
185
183
 
186
- # Public: Directory of the Bridgetown source folder
184
+ # Directory of the Bridgetown source folder
187
185
  #
188
186
  # @param override [Hash] options hash which will override value if key is present
189
- #
190
187
  # @return [String] path to the Bridgetown source directory
191
188
  def source(override = {})
192
189
  get_config_value_with_override("source", override)
@@ -208,11 +205,10 @@ module Bridgetown
208
205
  raise "Unable to parse `#{File.basename(filename)}'. #{e.message}"
209
206
  end
210
207
 
211
- # Public: Generate list of configuration files from the override
208
+ # Generate list of configuration files from the override
212
209
  #
213
- # override - the command-line options hash
214
- #
215
- # Returns an Array of config files
210
+ # @param override [Hash] the command-line options hash
211
+ # @return [Array<string>] config files
216
212
  def config_files(override)
217
213
  # Adjust verbosity quickly
218
214
  Bridgetown.logger.adjust_verbosity(
@@ -232,9 +228,8 @@ module Bridgetown
232
228
  # Read in a list of configuration files and merge with this hash
233
229
  #
234
230
  # @param files [Array<String>]
235
- #
236
231
  # @return [Hash] configuration with the defaults overridden by the values in the
237
- # configuration files
232
+ # configuration files
238
233
  def read_config_files(files)
239
234
  config = self
240
235
 
@@ -257,7 +252,6 @@ module Bridgetown
257
252
  # Read configuration and return merged Hash
258
253
  #
259
254
  # @param file [String] the path to the YAML file to be read in
260
- #
261
255
  # @return [Hash]
262
256
  def read_config_file(file)
263
257
  default_config_file = file == "bridgetown.config.yml"
@@ -40,7 +40,6 @@ module Bridgetown
40
40
  #
41
41
  # @param content [String] content of file (without front matter).
42
42
  # @param convertible [Bridgetown::Layout, Bridgetown::Resource::Base]
43
- #
44
43
  # @return [String] the converted content.
45
44
  def convert(content, convertible = nil) # rubocop:disable Lint/UnusedMethodArgument
46
45
  content
@@ -48,10 +47,8 @@ module Bridgetown
48
47
 
49
48
  # Does the given extension match this converter's list of acceptable extensions?
50
49
  #
51
- # @param [String] ext
52
- # The file's extension (including the dot)
50
+ # @param ext [String] the file's extension (including the dot)
53
51
  # @param convertible [Bridgetown::Layout, Bridgetown::Resource::Base]
54
- #
55
52
  # @return [Boolean] Whether the extension matches one in the list
56
53
  def matches(ext, _convertible = nil)
57
54
  (self.class.extname_list || []).include?(ext.downcase)
@@ -67,9 +64,7 @@ module Bridgetown
67
64
  # You can override this in Converter subclasses as needed. Default is ".html", unless the
68
65
  # converter is a template engine and the input file doesn't match the normal template extension
69
66
  #
70
- # @param [String] ext
71
- # The extension of the original file
72
- #
67
+ # @param ext [String] the extension of the original file
73
68
  # @return [String] The output file extension (including the dot)
74
69
  def output_ext(ext)
75
70
  if self.class.template_engine
@@ -9,21 +9,13 @@ module Bridgetown
9
9
 
10
10
  support_slots
11
11
 
12
- # Public: Does the given extension match this converter's list of acceptable extensions?
13
- # Takes one argument: the file's extension (including the dot).
14
- #
15
- # _ext - The String extension to check (not relevant here)
16
- #
17
- # Returns true since it always matches.
12
+ # @return [Boolean] true since it always matches.
18
13
  def matches(*)
19
14
  true
20
15
  end
21
16
 
22
- # Public: The extension to be given to the output file (including the dot).
23
- #
24
- # ext - The String extension or original file.
25
- #
26
- # Returns The String output file extension.
17
+ # @param ext [String] the extension of the original file
18
+ # @return [String] The output file extension (including the dot)
27
19
  def output_ext(ext)
28
20
  ext
29
21
  end
@@ -22,7 +22,6 @@ module Bridgetown
22
22
  # @param convertible [
23
23
  # Bridgetown::GeneratedPage, Bridgetown::Resource::Base, Bridgetown::Layout]
24
24
  # The instantiated object which is processing the file.
25
- #
26
25
  # @return [String] The converted content.
27
26
  def convert(content, convertible)
28
27
  self.class.cached_partials ||= {}
@@ -55,17 +54,16 @@ module Bridgetown
55
54
  # rubocop: enable Metrics/MethodLength
56
55
  # rubocop: enable Metrics/AbcSize
57
56
 
58
- # Fetches the payload used in Liquid rendering.
59
- # Falls back to site.site_payload if no payload is set.
57
+ # Fetches the payload used in Liquid rendering, aka `site.site_payload`
60
58
  #
61
- # Returns a Bridgetown::Drops::UnifiedPayloadDrop
59
+ # @return [Bridgetown::Drops::UnifiedPayloadDrop]
62
60
  def payload
63
61
  @payload ||= site.site_payload
64
62
  end
65
63
 
66
64
  # Set page content to payload and assign paginator if document has one.
67
65
  #
68
- # Returns nothing
66
+ # @return [void]
69
67
  def configure_payload(content = nil)
70
68
  payload["page"] = document.to_liquid
71
69
  payload["paginator"] = document.respond_to?(:paginator) ? document.paginator.to_liquid : nil
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kramdown
4
- # A Kramdown::Document subclass meant to optimize memory usage from initializing
4
+ # A `Kramdown::Document`` subclass meant to optimize memory usage from initializing
5
5
  # a kramdown document for parsing.
6
6
  #
7
7
  # The optimization is by using the same options Hash (and its derivatives) for
@@ -43,26 +43,25 @@ module Bridgetown
43
43
  end
44
44
  # rubocop:enable Naming/AccessorMethodName
45
45
 
46
- # Public: Provides you with a list of processors comprised of the ones we support internally
46
+ # Provides you with a list of processors comprised of the ones we support internally
47
47
  # and the ones that you have provided to us
48
48
  #
49
- # Returns an array of symbols.
49
+ # @return [Array<Symbol>]
50
50
  def valid_processors
51
51
  [:kramdown] + third_party_processors
52
52
  end
53
53
 
54
- # Public: A list of processors that you provide via plugins.
54
+ # A list of processors that you provide via plugins
55
55
  #
56
- # Returns an array of symbols
56
+ # @return [Array<Symbol>]
57
57
  def third_party_processors
58
58
  self.class.constants - [:KramdownParser, :PRIORITIES]
59
59
  end
60
60
 
61
- # Logic to do the content conversion.
61
+ # Logic to do the content conversion
62
62
  #
63
- # content - String content of file (without front matter).
64
- #
65
- # Returns a String of the converted content.
63
+ # @param content [String] content of file (without front matter)
64
+ # @return [String] converted content
66
65
  def convert(content, convertible = nil)
67
66
  setup
68
67
  if @cache
@@ -85,13 +84,11 @@ module Bridgetown
85
84
  self.class.const_get(converter_name).new(@config) if custom_class_allowed?(converter_name)
86
85
  end
87
86
 
88
- # Private: Determine whether a class name is an allowed custom
89
- # markdown class name.
90
- #
91
- # parser_name - the name of the parser class
87
+ # Determine whether a class name is an allowed custom markdown class name.
92
88
  #
93
- # Returns true if the parser name contains only alphanumeric characters and is defined
94
- # within Bridgetown::Converters::Markdown
89
+ # @param parser_name [Symbol] name of the parser class
90
+ # @return [Boolean] true if the parser name contains only alphanumeric characters and is
91
+ # defined within `Bridgetown::Converters::Markdown`
95
92
  def custom_class_allowed?(parser_name)
96
93
  parser_name !~ %r![^A-Za-z0-9_]! && self.class.constants.include?(parser_name.to_sym)
97
94
  end
@@ -25,14 +25,13 @@ module Bridgetown
25
25
  template_engine :serbea
26
26
  input :serb
27
27
 
28
- # Logic to do the Serbea content conversion.
28
+ # Logic to do the Serbea content conversion
29
29
  #
30
- # @param content [String] Content of the file (without front matter).
30
+ # @param content [String] Content of the file (without front matter)
31
31
  # @param convertible [
32
32
  # Bridgetown::GeneratedPage, Bridgetown::Resource::Base, Bridgetown::Layout]
33
33
  # The instantiated object which is processing the file.
34
- #
35
- # @return [String] The converted content.
34
+ # @return [String] The converted content
36
35
  def convert(content, convertible)
37
36
  serb_view = Bridgetown::SerbeaView.new(convertible)
38
37
  serb_renderer = Tilt::SerbeaTemplate.new(
@@ -11,23 +11,22 @@ module Bridgetown
11
11
  # Mutability determines whether or not pre-defined fields may be
12
12
  # overwritten.
13
13
  #
14
- # is_mutable - Boolean set mutability of the class (default: nil)
14
+ # @param is_mutable [Boolean] set mutability of the class
15
15
  #
16
- # Returns the mutability of the class
16
+ # @return [Boolean] the mutability of the class
17
17
  def self.mutable(is_mutable = nil)
18
18
  @is_mutable = is_mutable || false
19
19
  end
20
20
 
21
+ # @return [Boolean] the mutability of the class
21
22
  def self.mutable?
22
23
  @is_mutable
23
24
  end
24
25
 
25
26
  # Create a new Drop
26
27
  #
27
- # obj - the Bridgetown Site, Collection, or Resource required by the
28
+ # @param obj [Object] the Bridgetown Site, Collection, or Resource required by the
28
29
  # drop.
29
- #
30
- # Returns nothing
31
30
  def initialize(obj) # rubocop:disable Lint/MissingSuper
32
31
  @obj = obj
33
32
  end
@@ -37,9 +36,8 @@ module Bridgetown
37
36
  # and finally check the underlying hash (e.g. document front matter)
38
37
  # if all the previous places didn't match.
39
38
  #
40
- # key - the string key whose value to fetch
41
- #
42
- # Returns the value for the given key, or nil if none exists
39
+ # @param key [String] key whose value to fetch
40
+ # @return [Object, nil] returns the value for the given key if present
43
41
  def [](key)
44
42
  if self.class.mutable? && mutations.key?(key)
45
43
  mutations[key]
@@ -51,26 +49,22 @@ module Bridgetown
51
49
  end
52
50
  alias_method :invoke_drop, :[]
53
51
 
54
- # Set a field in the Drop. If mutable, sets in the mutations and
55
- # returns. If not mutable, checks first if it's trying to override a
56
- # Drop method and raises a DropMutationException if so. If not
57
- # mutable and the key is not a method on the Drop, then it sets the
58
- # key to the value in the underlying hash (e.g. document front
59
- # matter)
52
+ # Set a field in the Drop. If mutable, sets in the mutations and returns. If not mutable,
53
+ # checks first if it's trying to override a Drop method and raises an exception if so.
54
+ # If not mutable and the key is not a method on the Drop, then it sets the key to the value
55
+ # in the underlying hash (e.g. document front matter)
60
56
  #
61
- # key - the String key whose value to set
62
- # val - the Object to set the key's value to
63
- #
64
- # Returns the value the key was set to unless the Drop is not mutable
65
- # and the key matches a method in which case it raises a
66
- # DropMutationException.
57
+ # @param key [String] key whose value to set
58
+ # @param val [Object] what to set the key's value to
59
+ # @return [Object] the value the key was set to unless the Drop is not mutable
60
+ # and the key matches a method in which case it raises an exception
67
61
  def []=(key, val)
68
62
  setter = "#{key}="
69
63
  if respond_to?(setter)
70
64
  public_send(setter, val)
71
65
  elsif respond_to?(key.to_s)
72
66
  unless self.class.mutable?
73
- raise Errors::DropMutationException, "Key #{key} cannot be set in the drop."
67
+ raise Errors::FatalException, "Key #{key} cannot be set in the drop."
74
68
  end
75
69
 
76
70
  mutations[key] = val
@@ -82,7 +76,7 @@ module Bridgetown
82
76
  # Generates a list of strings which correspond to content getter
83
77
  # methods.
84
78
  #
85
- # Returns an Array of strings which represent method-specific keys.
79
+ # @return [Array<String>] method-specific keys
86
80
  def content_methods
87
81
  @content_methods ||= (
88
82
  self.class.instance_methods \
@@ -95,9 +89,8 @@ module Bridgetown
95
89
 
96
90
  # Check if key exists in Drop
97
91
  #
98
- # key - the string key whose value to fetch
99
- #
100
- # Returns true if the given key is present
92
+ # @param key [String] key whose value to set
93
+ # @return [Boolean] true if the given key is present
101
94
  def key?(key)
102
95
  return false if key.nil?
103
96
  return true if self.class.mutable? && mutations.key?(key)
@@ -121,7 +114,7 @@ module Bridgetown
121
114
  # value. It includes Drop methods, mutations, and the underlying object's
122
115
  # data. See the documentation for Drop#keys for more.
123
116
  #
124
- # Returns a Hash with all the keys and values resolved.
117
+ # @return [Hash<String, Object>] all the keys and values resolved
125
118
  def to_h
126
119
  keys.each_with_object({}) do |(key, _), result|
127
120
  result[key] = self[key]
@@ -132,33 +125,27 @@ module Bridgetown
132
125
  # Inspect the drop's keys and values through a JSON representation
133
126
  # of its keys and values.
134
127
  #
135
- # Returns a pretty generation of the hash representation of the Drop.
128
+ # @return [String]
136
129
  def inspect
137
130
  JSON.pretty_generate to_h
138
131
  end
139
132
 
140
- # Generate a Hash for use in generating JSON.
141
- # This is useful if fields need to be cleared before the JSON can generate.
133
+ # Generate a Hash for use in generating JSON. Essentially an alias for `to_h`
142
134
  #
143
- # Returns a Hash ready for JSON generation.
135
+ # @return [Hash<String, Object>] all the keys and values resolved
144
136
  def hash_for_json(*)
145
137
  to_h
146
138
  end
147
139
 
148
- # Generate a JSON representation of the Drop.
140
+ # Generate a JSON representation of the Drop
149
141
  #
150
- # state - the JSON::State object which determines the state of current processing.
151
- #
152
- # Returns a JSON representation of the Drop in a String.
142
+ # @param state [JSON::State] object which determines the state of current processing
143
+ # @return [String] JSON representation of the Drop
153
144
  def to_json(state = nil)
154
145
  JSON.generate(hash_for_json(state), state)
155
146
  end
156
147
 
157
- # Collects all the keys and passes each to the block in turn.
158
- #
159
- # block - a block which accepts one argument, the key
160
- #
161
- # Returns nothing.
148
+ # Collects all the keys and passes each to the block in turn
162
149
  def each_key(&)
163
150
  keys.each(&)
164
151
  end
@@ -194,10 +181,10 @@ module Bridgetown
194
181
  end
195
182
  end
196
183
 
197
- # Imitate Hash.fetch method in Drop
184
+ # Imitate `Hash.fetch` method in Drop
198
185
  #
199
- # Returns value if key is present in Drop, otherwise returns default value
200
- # KeyError is raised if key is not present and no default value given
186
+ # @return [Object] value if key is present in Drop, otherwise returns default value.
187
+ # KeyError is raised if key is not present and no default value given
201
188
  def fetch(key, default = nil, &block)
202
189
  return self[key] if key?(key)
203
190
  raise KeyError, %(key not found: "#{key}") if default.nil? && block.nil?
@@ -58,9 +58,8 @@ module Bridgetown
58
58
  # Generate a Hash for use in generating JSON.
59
59
  # This is useful if fields need to be cleared before the JSON can generate.
60
60
  #
61
- # state - the JSON::State object which determines the state of current processing.
62
- #
63
- # Returns a Hash ready for JSON generation.
61
+ # @param state [JSON::State] object which determines the state of current processing
62
+ # @return [Hash<String, Object>] all the keys and values resolved
64
63
  def hash_for_json(state = nil)
65
64
  to_h.tap do |hash|
66
65
  # use collection label in the hash
@@ -76,19 +75,13 @@ module Bridgetown
76
75
  # Generate a Hash which breaks the recursive chain.
77
76
  # Certain fields which are normally available are omitted.
78
77
  #
79
- # Returns a Hash with only non-recursive fields present.
78
+ # @return [Hash<String, Object>] only non-recursive fields present
80
79
  def collapse_document(doc)
81
80
  doc.keys.each_with_object({}) do |(key, _), result|
82
81
  result[key] = doc[key] unless NESTED_OBJECT_FIELD_BLACKLIST.include?(key)
83
82
  end
84
83
  end
85
84
 
86
- # Generates a list of keys with user content as their values.
87
- # This gathers up the Drop methods and keys of the mutations and
88
- # underlying data hashes and performs a set union to ensure a list
89
- # of unique keys for the Drop.
90
- #
91
- # @return [Array<String>]
92
85
  def keys
93
86
  keys_to_remove = %w[next_resource previous_resource]
94
87
  (content_methods |
@@ -98,8 +91,6 @@ module Bridgetown
98
91
  end
99
92
  end
100
93
 
101
- # Inspect the drop's keys and values through a JSON representation
102
- # of its keys and values.
103
94
  def inspect
104
95
  JSON.pretty_generate hash_for_json
105
96
  end
@@ -4,16 +4,10 @@ module Bridgetown
4
4
  module Errors
5
5
  FatalException = Class.new(::RuntimeError)
6
6
 
7
- DropMutationException = Class.new(FatalException)
8
- InvalidPermalinkError = Class.new(FatalException)
9
- InvalidYAMLFrontMatterError = Class.new(FatalException)
10
- MissingDependencyException = Class.new(FatalException)
11
-
7
+ InvalidConfigurationError = Class.new(FatalException)
12
8
  InvalidDateError = Class.new(FatalException)
13
- InvalidPostNameError = Class.new(FatalException)
9
+ InvalidYAMLFrontMatterError = Class.new(FatalException)
14
10
  PostURLError = Class.new(FatalException)
15
- InvalidURLError = Class.new(FatalException)
16
- InvalidConfigurationError = Class.new(FatalException)
17
11
 
18
12
  def self.print_build_error(exc, trace: false, logger: Bridgetown.logger, server: false) # rubocop:todo Metrics
19
13
  logger.error "Exception raised:", exc.class.to_s.bold
@@ -2,10 +2,9 @@
2
2
 
3
3
  module Bridgetown
4
4
  module Filters
5
+ # The following set of code was *adapted* from `Liquid::If`
6
+ # ref: https://git.io/vp6K6
5
7
  module ConditionHelpers
6
- # ----------- The following set of code was *adapted* from Liquid::If
7
- # ----------- ref: https://git.io/vp6K6
8
-
9
8
  # Parse a string to a Liquid Condition
10
9
  def parse_condition(exp)
11
10
  parser = Liquid::Parser.new(exp)
@@ -19,9 +18,8 @@ module Bridgetown
19
18
  # the parsed expression based on whether the expression consists of binary operations with
20
19
  # Liquid operators `and` or `or`
21
20
  #
22
- # - parser: an instance of Liquid::Parser
23
- #
24
- # Returns an instance of Liquid::Condition
21
+ # @param parser [Liquid::Parser]
22
+ # @return [Liquid::Condition]
25
23
  def parse_binary_comparison(parser)
26
24
  condition = parse_comparison(parser)
27
25
  first_condition = condition
@@ -37,9 +35,8 @@ module Bridgetown
37
35
  # on whether the parsed expression involves a "comparison" operator
38
36
  # (e.g. <, ==, >, !=, etc)
39
37
  #
40
- # - parser: an instance of Liquid::Parser
41
- #
42
- # Returns an instance of Liquid::Condition
38
+ # @param parser [Liquid::Parser]
39
+ # @return [Liquid::Condition]
43
40
  def parse_comparison(parser)
44
41
  left_operand = Liquid::Expression.parse(parser.expression)
45
42
  operator = parser.consume?(:comparison)
@@ -8,12 +8,11 @@ module Bridgetown
8
8
  # (e.g. "27th Jan 2011") and US ("e.g. Jan 27th, 2011") formats.
9
9
  # UK format is the default.
10
10
  #
11
- # date - the Time to format.
12
- # type - if "ordinal" the returned String will be in ordinal format
13
- # style - if "US" the returned String will be in US format.
14
- # Otherwise it will be in UK format.
15
- #
16
- # Returns the formatting String.
11
+ # @param date [Time]
12
+ # @param type [String] if "ordinal" the returned String will be in ordinal format
13
+ # @param style [String] if "US" the returned String will be in US format.
14
+ # Otherwise it will be in UK format.
15
+ # @return [String]
17
16
  def date_to_string(date, type = nil, style = nil)
18
17
  stringify_date(date, "%b", type, style)
19
18
  end
@@ -23,42 +22,29 @@ module Bridgetown
23
22
  # (e.g. "27th January 2011") and US ("e.g. January 27th, 2011") formats.
24
23
  # UK format is the default.
25
24
  #
26
- # date - the Time to format.
27
- # type - if "ordinal" the returned String will be in ordinal format
28
- # style - if "US" the returned String will be in US format.
29
- # Otherwise it will be in UK format.
30
- #
31
- # Returns the formatted String.
25
+ # @param date [Time]
26
+ # @param type [String] if "ordinal" the returned String will be in ordinal format
27
+ # @param style [String] if "US" the returned String will be in US format.
28
+ # Otherwise it will be in UK format.
29
+ # @return [String]
32
30
  def date_to_long_string(date, type = nil, style = nil)
33
31
  stringify_date(date, "%B", type, style)
34
32
  end
35
33
 
36
- # Format a date for use in XML.
37
- #
38
- # date - The Time to format.
39
- #
40
- # Examples
41
- #
42
- # date_to_xmlschema(Time.now)
43
- # # => "2011-04-24T20:34:46+08:00"
34
+ # Format a date for use in XML, e.g. "2011-04-24T20:34:46+08:00"
44
35
  #
45
- # Returns the formatted String.
36
+ # @param date [Time]
37
+ # @return [String]
46
38
  def date_to_xmlschema(date)
47
39
  return date if date.to_s.empty?
48
40
 
49
41
  time(date).xmlschema
50
42
  end
51
43
 
52
- # Format a date according to RFC-822
44
+ # Format a date according to RFC-822, e.g. "Sun, 24 Apr 2011 12:34:46 +0000"
53
45
  #
54
- # date - The Time to format.
55
- #
56
- # Examples
57
- #
58
- # date_to_rfc822(Time.now)
59
- # # => "Sun, 24 Apr 2011 12:34:46 +0000"
60
- #
61
- # Returns the formatted String.
46
+ # @param date [Time]
47
+ # @return [String]
62
48
  def date_to_rfc822(date)
63
49
  return date if date.to_s.empty?
64
50
 
@@ -67,11 +53,12 @@ module Bridgetown
67
53
 
68
54
  private
69
55
 
70
- # month_type: Notations that evaluate to 'Month' via `Time#strftime` ("%b", "%B")
71
- # type: nil (default) or "ordinal"
72
- # style: nil (default) or "US"
73
- #
74
- # Returns a stringified date or the empty input.
56
+ # @param date [Time]
57
+ # @param month_type [String] notations that evaluate to 'Month' via `Time#strftime`
58
+ # ("%b", "%B")
59
+ # @param type [String]
60
+ # @param style [String]
61
+ # @return [String]
75
62
  def stringify_date(date, month_type, type = nil, style = nil)
76
63
  return date if date.to_s.empty?
77
64