govuk_tech_docs 2.4.2 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of govuk_tech_docs might be problematic. Click here for more details.

Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +13 -0
  3. data/.github/pull_request_template.md +14 -1
  4. data/.github/workflows/publish.yaml +76 -0
  5. data/.github/workflows/test.yaml +23 -0
  6. data/.nvmrc +1 -1
  7. data/CHANGELOG.md +39 -0
  8. data/README.md +15 -1
  9. data/lib/assets/javascripts/_modules/search.js +59 -66
  10. data/lib/assets/javascripts/_modules/table-of-contents.js +0 -1
  11. data/lib/assets/javascripts/_vendor/jquery.js +2 -5
  12. data/lib/assets/javascripts/_vendor/lodash.js +5 -3
  13. data/lib/assets/stylesheets/modules/_search.scss +51 -73
  14. data/lib/assets/stylesheets/modules/_technical-documentation.scss +0 -4
  15. data/lib/assets/stylesheets/modules/_toc.scss +0 -3
  16. data/lib/govuk_tech_docs/api_reference/api_reference_renderer.rb +10 -0
  17. data/lib/govuk_tech_docs/api_reference/templates/api_reference_full.html.erb +2 -2
  18. data/lib/govuk_tech_docs/api_reference/templates/operation.html.erb +1 -1
  19. data/lib/govuk_tech_docs/api_reference/templates/parameters.html.erb +1 -1
  20. data/lib/govuk_tech_docs/api_reference/templates/responses.html.erb +1 -1
  21. data/lib/govuk_tech_docs/api_reference/templates/schema.html.erb +2 -2
  22. data/lib/govuk_tech_docs/contribution_banner.rb +8 -2
  23. data/lib/govuk_tech_docs/version.rb +1 -1
  24. data/lib/govuk_tech_docs.rb +3 -1
  25. data/lib/source/layouts/_header.erb +3 -3
  26. data/lib/source/layouts/_search.erb +0 -7
  27. data/lib/source/layouts/core.erb +1 -1
  28. data/lib/source/search/index.html.erb +31 -0
  29. data/node_modules/govuk-frontend/govuk/all.js +272 -75
  30. data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +275 -98
  31. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +169 -65
  32. data/node_modules/govuk-frontend/govuk/components/button/_index.scss +3 -4
  33. data/node_modules/govuk-frontend/govuk/components/button/button.js +2 -2
  34. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +3 -3
  35. data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +14 -0
  36. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +8 -10
  37. data/node_modules/govuk-frontend/govuk/components/cookie-banner/_index.scss +0 -2
  38. data/node_modules/govuk-frontend/govuk/components/details/_index.scss +2 -1
  39. data/node_modules/govuk-frontend/govuk/components/details/details.js +2 -2
  40. data/node_modules/govuk-frontend/govuk/components/error-message/_index.scss +1 -0
  41. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +2 -2
  42. data/node_modules/govuk-frontend/govuk/components/file-upload/_index.scss +1 -0
  43. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +6 -37
  44. data/node_modules/govuk-frontend/govuk/components/header/_index.scss +10 -4
  45. data/node_modules/govuk-frontend/govuk/components/header/header.js +4 -4
  46. data/node_modules/govuk-frontend/govuk/components/hint/_index.scss +1 -3
  47. data/node_modules/govuk-frontend/govuk/components/input/_index.scss +1 -1
  48. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +499 -2
  49. data/node_modules/govuk-frontend/govuk/components/panel/_index.scss +13 -1
  50. data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +14 -0
  51. data/node_modules/govuk-frontend/govuk/components/radios/radios.js +4 -4
  52. data/node_modules/govuk-frontend/govuk/components/select/_index.scss +1 -1
  53. data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +13 -0
  54. data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +1108 -0
  55. data/node_modules/govuk-frontend/govuk/components/summary-list/_index.scss +15 -23
  56. data/node_modules/govuk-frontend/govuk/components/tabs/_index.scss +2 -2
  57. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +2 -2
  58. data/node_modules/govuk-frontend/govuk/components/tag/_index.scss +0 -5
  59. data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +1 -1
  60. data/node_modules/govuk-frontend/govuk/core/_all.scss +0 -1
  61. data/node_modules/govuk-frontend/govuk/core/_global-styles.scss +0 -6
  62. data/node_modules/govuk-frontend/govuk/core/_links.scss +0 -6
  63. data/node_modules/govuk-frontend/govuk/core/_lists.scss +0 -6
  64. data/node_modules/govuk-frontend/govuk/core/_section-break.scss +0 -6
  65. data/node_modules/govuk-frontend/govuk/core/_typography.scss +0 -6
  66. data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +2 -2
  67. data/node_modules/govuk-frontend/govuk/helpers/_spacing.scss +22 -4
  68. data/node_modules/govuk-frontend/govuk/objects/_all.scss +1 -0
  69. data/node_modules/govuk-frontend/govuk/objects/_main-wrapper.scss +15 -30
  70. data/node_modules/govuk-frontend/govuk/{core → objects}/_template.scss +1 -5
  71. data/node_modules/govuk-frontend/govuk/overrides/_all.scss +1 -0
  72. data/node_modules/govuk-frontend/govuk/overrides/_display.scss +0 -6
  73. data/node_modules/govuk-frontend/govuk/overrides/_spacing.scss +0 -6
  74. data/node_modules/govuk-frontend/govuk/overrides/_text-align.scss +14 -0
  75. data/node_modules/govuk-frontend/govuk/overrides/_typography.scss +0 -6
  76. data/node_modules/govuk-frontend/govuk/overrides/_width.scss +0 -6
  77. data/node_modules/govuk-frontend/govuk/settings/_colours-organisations.scss +3 -0
  78. data/node_modules/govuk-frontend/govuk/settings/_measurements.scss +0 -10
  79. data/node_modules/govuk-frontend/govuk/tools/_all.scss +0 -1
  80. data/package-lock.json +6 -6
  81. data/package.json +1 -1
  82. metadata +13 -10
  83. data/.travis.yml +0 -19
  84. data/CONTRIBUTING.md +0 -12
  85. data/node_modules/govuk-frontend/govuk/tools/_iff.scss +0 -17
