govuk_tech_docs 2.0.7 → 2.0.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 382dfb39d87e905ae4d6c36c5034d159446b5959e69d66108adabddd8aa979a3
4
- data.tar.gz: b5ca8f8782e02ed3c6397fcbd07c2cf506315f0bde5a5bd257ca394ed9f196e0
3
+ metadata.gz: c0b123cc9f0def3edb572706b6a436e5f13077651bb2707fed1e367b5c5c7941
4
+ data.tar.gz: 7e1d5525805495efbec0b8c3192eba9022763f557df3a7a4d31b5a6ae419697e
5
5
  SHA512:
6
- metadata.gz: 5e25407531d21cba8580cf15b0d2cc1093a596dfe241d1893d6635a3790c818d2b035b478d4deb6d3a87b2e8b98a91f56937d0a56fbd6f10c11e62118c37d3b5
7
- data.tar.gz: 5a53a4c55a8bb130189d974bc21f8eb4e003c6a1f59da998a35258b35a4d1b3f8b192bdf233dcbb2f70510f25a5b3d330bf1d3da5c27ff976eb4919d493a4512
6
+ metadata.gz: e6db970cf21bff4276d957b6db10df14c160cf361169be7a6c131de6a69c93ba1e8da3f856cfa10a28e14b28f453202ec91f60c34424775e2642c8ca5638c5bd
7
+ data.tar.gz: 1db9a29bc0833e07f7b06c57fa7e3bc93fdf5b8c11bd682edfbe925f4244470e456104f23c7be3f58c6858c5d6ce8f380834fd4dfcc11c8a005a62ef9e2e9cf7
@@ -1,3 +1,7 @@
1
+ inherit_gem:
2
+ rubocop-govuk:
3
+ - config/default.yml
4
+
1
5
  Layout/IndentHeredoc:
2
6
  Enabled: false
3
7
 
@@ -6,6 +10,3 @@ Naming/HeredocDelimiterNaming:
6
10
 
7
11
  Lint/NestedMethodDefinition:
8
12
  Enabled: false