@@ -52,48 +52,44 @@ $input-size: 40px;
52
52
  }
53
53
  }
54
54
 
55
- html.has-search-results-open {
56
- overflow: hidden;
57
- .app-pane__content {
58
- overflow: hidden;
59
- }
60
-
61
- .toc__close{
62
- display: none;
55
+ @include govuk-media-query($until: tablet) {
56
+ html.js.has-search-results-open:not(.toc-open) {
57
+ .toc {
58
+ display: block;
59
+ padding-bottom: 0;
60
+ }
61
+
62
+ .toc__close {
63
+ display: none;
64
+ }
65
+
66
+ .toc__list {
67
+ display: none;
68
+ }
63
69
  }
64
70
  }
71
+
65
72
  .search-results {
66
- display: none;
67
- &.is-open {
68
- display: block;
73
+ @include govuk-media-query(tablet) {
74
+ // Create basis for the search results caret (below)
75
+ position: relative;
76
+
77
+ @include govuk-font($size: 16);
78
+ padding-top: govuk-spacing(6);
69
79
  }
70
- }
71
80
 
72
- .search-results {
73
- position: absolute;
74
- top: 60px;
75
- left: 0;
76
- right: 0;
77
- bottom: 0;
78
- z-index: 600;
79
- overflow-x: scroll;
80
- -webkit-overflow-scrolling: touch;
81
- -ms-overflow-style: none;
82
- @include govuk-media-query(tablet) {
83
- padding: govuk-spacing(6);
84
- top: 0;
85
- // The width of the sidebar
86
- left: 330px;
87
- min-height: auto;
88
- }
81
+ a {
82
+ @include govuk-link-common;
83
+ @include govuk-link-style-no-visited-state;
84
+ }
89
85
 
90
- a {
91
- @include govuk-link-common;
92
- @include govuk-link-style-no-visited-state;
93
- }
86
+ ul {
87
+ list-style: none;
88
+ padding: 0;
89
+ margin: 0;
94
90
  }
91
+ }
95
92
  .search-results__inner {
96
- position: relative;
97
93
  background: govuk-colour("white");
98
94
  border-top: 1px solid govuk-colour("mid-grey");
99
95
  max-width: 40rem;
@@ -104,7 +100,7 @@ html.has-search-results-open {
104
100
  &::after {
105
101
  content: '';
106
102
  position: absolute;
107
- top: 10px;
103
+ top: 35px;
108
104
  left: -9px;
109
105
  width: 10px;
110
106
  height: 20px;
@@ -117,44 +113,6 @@ html.has-search-results-open {
117
113
  @include govuk-font($size: 27, $weight: bold);
118
114
  margin-bottom: govuk-spacing(6);
119
115
  }
120
- .search-results__close {
121
- @include govuk-font($size: 16);
122
- position: absolute;
123
- top: 18px;
124
- right: 20px;
125
- appearance: none;
126
- -webkit-appearance: none;
127
- background: none;
128
- border: 0;
129
- padding: 0;
130
- cursor: pointer;
131
-
132
- &:focus {
133
- @include govuk-focused-text;
134
- }
135
-
136
- &::after {
137
- content: '';
138
- display: inline-block;
139
- vertical-align: middle;
140
- padding-left: 8px;
141
- height: 18px;
142
- width: 18px;
143
- background: no-repeat url('/images/govuk-icn-close.png') center right;
144
- @include govuk-device-pixel-ratio {
145
- background-image: url('/images/govuk-icn-close@2x.png');
146
- }
147
- background-size: contain;
148
- }
149
- }
150
- .search-results__close-label {
151
- position: absolute;
152
- left: -9999em;
153
- top: auto;
154
- width: 1px;
155
- height: 1px;
156
- overflow: hidden;
157
- }
158
116
  .search-result {
159
117
  margin-bottom: govuk-spacing(6);
160
118
  }
@@ -162,4 +120,24 @@ html.has-search-results-open {
162
120
  background-color: transparent;
163
121
  color: inherit;
164
122
  font-weight: bold;
123
+
124
+ // In forced color mode some browsers will keep the background transparent
125
+ // but set the text colour black, making the highlighted text unreadable.
126
+ // The following blocks fix this by setting the text colour to be the same as
127
+ // other text in a way that forced color mode will respect.
128
+
129
+ @media screen and (-ms-high-contrast: active) {
130
+ // IE does not support `CanvasText`,
131
+ // and `currentColor` does not work with Blink
132
+ color: currentColor;
133
+ }
134
+
135
+ @media screen and (forced-colors: active) {
136
+ background-color: Canvas; // needed for Firefox
137
+ color: CanvasText;
138
+ }
139
+ }
140
+
141
+ .js .search-help__no-js {
142
+ display: none;
165
143
  }
@@ -11,10 +11,6 @@
11
11
  margin: 0 govuk-spacing(6) govuk-spacing(6);
12
12
  }
13
13
 
14
- .has-search-results-open & {
15
- visibility: hidden;
16
- }
17
-
18
14
  > h1 {
19
15
  @extend %govuk-heading-xl;
20
16
 
@@ -165,9 +165,6 @@
165
165
 
166
166
  .toc__list {
167
167
  margin-right: govuk-spacing(7);
168
- &.search-results-open {
169
- display: none;
170
- }
171
168
  }
172
169
 
173
170
  .toc__close {
@@ -7,6 +7,7 @@ module GovukTechDocs
7
7
  def initialize(app, document)
8
8
  @app = app
9
9
  @document = document
10
+ @redcarpet = build_redcarpet(app)
10
11
 
11
12
  # Load template files
12
13
  @template_api_full = get_renderer("api_reference_full.html.erb")
@@ -137,6 +138,11 @@ module GovukTechDocs
137
138
 
138
139
  private
139
140
 
141
+ def build_redcarpet(app)
142
+ renderer = GovukTechDocs::TechDocsHTMLRenderer.new(context: app.config_context)
143
+ Redcarpet::Markdown.new(renderer)
144
+ end
145
+
140
146
  def get_renderer(file)
141
147
  template_path = File.join(File.dirname(__FILE__), "templates/" + file)
142
148
  template = File.open(template_path, "r").read
@@ -159,6 +165,10 @@ module GovukTechDocs
159
165
  id = "schema-#{schema.name.parameterize}"
160
166
  "<a href='\##{id}'>#{schema.name}</a>"
161
167
  end
168
+
169
+ def render_markdown(text)
170
+ @redcarpet.render(text) if text
171
+ end
162
172
  end
163
173
  end
164
174
  end
@@ -1,5 +1,5 @@
1
1
  <h1 id="<%= info.title.parameterize %>"><%= info.title %> v<%= info.version %></h1>
2
- <%= info.description_html %>
2
+ <%= render_markdown(info.description) %>
3
3
 
4
4
  <%# OpenAPI files default to having a single server of URL "/" %>
5
5
  <% if servers.length > 1 || servers[0].url != "/" %>
@@ -7,7 +7,7 @@
7
7
  <div id="server-list">
8
8
  <% servers.each do |server| %>
9
9
  <% if server.description %>
10
- <p><strong><%= server.description %></strong></p>
10
+ <p><strong><%= render_markdown(server.description) %></strong></p>
11
11
  <% end %>
12
12
  <a href="<%= server.url %>"><%= server.url %></a>
13
13
  <% end %>
@@ -3,7 +3,7 @@
3
3
  <p><em><%= operation.summary %></em></p>
4
4
  <% end %>
5
5
  <% if operation.description %>
6
- <%= operation.description_html %>
6
+ <%= render_markdown(operation.description) %>
7
7
  <% end %>
8
8
 
9
9
  <%= parameters %>
@@ -11,7 +11,7 @@
11
11
  <td><%= parameter.in %></td>
12
12
  <td><%= parameter.schema.type %></td>
13
13
  <td><%= parameter.required? %></td>
14
- <td><%= parameter.description_html %>
14
+ <td><%= render_markdown(parameter.description) %>
15
15
  <% if parameter.schema.enum %>
16
16
  <p>Available items:</p>
17
17
  <ul>
@@ -9,7 +9,7 @@
9
9
  <tr>
10
10
  <td><%= key %></td>
11
11
  <td>
12
- <%= response.description_html %>
12
+ <%= render_markdown(response.description) %>
13
13
  <% if response.content['application/json']
14
14
  if response.content['application/json']["example"]
15
15
  request_body = json_prettyprint(response.content['application/json']["example"])
@@ -1,5 +1,5 @@
1
1
  <h3 id="<%= id = 'schema-' + title; id.parameterize %>"><%= title %></h3>
2
- <%= schema.description_html %>
2
+ <%= render_markdown(schema.description) %>
3
3
  <% if properties.any? %>
4
4
  <table class='<%= id.parameterize %>'>
5
5
  <thead>
@@ -11,7 +11,7 @@
11
11
  <td><%= property_name %></td>
12
12
  <td><%= property_attributes.type %></td>
13
13
  <td><%= schema.requires?(property_name) %></td>
14
- <td><%= property_attributes.description_html %></td>
14
+ <td><%= render_markdown(property_attributes.description) %></td>
15
15
  <td>
16
16
  <%=
17
17
  linked_schema = property_attributes
@@ -20,12 +20,18 @@ module GovukTechDocs
20
20
 
21
21
  def report_issue_url
22
22
  url = config[:source_urls]&.[](:report_issue_url)
23
+ params = {
24
+ body: "Problem with '#{current_page.data.title}' (#{config[:tech_docs][:host]}#{current_page.url})",
25
+ }
23
26
 
24
27
  if url.nil?
25
- "#{repo_url}/issues/new?labels=bug&title=Re: '#{current_page.data.title}'&body=Problem with '#{current_page.data.title}' (#{config[:tech_docs][:host]}#{current_page.url})"
28
+ url = "#{repo_url}/issues/new"
29
+ params["labels"] = "bug"
30
+ params["title"] = "Re: '#{current_page.data.title}'"
26
31
  else
27
- "#{url}?subject=Re: '#{current_page.data.title}'&body=Problem with '#{current_page.data.title}' (#{config[:tech_docs][:host]}#{current_page.url})"
32
+ params["subject"] = "Re: '#{current_page.data.title}'"
28
33
  end
34
+ "#{url}?#{URI.encode_www_form(params)}"
29
35
  end
30
36
 
31
37
  def repo_url
@@ -1,3 +1,3 @@
1
1
  module GovukTechDocs
2
- VERSION = "2.4.2".freeze
2
+ VERSION = "3.1.0".freeze
3
3
  end
@@ -113,10 +113,12 @@ module GovukTechDocs
113
113
  url: { index: false, store: true },
114
114
  }
115
115
 
116
- search.pipeline_remove = %w[stopWordFilter]
116
+ search.pipeline_remove = %w[stemmer stopWordFilter]
117
117
 
118
118
  search.tokenizer_separator = '/[\s\-/]+/'
119
119
  end
120
+ else
121
+ context.ignore "search/*"
120
122
  end
121
123
  end
122
124
  end
@@ -41,9 +41,9 @@
41
41
  </div>
42
42
  <% if config[:tech_docs][:header_links] %>
43
43
  <div class="govuk-header__content">
44
- <button type="button" class="govuk-header__menu-button govuk-js-header-toggle" aria-controls="navigation" aria-label="Show or hide Top Level Navigation">Menu</button>
45
- <nav>
46
- <ul id="navigation" class="govuk-header__navigation govuk-header__navigation--end" aria-label="Top Level Navigation">
44
+ <nav class="govuk-header__navigation govuk-header__navigation--end" aria-label="Menu">
45
+ <button type="button" class="govuk-header__menu-button govuk-js-header-toggle" aria-controls="navigation" aria-label="Show or hide menu">Menu</button>
46
+ <ul id="navigation" class="govuk-header__navigation-list">
47
47
  <% config[:tech_docs][:header_links].each do |title, path| %>
48
48
  <li class="govuk-header__navigation-item<% if active_page(path) %> govuk-header__navigation-item--active<% end %>">
49
49
  <a class="govuk-header__link" href="<%= url_for path %>"><%= title %></a>
@@ -13,12 +13,5 @@
13
13
  placeholder="Search">
14
14
  <button type="submit" class="search__button">Search</button>
15
15
  </form>
16
- <div id="search-results" class="search-results" aria-hidden="true" role="dialog" aria-labelledby="search-results-title">
17
- <div class="search-results__inner">
18
- <button class="search-results__close">Close<span class="search-results__close-label"> search results</span></button>
19
- <h2 id="search-results-title" class="search-results__title" aria-live="assertive" role="alert">Results</h2>
20
- <div class="search-results__content"></div>
21
- </div>
22
- </div>
23
16
  </div>
24
17
  <% end %>
@@ -27,7 +27,7 @@
27
27
 
28
28
  <div class="app-pane">
29
29
  <div class="app-pane__header toc-open-disabled">
30
- <a href="#content" class="govuk-skip-link">Skip to main content</a>
30
+ <a href="#content" class="govuk-skip-link" data-module="govuk-skip-link">Skip to main content</a>
31
31
 
32
32
  <%= partial 'layouts/header' %>
33
33
  </div>
@@ -0,0 +1,31 @@
1
+ ---
2
+ title: Search
3
+ index: false
4
+ prevent_indexing: true
5
+ hide_in_navigation: true
6
+ ---
7
+
8
+ <div id="search-help" class="search-help">
9
+ <%# strange id is to avoid clash with search input id #%>
10
+ <h1 id="how-to-search">Search</h1>
11
+
12
+ <p class="govuk-body search-help__no-js">
13
+ You need to turn on JavaScript in your browser to search this site. You can either:
14
+
15
+ <ul>
16
+ <li>turn on JavaScript in your browser</li>
17
+ <li>search this site using Google</li>
18
+ </ul>
19
+ </p>
20
+
21
+ <p class="govuk-body">
22
+ Enter a search term in the search box, then select the search button.
23
+ </p>
24
+ </div>
25
+
26
+ <div id="search-results" class="search-results" hidden aria-labelledby="search-results-title">
27
+ <div class="search-results__inner">
28
+ <h1 id="search-results-title" class="search-results__title" aria-live="assertive">Results</h1>
29
+ <div class="search-results__content"></div>
30
+ </div>
31
+ </div>