9
-
10
- Performance/HashEachMethods:
11
- Enabled: false
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.8
4
+
5
+ Use of `govuk-lint` replaced with `rubocop-govuk` due to the former [becoming deprecated](https://github.com/alphagov/govuk-lint/pull/133).
6
+
3
7
  ## 2.0.7
4
8
 
5
9
  A small release to fix an issue where code blocks font size was too large on some browsers.
data/Rakefile CHANGED
@@ -1,14 +1,14 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
- require 'jasmine'
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "jasmine"
4
4
 
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
 
7
- load 'jasmine/tasks/jasmine.rake'
7
+ load "jasmine/tasks/jasmine.rake"
8
8
 
9
9
  task :lint do
10
- sh "govuk-lint-ruby example lib spec Rakefile"
10
+ sh "rubocop example lib spec Rakefile"
11
11
  sh "npm run lint --silent"
12
12
  end
13
13
 
14
- task default: ['lint', 'spec', 'jasmine:ci']
14
+ task default: ["lint", "spec", "jasmine:ci"]
@@ -80,5 +80,5 @@ default_owner_slack: '#owner'
80
80
 
81
81
  The expiry date for each page is also shown in the `/api/pages.json`
82
82
  representation of all pages. This is used by the
83
- [tech-docs-notifier](https://github.com/alphagov/tech-docs-notifier) to post
83
+ [tech-docs-monitor](https://github.com/alphagov/tech-docs-monitor) to post
84
84
  messages to Slack when pages have expired.
@@ -1,3 +1,3 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- gem 'govuk_tech_docs', path: '..'
3
+ gem "govuk_tech_docs", path: ".."
@@ -1,9 +1,9 @@
1
- require 'govuk_tech_docs'
1
+ require "govuk_tech_docs"
2
2
 
3
3
  GovukTechDocs.configure(self)
4
4
 
5
- ignore 'templates/*'
5
+ ignore "templates/*"
6
6
 
7
- proxy '/a-proxied-page.html', 'templates/proxy_template.html', locals: {
8
- title: 'I am a title'
7
+ proxy "/a-proxied-page.html", "templates/proxy_template.html", locals: {
8
+ title: "I am a title",
9
9
  }
@@ -52,7 +52,7 @@ Gem::Specification.new do |spec|
52
52
  spec.add_development_dependency "bundler", "~> 2.0.1"
53
53
  spec.add_development_dependency "rake", "~> 10.0"
54
54
  spec.add_development_dependency "capybara", "~> 2.18.0"
55
- spec.add_development_dependency "govuk-lint", "~> 3.11.5"
55
+ spec.add_development_dependency "rubocop-govuk", "~> 1.0.0"
56
56
  spec.add_development_dependency "jasmine", "~> 3.1.0"
57
57
  spec.add_development_dependency "rspec", "~> 3.7.0"
58
58
  spec.add_development_dependency "byebug"
@@ -1,27 +1,27 @@
1
- require 'govuk_tech_docs/version'
2
-
3
- require 'middleman'
4
- require 'middleman-autoprefixer'
5
- require 'middleman-sprockets'
6
- require 'middleman-livereload'
7
- require 'middleman-syntax'
8
- require 'middleman-search'
9
-
10
- require 'nokogiri'
11
- require 'chronic'
12
- require 'active_support/all'
13
-
14
- require 'govuk_tech_docs/redirects'
15
- require 'govuk_tech_docs/table_of_contents/helpers'
16
- require 'govuk_tech_docs/contribution_banner'
17
- require 'govuk_tech_docs/meta_tags'
18
- require 'govuk_tech_docs/page_review'
19
- require 'govuk_tech_docs/pages'
20
- require 'govuk_tech_docs/tech_docs_html_renderer'
21
- require 'govuk_tech_docs/unique_identifier_extension'
22
- require 'govuk_tech_docs/unique_identifier_generator'
23
- require 'govuk_tech_docs/warning_text_extension'
24
- require 'govuk_tech_docs/api_reference/api_reference_extension'
1
+ require "govuk_tech_docs/version"
2
+
3
+ require "middleman"
4
+ require "middleman-autoprefixer"
5
+ require "middleman-sprockets"
6
+ require "middleman-livereload"
7
+ require "middleman-syntax"
8
+ require "middleman-search"
9
+
10
+ require "nokogiri"
11
+ require "chronic"
12
+ require "active_support/all"
13
+
14
+ require "govuk_tech_docs/redirects"
15
+ require "govuk_tech_docs/table_of_contents/helpers"
16
+ require "govuk_tech_docs/contribution_banner"
17
+ require "govuk_tech_docs/meta_tags"
18
+ require "govuk_tech_docs/page_review"
19
+ require "govuk_tech_docs/pages"
20
+ require "govuk_tech_docs/tech_docs_html_renderer"
21
+ require "govuk_tech_docs/unique_identifier_extension"
22
+ require "govuk_tech_docs/unique_identifier_generator"
23
+ require "govuk_tech_docs/warning_text_extension"
24
+ require "govuk_tech_docs/api_reference/api_reference_extension"
25
25
 
26
26
  module GovukTechDocs
27
27
  # Configure the tech docs template
@@ -32,8 +32,8 @@ module GovukTechDocs
32
32
  def self.configure(context, options = {})
33
33
  context.activate :sprockets
34
34
 
35
- context.sprockets.append_path File.join(__dir__, '../node_modules/govuk-frontend/')
36
- context.sprockets.append_path File.join(__dir__, './source')
35
+ context.sprockets.append_path File.join(__dir__, "../node_modules/govuk-frontend/")
36
+ context.sprockets.append_path File.join(__dir__, "./source")
37
37
 
38
38
  context.activate :syntax
39
39
 
@@ -44,7 +44,7 @@ module GovukTechDocs
44
44
  renderer: TechDocsHTMLRenderer.new(
45
45
  with_toc_data: true,
46
46
  api: true,
47
- context: context
47
+ context: context,
48
48
  ),
49
49
  fenced_code_blocks: true,
50
50
  tables: true,
@@ -57,10 +57,10 @@ module GovukTechDocs
57
57
 
58
58
  context.configure :build do
59
59
  activate :autoprefixer
60
- activate :minify_javascript, ignore: ['/raw_assets/*']
60
+ activate :minify_javascript, ignore: ["/raw_assets/*"]
61
61
  end
62
62
 
63
- config_file = ENV.fetch('CONFIG_FILE', 'config/tech-docs.yml')
63
+ config_file = ENV.fetch("CONFIG_FILE", "config/tech-docs.yml")
64
64
  context.config[:tech_docs] = YAML.load_file(config_file).with_indifferent_access
65
65
  context.activate :unique_identifier
66
66
  context.activate :warning_text
@@ -79,7 +79,7 @@ module GovukTechDocs
79
79
  end
80
80
 
81
81
  def format_date(date)
82
- date.strftime('%-e %B %Y')
82
+ date.strftime("%-e %B %Y")
83
83
  end
84
84
 
85
85
  def active_page(page_path)
@@ -91,9 +91,9 @@ module GovukTechDocs
91
91
  end
92
92
  end
93
93
 
94
- context.page '/*.xml', layout: false
95
- context.page '/*.json', layout: false
96
- context.page '/*.txt', layout: false
94
+ context.page "/*.xml", layout: false
95
+ context.page "/*.json", layout: false
96
+ context.page "/*.txt", layout: false
97
97
 
98
98
  context.ready do
99
99
  redirects = GovukTechDocs::Redirects.new(context).redirects
@@ -105,7 +105,7 @@ module GovukTechDocs
105
105
 
106
106
  if context.config[:tech_docs][:enable_search]
107
107
  context.activate :search do |search|
108
- search.resources = ['']
108
+ search.resources = [""]
109
109
 
110
110
  search.fields = {
111
111
  title: { boost: 100, store: true, required: true },
@@ -1,8 +1,8 @@
1
- require 'erb'
2
- require 'openapi3_parser'
3
- require 'uri'
4
- require 'pry'
5
- require 'govuk_tech_docs/api_reference/api_reference_renderer'
1
+ require "erb"
2
+ require "openapi3_parser"
3
+ require "uri"
4
+ require "pry"
5
+ require "govuk_tech_docs/api_reference/api_reference_renderer"
6
6
 
7
7
  module GovukTechDocs
8
8
  module ApiReference
@@ -16,22 +16,22 @@ module GovukTechDocs
16
16
  @config = @app.config[:tech_docs]
17
17
 
18
18
  # If no api path then just return.
19
- if @config['api_path'].to_s.empty?
19
+ if @config["api_path"].to_s.empty?
20
20
  @api_parser = false
21
21
  return
22
22
  end
23
23
 
24
24
  # Is the api_path a url or path?
25
- if uri?(@config['api_path'])
25
+ if uri?(@config["api_path"])
26
26
  @api_parser = true
27
- @document = Openapi3Parser.load_url(@config['api_path'])
28
- elsif File.exist?(@config['api_path'])
27
+ @document = Openapi3Parser.load_url(@config["api_path"])
28
+ elsif File.exist?(@config["api_path"])
29
29
  # Load api file and set existence flag.
30
30
  @api_parser = true
31
- @document = Openapi3Parser.load_file(@config['api_path'])
31
+ @document = Openapi3Parser.load_file(@config["api_path"])
32
32
  else
33
33
  @api_parser = false
34
- raise 'Unable to load api path from tech-docs.yml'
34
+ raise "Unable to load api path from tech-docs.yml"
35
35
  end
36
36
  @render = Renderer.new(@app, @document)
37
37
  end
@@ -49,26 +49,26 @@ module GovukTechDocs
49
49
  if @api_parser == true
50
50
 
51
51
  keywords = {
52
- 'api>' => 'default',
53
- 'api_schema>' => 'schema'
52
+ "api>" => "default",
53
+ "api_schema>" => "schema",
54
54
  }
55
55
 
56
- regexp = keywords.map { |k, _| Regexp.escape(k) }.join('|')
56
+ regexp = keywords.map { |k, _| Regexp.escape(k) }.join("|")
57
57
 
58
58
  md = text.match(/^<p>(#{regexp})/)
59
59
  if md
60
60
  key = md.captures[0]
61
61
  type = keywords[key]
62
62
 
63
- text.gsub!(/#{Regexp.escape(key)}\s+?/, '')
63
+ text.gsub!(/#{Regexp.escape(key)}\s+?/, "")
64
64
 
65
65
  # Strip paragraph tags from text
66
- text = text.gsub(/<\/?[^>]*>/, '')
66
+ text = text.gsub(/<\/?[^>]*>/, "")
67
67
  text = text.strip
68
68
 
69
- if text == 'api&gt;'
69
+ if text == "api&gt;"
70
70
  @render.api_full(api_info, api_servers)
71
- elsif type == 'default'
71
+ elsif type == "default"
72
72
  output = @render.path(text)
73
73
  # Render any schemas referenced in the above path
74
74
  output += @render.schemas_from_path(text)
@@ -1,5 +1,5 @@
1
- require 'erb'
2
- require 'json'
1
+ require "erb"
2
+ require "json"
3
3
 
4
4
  module GovukTechDocs
5
5
  module ApiReference
@@ -9,16 +9,16 @@ module GovukTechDocs
9
9
  @document = document
10
10
 
11
11
  # Load template files
12
- @template_api_full = get_renderer('api_reference_full.html.erb')
13
- @template_path = get_renderer('path.html.erb')
14
- @template_schema = get_renderer('schema.html.erb')
15
- @template_operation = get_renderer('operation.html.erb')
16
- @template_parameters = get_renderer('parameters.html.erb')
17
- @template_responses = get_renderer('responses.html.erb')
12
+ @template_api_full = get_renderer("api_reference_full.html.erb")
13
+ @template_path = get_renderer("path.html.erb")
14
+ @template_schema = get_renderer("schema.html.erb")
15
+ @template_operation = get_renderer("operation.html.erb")
16
+ @template_parameters = get_renderer("parameters.html.erb")
17
+ @template_responses = get_renderer("responses.html.erb")
18
18
  end
19
19
 
20
20
  def api_full(info, servers)
21
- paths = ''
21
+ paths = ""
22
22
  paths_data = @document.paths
23
23
  paths_data.each do |path_data|
24
24
  # For some reason paths.each returns an array of arrays [title, object]
@@ -26,7 +26,7 @@ module GovukTechDocs
26
26
  text = path_data[0]
27
27
  paths += path(text)
28
28
  end
29
- schemas = ''
29
+ schemas = ""
30
30
  schemas_data = @document.components.schemas
31
31
  schemas_data.each do |schema_data|
32
32
  text = schema_data[0]
@@ -43,7 +43,7 @@ module GovukTechDocs
43
43
  end
44
44
 
45
45
  def schema(text)
46
- schemas = ''
46
+ schemas = ""
47
47
  schemas_data = @document.components.schemas
48
48
  schemas_data.each do |schema_data|
49
49
  all_of = schema_data[1]["allOf"]
@@ -76,8 +76,8 @@ module GovukTechDocs
76
76
  operations.compact.each_value do |operation|
77
77
  responses = operation.responses
78
78
  responses.each do |_rkey, response|
79
- if response.content['application/json']
80
- schema = response.content['application/json'].schema
79
+ if response.content["application/json"]
80
+ schema = response.content["application/json"].schema
81
81
  schema_name = get_schema_name(schema.node_context.source_location.to_s)
82
82
  if !schema_name.nil?
83
83
  schemas.push schema_name
@@ -87,7 +87,7 @@ module GovukTechDocs
87
87
  end
88
88
  end
89
89
  # Render all referenced schemas
90
- output = ''
90
+ output = ""
91
91
  schemas.uniq.each do |schema_name|
92
92
  output += schema(schema_name)
93
93
  end
@@ -103,7 +103,7 @@ module GovukTechDocs
103
103
  schema.properties.each do |property|
104
104
  properties.push property[1]
105
105
  end
106
- if schema.type == 'array'
106
+ if schema.type == "array"
107
107
  properties.push schema.items
108
108
  end
109
109
  all_of = schema["allOf"]
@@ -117,8 +117,8 @@ module GovukTechDocs
117
117
  properties.each do |property|
118
118
  # Must be a schema be referenced by another schema
119
119
  # And not a property of a schema
120
- if property.node_context.referenced_by.to_s.include?('#/components/schemas') &&
121
- !property.node_context.source_location.to_s.include?('/properties/')
120
+ if property.node_context.referenced_by.to_s.include?("#/components/schemas") &&
121
+ !property.node_context.source_location.to_s.include?("/properties/")
122
122
  schema_name = get_schema_name(property.node_context.source_location.to_s)
123
123
  end
124
124
  if !schema_name.nil?
@@ -131,7 +131,7 @@ module GovukTechDocs
131
131
  end
132
132
 
133
133
  def operations(path, path_id)
134
- output = ''
134
+ output = ""
135
135
  operations = get_operations(path)
136
136
  operations.compact.each do |key, operation|
137
137
  id = "#{path_id}-#{key.parameterize}"
@@ -158,7 +158,7 @@ module GovukTechDocs
158
158
 
159
159
  def markdown(text)
160
160
  if text
161
- Tilt['markdown'].new(context: @app) { text }.render
161
+ Tilt["markdown"].new(context: @app) { text }.render
162
162
  end
163
163
  end
164
164
 
@@ -181,7 +181,7 @@ module GovukTechDocs
181
181
  properties.merge! get_all_of_hash(schema_data)
182
182
  properties_hash = Hash.new
183
183
  properties.each do |pkey, property|
184
- if property.type == 'object'
184
+ if property.type == "object"
185
185
  properties_hash[pkey] = Hash.new
186
186
  items = property.items
187
187
  if !items.blank?
@@ -190,7 +190,7 @@ module GovukTechDocs
190
190
  if !property.properties.blank?
191
191
  properties_hash[pkey] = schema_properties(property)
192
192
  end
193
- elsif property.type == 'array'
193
+ elsif property.type == "array"
194
194
  properties_hash[pkey] = Array.new
195
195
  items = property.items
196
196
  if !items.blank?
@@ -243,18 +243,18 @@ module GovukTechDocs
243
243
  end
244
244
 
245
245
  def get_renderer(file)
246
- template_path = File.join(File.dirname(__FILE__), 'templates/' + file)
247
- template = File.open(template_path, 'r').read
246
+ template_path = File.join(File.dirname(__FILE__), "templates/" + file)
247
+ template = File.open(template_path, "r").read
248
248
  ERB.new(template)
249
249
  end
250
250
 
251
251
  def get_operations(path)
252
252
  operations = {}
253
- operations['get'] = path.get if defined? path.get
254
- operations['put'] = path.put if defined? path.put
255
- operations['post'] = path.post if defined? path.post
256
- operations['delete'] = path.delete if defined? path.delete
257
- operations['patch'] = path.patch if defined? path.patch
253
+ operations["get"] = path.get if defined? path.get
254
+ operations["put"] = path.put if defined? path.put
255
+ operations["post"] = path.post if defined? path.post
256
+ operations["delete"] = path.delete if defined? path.delete
257
+ operations["patch"] = path.patch if defined? path.patch
258
258
  operations
259
259
  end
260
260
 
@@ -264,7 +264,7 @@ module GovukTechDocs
264
264
  end
265
265
 
266
266
  # Schema dictates that it's always components['schemas']
267
- text.gsub(/#\/components\/schemas\//, '')
267
+ text.gsub(/#\/components\/schemas\//, "")
268
268
  end
269
269
 
270
270
  def get_schema_link(schema)
@@ -33,7 +33,7 @@ module GovukTechDocs
33
33
  end
34
34
 
35
35
  def repo_branch
36
- config[:tech_docs][:github_branch] || 'master'
36
+ config[:tech_docs][:github_branch] || "master"
37
37
  end
38
38
 
39
39
  private
@@ -7,25 +7,25 @@ module GovukTechDocs
7
7
 
8
8
  def tags
9
9
  all_tags = {
10
- 'description' => page_description,
11
- 'og:description' => page_description,
12
- 'og:image' => page_image,
13
- 'og:site_name' => site_name,
14
- 'og:title' => page_title,
15
- 'og:type' => 'object',
16
- 'og:url' => canonical_url,
17
- 'twitter:card' => 'summary',
18
- 'twitter:domain' => URI.parse(host).host,
19
- 'twitter:image' => page_image,
20
- 'twitter:title' => browser_title,
21
- 'twitter:url' => canonical_url,
10
+ "description" => page_description,
11
+ "og:description" => page_description,
12
+ "og:image" => page_image,
13
+ "og:site_name" => site_name,
14
+ "og:title" => page_title,
15
+ "og:type" => "object",
16
+ "og:url" => canonical_url,
17
+ "twitter:card" => "summary",
18
+ "twitter:domain" => URI.parse(host).host,
19
+ "twitter:image" => page_image,
20
+ "twitter:title" => browser_title,
21
+ "twitter:url" => canonical_url,
22
22
  }
23
23
 
24
24
  Hash[all_tags.select { |_k, v| v }]
25
25
  end
26
26
 
27
27
  def browser_title
28
- [page_title, site_name].select(&:present?).uniq.join(' | ')
28
+ [page_title, site_name].select(&:present?).uniq.join(" | ")
29
29
  end
30
30
 
31
31
  def canonical_url
@@ -12,7 +12,7 @@ module GovukTechDocs
12
12
 
13
13
  @review_by ||= Chronic.parse(
14
14
  "in #{page.data.review_in}",
15
- now: last_reviewed_on.to_time
15
+ now: last_reviewed_on.to_time,
16
16
  ).to_date
17
17
  end
18
18
 
@@ -32,7 +32,7 @@ module GovukTechDocs
32
32
  return "" unless owner_slack_workspace
33
33
 
34
34
  # Slack URLs don't have the # (channels) or @ (usernames)
35
- slack_identifier = owner_slack.to_s.delete('#').delete('@')
35
+ slack_identifier = owner_slack.to_s.delete("#").delete("@")
36
36
  "https://#{owner_slack_workspace}.slack.com/messages/#{slack_identifier}"
37
37
  end
38
38
 
@@ -11,7 +11,7 @@ module GovukTechDocs
11
11
 
12
12
  all_redirects.map do |from, to|
13
13
  # Middleman needs paths without leading slashes
14
- [from.sub(LEADING_SLASH, ''), to: to.sub(LEADING_SLASH, '')]
14
+ [from.sub(LEADING_SLASH, ""), to: to.sub(LEADING_SLASH, "")]
15
15
  end
16
16
  end
17
17
 
@@ -1,7 +1,7 @@
1
1
  module GovukTechDocs
2
2
  module TableOfContents
3
3
  class Heading
4
- def initialize(element_name:, text:, attributes:, page_url: '')
4
+ def initialize(element_name:, text:, attributes:, page_url: "")
5
5
  @element_name = element_name
6
6
  @text = text
7
7
  @attributes = attributes
@@ -13,7 +13,7 @@ module GovukTechDocs
13
13
  end
14
14
 
15
15
  def href
16
- @page_url + '#' + @attributes['id']
16
+ @page_url + "#" + @attributes["id"]
17
17
  end
18
18
 
19
19
  def title
@@ -2,8 +2,8 @@ module GovukTechDocs
2
2
  module TableOfContents
3
3
  class HeadingTreeRenderer
4
4
  DEFAULT_MAX_LEVEL = Float::INFINITY
5
- DEFAULT_INDENTATION = ''.freeze
6
- INDENTATION_INCREMENT = ' '.freeze
5
+ DEFAULT_INDENTATION = "".freeze
6
+ INDENTATION_INCREMENT = " ".freeze
7
7
 
8
8
  def initialize(heading_tree, max_level: nil)
9
9
  @heading_tree = heading_tree
@@ -17,7 +17,7 @@ module GovukTechDocs
17
17
  private
18
18
 
19
19
  def render_tree(tree, indentation: DEFAULT_INDENTATION, level: nil)
20
- output = ''
20
+ output = ""
21
21
 
22
22
  if tree.heading
23
23
  output += indentation + %{<a href="#{tree.heading.href}"><span>#{tree.heading.title}</span></a>\n}
@@ -31,7 +31,7 @@ module GovukTechDocs
31
31
  output += render_tree(
32
32
  child,
33
33
  indentation: indentation + INDENTATION_INCREMENT * 2,
34
- level: level + 1
34
+ level: level + 1,
35
35
  )
36
36
  output += indentation + INDENTATION_INCREMENT + "</li>\n"
37
37
  end
@@ -12,7 +12,7 @@ module GovukTechDocs
12
12
  element_name: element.node_name,
13
13
  text: element.content,
14
14
  attributes: convert_nokogiri_attr_objects_to_hashes(element.attributes),
15
- page_url: @url
15
+ page_url: @url,
16
16
  )
17
17
  end
18
18
  end
@@ -24,7 +24,7 @@ module GovukTechDocs
24
24
  end
25
25
 
26
26
  def heading_elements
27
- page.search('h1, h2, h3, h4, h5, h6')
27
+ page.search("h1, h2, h3, h4, h5, h6")
28
28
  end
29
29
 
30
30
  def convert_nokogiri_attr_objects_to_hashes(attributes)
@@ -1,13 +1,13 @@
1
- require 'govuk_tech_docs/table_of_contents/heading_tree_builder'
2
- require 'govuk_tech_docs/table_of_contents/heading_tree_renderer'
3
- require 'govuk_tech_docs/table_of_contents/heading_tree'
4
- require 'govuk_tech_docs/table_of_contents/heading'
5
- require 'govuk_tech_docs/table_of_contents/headings_builder'
1
+ require "govuk_tech_docs/table_of_contents/heading_tree_builder"
2
+ require "govuk_tech_docs/table_of_contents/heading_tree_renderer"
3
+ require "govuk_tech_docs/table_of_contents/heading_tree"
4
+ require "govuk_tech_docs/table_of_contents/heading"
5
+ require "govuk_tech_docs/table_of_contents/headings_builder"
6
6
 
7
7
  module GovukTechDocs
8
8
  module TableOfContents
9
9
  module Helpers
10
- def single_page_table_of_contents(html, url: '', max_level: nil)
10
+ def single_page_table_of_contents(html, url: "", max_level: nil)
11
11
  headings = HeadingsBuilder.new(html, url).headings
12
12
 
13
13
  if headings.none? { |heading| heading.size == 1 }
@@ -32,7 +32,7 @@ module GovukTechDocs
32
32
  # Sort by weight frontmatter
33
33
  resources = resources
34
34
  .sort_by { |r| [r.data.weight ? 0 : 1, r.data.weight || 0] }
35
- output = '';
35
+ output = "";
36
36
  resources.each do |resource|
37
37
  # Skip from page tree if hide_in_navigation:true frontmatter
38
38
  next if resource.data.hide_in_navigation
@@ -65,13 +65,13 @@ module GovukTechDocs
65
65
  if resource.children.any? && resource.url != home_url
66
66
  output += %{<ul><li><a href="#{resource.url}"><span>#{resource.data.title}</span></a>\n}
67
67
  output += render_page_tree(resource.children, current_page, config, current_page_html)
68
- output += '</li></ul>'
68
+ output += "</li></ul>"
69
69
  else
70
70
  output +=
71
71
  single_page_table_of_contents(
72
72
  content,
73
73
  url: resource.url,
74
- max_level: config[:tech_docs][:max_toc_heading_level]
74
+ max_level: config[:tech_docs][:max_toc_heading_level],
75
75
  )
76
76
  end
77
77
  end
@@ -1,4 +1,4 @@
1
- require 'middleman-core/renderers/redcarpet'
1
+ require "middleman-core/renderers/redcarpet"
2
2
 
3
3
  module GovukTechDocs
4
4
  class TechDocsHTMLRenderer < Middleman::Renderers::MiddlemanRedcarpetHTML
@@ -1,4 +1,4 @@
1
- require 'singleton'
1
+ require "singleton"
2
2
 
3
3
  module GovukTechDocs
4
4
  class UniqueIdentifierGenerator
@@ -64,9 +64,9 @@ module GovukTechDocs
64
64
  text
65
65
  .downcase
66
66
  .strip
67
- .gsub(%r{</?[^>]+?>}, '') # Remove HTML tags
68
- .gsub(/[^0-9a-z]+/, '-') # Replace non-alphanumeric characters with dashes
69
- .gsub(/\A-+|-+\z/, '') # Remove trailing dashes
67
+ .gsub(%r{</?[^>]+?>}, "") # Remove HTML tags
68
+ .gsub(/[^0-9a-z]+/, "-") # Replace non-alphanumeric characters with dashes
69
+ .gsub(/\A-+|-+\z/, "") # Remove trailing dashes
70
70
  end
71
71
  end
72
72
  end
@@ -1,3 +1,3 @@
1
1
  module GovukTechDocs
2
- VERSION = "2.0.7".freeze
2
+ VERSION = "2.0.8".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_tech_docs
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.7
4
+ version: 2.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Government Digital Service
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-21 00:00:00.000000000 Z
11
+ date: 2019-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -263,19 +263,19 @@ dependencies:
263
263
  - !ruby/object:Gem::Version
264
264
  version: 2.18.0
265
265
  - !ruby/object:Gem::Dependency
266
- name: govuk-lint
266
+ name: rubocop-govuk
267
267
  requirement: !ruby/object:Gem::Requirement
268
268
  requirements:
269
269
  - - "~>"
270
270
  - !ruby/object:Gem::Version
271
- version: 3.11.5
271
+ version: 1.0.0
272
272
  type: :development
273
273
  prerelease: false
274
274
  version_requirements: !ruby/object:Gem::Requirement
275
275
  requirements:
276
276
  - - "~>"
277
277
  - !ruby/object:Gem::Version
278
- version: 3.11.5
278
+ version: 1.0.0
279
279
  - !ruby/object:Gem::Dependency
280
280
  name: jasmine
281
281
  requirement: !ruby/object:Gem::Requirement