govuk_tech_docs 2.1.1 → 2.2.0
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 +4 -4
- data/.github/pull_request_template.md +1 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.md +18 -4
- data/README.md +15 -22
- data/lib/assets/javascripts/_modules/search.js +13 -2
- data/lib/assets/javascripts/_modules/table-of-contents.js +9 -14
- data/lib/assets/stylesheets/modules/_search.scss +43 -9
- data/lib/assets/stylesheets/modules/_technical-documentation.scss +11 -2
- data/lib/assets/stylesheets/modules/_toc.scss +12 -2
- data/lib/govuk_tech_docs/tech_docs_html_renderer.rb +75 -1
- data/lib/govuk_tech_docs/version.rb +1 -1
- data/lib/source/images/search-button.png +0 -0
- data/lib/source/layouts/_search.erb +10 -4
- data/lib/source/layouts/core.erb +4 -4
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4adec245cbbc73fe2a14f73eb4a0eb2f9acf4d8d751f0786271c59f479c8b244
|
|
4
|
+
data.tar.gz: 9017c133a8dace561bf56b4e2ec852b4dcdc15a341501b8784659f229f2f183a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3da0c05902288480bf1953b7d5ad275742707cb8324cebe68a1f970cb9dda1b2c70a6538aa9af7a6272973e4b08b3a10108ad6591cbb78bae5aa4e46d436357d
|
|
7
|
+
data.tar.gz: 1ca0540c1625e80f25d89426f893d15368da0c13b84e5824c4808abd62bfed7bf1e4b93738c2ecd76fe43d70fd23b5517494078ab94367f062f4a73f8c0cec8f
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
⚠️ Don't forget to update the gem version in the [CHANGELOG](https://github.com/alphagov/tech-docs-gem/blob/master/CHANGELOG.md) before merging! When you're ready to release bump [version file](https://github.com/alphagov/tech-docs-gem/blob/master/lib/govuk_tech_docs/version.rb) and generate a tag. ⚠️
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 2.2.0
|
|
4
4
|
|
|
5
|
-
###
|
|
5
|
+
### Accessibility Fixes
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- [#205: Improve table of contents accessibility](https://github.com/alphagov/tech-docs-gem/pull/205)
|
|
8
|
+
- [#209: Some search and keyboard navigation updates](https://github.com/alphagov/tech-docs-gem/pull/209)
|
|
9
|
+
- [#210: Stop linking images to new tabs](https://github.com/alphagov/tech-docs-gem/pull/210)
|
|
10
|
+
- [#214: Implement row level table headings to allow accessible tables with row headings](https://github.com/alphagov/tech-docs-gem/pull/214)
|
|
11
|
+
- [#215: Add tabindex and focus states to code blocks](https://github.com/alphagov/tech-docs-gem/pull/215)
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
### Docs
|
|
14
|
+
|
|
15
|
+
- [#206: Remove tdt docs content from readme file](https://github.com/alphagov/tech-docs-gem/pull/206)
|
|
16
|
+
|
|
17
|
+
## 2.1.1
|
|
10
18
|
|
|
11
19
|
### Fixes
|
|
12
20
|
|
|
@@ -14,6 +22,12 @@ We’ve made fixes in the following pull requests:
|
|
|
14
22
|
|
|
15
23
|
- [#199: Fix page expiry box link colours (hover and focus) ](https://github.com/alphagov/tech-docs-gem/pull/199)
|
|
16
24
|
|
|
25
|
+
### Ruby version bump
|
|
26
|
+
|
|
27
|
+
We've updated the Ruby version supported:
|
|
28
|
+
|
|
29
|
+
- [#201: Bump ruby to 2.7.2](https://github.com/alphagov/tech-docs-gem/pull/201)
|
|
30
|
+
|
|
17
31
|
## 2.1.0
|
|
18
32
|
|
|
19
33
|
### New features
|
data/README.md
CHANGED
|
@@ -3,23 +3,19 @@
|
|
|
3
3
|
This repo contains the Ruby gem that distributes the [Tech Docs Template][tdt-template]. The Tech Docs Template is a [middleman template][mmt] that
|
|
4
4
|
you can use to build technical documentation using a GOV.UK style.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
## Usage
|
|
9
|
-
|
|
10
|
-
👉 Find out how to [generate a new website with the Tech Docs Template][tdt-readme].
|
|
6
|
+
To find out more about setting up and managing content for a website using this template, see the [Tech Docs Template documentation][tdt-docs].
|
|
11
7
|
|
|
12
8
|
## Contributing
|
|
13
9
|
|
|
14
10
|
Everybody who uses this project is encouraged to contribute.
|
|
15
11
|
|
|
16
|
-
|
|
12
|
+
You can find out more about contributing to this project from the[CONTRIBUTING.md file](CONTRIBUTING.md).
|
|
17
13
|
|
|
18
14
|
## GOV.UK frontend
|
|
19
15
|
|
|
20
16
|
This gem uses [GOV.UK Frontend](https://github.com/alphagov/govuk-frontend), part of the [GOV.UK Design System](https://design-system.service.gov.uk/).
|
|
21
17
|
|
|
22
|
-
We use `npm` to download the govuk-frontend package. To update to a new version, change the version in [package.json](blob/master/package.json) and run `npm update`.
|
|
18
|
+
We use `npm` to download the govuk-frontend package. To update to a new version, change the version in the [package.json file](blob/master/package.json) and run `npm update`.
|
|
23
19
|
|
|
24
20
|
## Developing locally
|
|
25
21
|
|
|
@@ -30,19 +26,13 @@ There are 2 ways to develop with this gem. You can see your changes on either:
|
|
|
30
26
|
|
|
31
27
|
### Use your own Tech Docs Template website
|
|
32
28
|
|
|
33
|
-
|
|
29
|
+
To see how your changes to the gem affect your website, point your website's Gemfile to your local checkout:
|
|
34
30
|
|
|
35
31
|
```rb
|
|
36
32
|
gem 'govuk_tech_docs', path: '../tech-docs-gem'
|
|
37
33
|
```
|
|
38
34
|
|
|
39
|
-
To
|
|
40
|
-
|
|
41
|
-
```sh
|
|
42
|
-
bundle exec middleman server
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
See your website on `http://localhost:4567` in your browser.
|
|
35
|
+
To preview your documentation changes locally, see the [Tech Docs Template documentation on previewing your documentation](https://tdt-documentation.london.cloudapps.digital/create_project/preview/#preview-your-documentation).
|
|
46
36
|
|
|
47
37
|
### Use the example in this repo
|
|
48
38
|
|
|
@@ -56,14 +46,16 @@ bundle exec middleman server
|
|
|
56
46
|
|
|
57
47
|
See your website on `http://localhost:4567` in your browser.
|
|
58
48
|
|
|
49
|
+
For more information on previewing your documentation locally, see the [Tech Docs template documentation on previewing your documentation](https://tdt-documentation.london.cloudapps.digital/create_project/preview/#preview-your-documentation).
|
|
50
|
+
|
|
59
51
|
## Tests
|
|
60
52
|
|
|
61
|
-
|
|
53
|
+
This repository contains automated JavaScript tests that use the [Jasmine test framework][jas].
|
|
62
54
|
|
|
63
|
-
|
|
55
|
+
You can run these tests and see the results in your browser.
|
|
64
56
|
|
|
65
|
-
1. Run `bundle exec rake jasmine
|
|
66
|
-
2. Go to `http://localhost:8888` in your browser
|
|
57
|
+
1. Run `bundle exec rake jasmine`.
|
|
58
|
+
2. Go to `http://localhost:8888` in your browser.
|
|
67
59
|
|
|
68
60
|
To run the tests and see the results in your terminal, run:
|
|
69
61
|
|
|
@@ -73,14 +65,15 @@ bundle exec rake jasmine:ci
|
|
|
73
65
|
|
|
74
66
|
## Releasing new versions
|
|
75
67
|
|
|
76
|
-
To release a new version, create a new
|
|
68
|
+
To release a new version, create a new pull request (PR) that updates [version.rb](lib/govuk_tech_docs/version.rb) and [CHANGELOG.md](CHANGELOG.md).
|
|
69
|
+
|
|
70
|
+
Do not include other changes in your pull request, as this makes it easier to find out what was released when. See an example of a [PR for releasing a new version](https://github.com/alphagov/tech-docs-gem/pull/15).
|
|
77
71
|
|
|
78
72
|
Travis will automatically release a [new version to Rubygems.org](https://rubygems.org/gems/govuk_tech_docs).
|
|
79
73
|
|
|
80
74
|
## Licence
|
|
81
75
|
|
|
82
|
-
Unless stated otherwise, the codebase is released under [the MIT License][mit].
|
|
83
|
-
This covers both the codebase and any sample code in the documentation.
|
|
76
|
+
Unless stated otherwise, the codebase is released under [the MIT License][mit]. This covers both the codebase and any sample code in the documentation.
|
|
84
77
|
|
|
85
78
|
The documentation is [© Crown copyright][copyright] and available under the terms of the [Open Government 3.0][ogl] licence.
|
|
86
79
|
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
Modules.Search = function Search () {
|
|
7
7
|
var s = this
|
|
8
8
|
var $html = $('html')
|
|
9
|
+
var $tocNav
|
|
9
10
|
var $searchForm
|
|
10
11
|
var $searchLabel
|
|
11
12
|
var $searchInput
|
|
@@ -26,6 +27,7 @@
|
|
|
26
27
|
$searchResults = $searchResultsWrapper.find('.search-results__content')
|
|
27
28
|
$searchResultsTitle = $searchResultsWrapper.find('.search-results__title')
|
|
28
29
|
$searchResultsClose = $searchResultsWrapper.find('.search-results__close')
|
|
30
|
+
$tocNav = $('#toc')
|
|
29
31
|
s.downloadSearchIndex()
|
|
30
32
|
attach()
|
|
31
33
|
changeSearchLabel()
|
|
@@ -67,7 +69,14 @@
|
|
|
67
69
|
$searchForm.on('submit', function (e) {
|
|
68
70
|
e.preventDefault()
|
|
69
71
|
showResults()
|
|
70
|
-
$searchResults.find('.search-result__title a').first()
|
|
72
|
+
var $firstResult = $searchResults.find('.search-result__title a').first()
|
|
73
|
+
if ($firstResult.length) {
|
|
74
|
+
$firstResult.focus()
|
|
75
|
+
} else {
|
|
76
|
+
// if there are no results, show the "0 results" state
|
|
77
|
+
results = []
|
|
78
|
+
updateTitle()
|
|
79
|
+
}
|
|
71
80
|
})
|
|
72
81
|
|
|
73
82
|
// Closing the search results, move focus back to the search input
|
|
@@ -98,7 +107,7 @@
|
|
|
98
107
|
}
|
|
99
108
|
|
|
100
109
|
function changeSearchLabel () {
|
|
101
|
-
$searchLabel.text('Search')
|
|
110
|
+
$searchLabel.text('Search this documentation')
|
|
102
111
|
}
|
|
103
112
|
|
|
104
113
|
function getResults (query) {
|
|
@@ -192,12 +201,14 @@
|
|
|
192
201
|
$searchResultsWrapper.addClass('is-open')
|
|
193
202
|
.attr('aria-hidden', 'false')
|
|
194
203
|
$html.addClass('has-search-results-open')
|
|
204
|
+
$tocNav.addClass('search-results-open')
|
|
195
205
|
}
|
|
196
206
|
|
|
197
207
|
function hideResults () {
|
|
198
208
|
$searchResultsWrapper.removeClass('is-open')
|
|
199
209
|
.attr('aria-hidden', 'true')
|
|
200
210
|
$html.removeClass('has-search-results-open')
|
|
211
|
+
$tocNav.removeClass('search-results-open')
|
|
201
212
|
}
|
|
202
213
|
|
|
203
214
|
function sendQueryToAnalytics () {
|
|
@@ -7,23 +7,22 @@
|
|
|
7
7
|
var $toc
|
|
8
8
|
var $tocList
|
|
9
9
|
|
|
10
|
-
var $
|
|
11
|
-
var $
|
|
10
|
+
var $openButton
|
|
11
|
+
var $closeButton
|
|
12
12
|
|
|
13
13
|
this.start = function ($element) {
|
|
14
14
|
$toc = $element
|
|
15
15
|
$tocList = $toc.find('.js-toc-list')
|
|
16
|
-
|
|
17
16
|
// Open link is not inside the module
|
|
18
|
-
$
|
|
19
|
-
$
|
|
17
|
+
$openButton = $html.find('.js-toc-show')
|
|
18
|
+
$closeButton = $toc.find('.js-toc-close')
|
|
20
19
|
|
|
21
20
|
fixRubberBandingInIOS()
|
|
22
21
|
updateAriaAttributes()
|
|
23
22
|
|
|
24
23
|
// Need delegated handler for show link as sticky polyfill recreates element
|
|
25
|
-
$
|
|
26
|
-
$
|
|
24
|
+
$openButton.on('click.toc', preventingScrolling(openNavigation))
|
|
25
|
+
$closeButton.on('click.toc', preventingScrolling(closeNavigation))
|
|
27
26
|
$tocList.on('click.toc', 'a', closeNavigation)
|
|
28
27
|
|
|
29
28
|
// Allow aria hidden to be updated when resizing from mobile to desktop or
|
|
@@ -65,21 +64,17 @@
|
|
|
65
64
|
|
|
66
65
|
toggleBackgroundVisiblity(false)
|
|
67
66
|
updateAriaAttributes()
|
|
68
|
-
|
|
69
|
-
focusFirstLinkInToc()
|
|
67
|
+
$toc.focus()
|
|
70
68
|
}
|
|
71
69
|
|
|
72
70
|
function closeNavigation () {
|
|
73
71
|
$html.removeClass('toc-open')
|
|
72
|
+
$html.removeClass('has-search-results-open')
|
|
74
73
|
|
|
75
74
|
toggleBackgroundVisiblity(true)
|
|
76
75
|
updateAriaAttributes()
|
|
77
76
|
}
|
|
78
77
|
|
|
79
|
-
function focusFirstLinkInToc () {
|
|
80
|
-
$('a', $tocList).first().focus()
|
|
81
|
-
}
|
|
82
|
-
|
|
83
78
|
function toggleBackgroundVisiblity (visibility) {
|
|
84
79
|
$('.toc-open-disabled').attr('aria-hidden', visibility ? '' : 'true')
|
|
85
80
|
}
|
|
@@ -87,7 +82,7 @@
|
|
|
87
82
|
function updateAriaAttributes () {
|
|
88
83
|
var tocIsVisible = $toc.is(':visible')
|
|
89
84
|
|
|
90
|
-
$($
|
|
85
|
+
$($openButton).add($closeButton)
|
|
91
86
|
.attr('aria-expanded', tocIsVisible ? 'true' : 'false')
|
|
92
87
|
|
|
93
88
|
$toc.attr('aria-hidden', tocIsVisible ? 'false' : 'true')
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
+
$input-size: 40px;
|
|
2
|
+
|
|
1
3
|
@include govuk-media-query($media-type: screen) {
|
|
2
4
|
.page-title + .search {
|
|
3
5
|
margin-top: govuk-spacing(6);
|
|
4
6
|
}
|
|
5
|
-
|
|
6
|
-
.js .search__label {
|
|
7
|
-
position: absolute;
|
|
8
|
-
left: -9999em;
|
|
9
|
-
top: auto;
|
|
10
|
-
width: 1px;
|
|
11
|
-
height: 1px;
|
|
12
|
-
overflow: hidden;
|
|
13
|
-
}
|
|
14
7
|
}
|
|
15
8
|
|
|
16
9
|
@include govuk-media-query($media-type: print) {
|
|
@@ -19,6 +12,46 @@
|
|
|
19
12
|
}
|
|
20
13
|
}
|
|
21
14
|
|
|
15
|
+
.js .search__label {
|
|
16
|
+
@extend .govuk-visually-hidden;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.search__form {
|
|
20
|
+
position: relative;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.search__input {
|
|
24
|
+
width: 230px;
|
|
25
|
+
width: calc(100% - #{$input-size});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.search__button {
|
|
29
|
+
position: absolute;
|
|
30
|
+
bottom: 0;
|
|
31
|
+
right: 0;
|
|
32
|
+
border: 0;
|
|
33
|
+
background-color: govuk-colour('blue');
|
|
34
|
+
color: #fff;
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
padding: 0;
|
|
37
|
+
width: $input-size;
|
|
38
|
+
height: 100%;
|
|
39
|
+
background-image: url('/images/search-button.png');
|
|
40
|
+
background-repeat: no-repeat;
|
|
41
|
+
background-position: 2px 50%;
|
|
42
|
+
text-indent: -5000px;
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
&:focus {
|
|
45
|
+
outline: $govuk-focus-width solid $govuk-focus-colour;
|
|
46
|
+
outline-offset: 0;
|
|
47
|
+
box-shadow: inset 0 0 0 $govuk-border-width-form-element * 2 govuk-colour("black");
|
|
48
|
+
|
|
49
|
+
@include govuk-if-ie8 {
|
|
50
|
+
border-width: $govuk-border-width-form-element * 2;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
22
55
|
html.has-search-results-open {
|
|
23
56
|
overflow: hidden;
|
|
24
57
|
.app-pane__content {
|
|
@@ -47,6 +80,7 @@ html.has-search-results-open {
|
|
|
47
80
|
top: 0;
|
|
48
81
|
// The width of the sidebar
|
|
49
82
|
left: 330px;
|
|
83
|
+
min-height: auto;
|
|
50
84
|
}
|
|
51
85
|
|
|
52
86
|
a:link, a:visited {
|
|
@@ -118,11 +118,20 @@
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
pre {
|
|
121
|
+
$padding: 15px;
|
|
122
|
+
$border-width: 1px;
|
|
123
|
+
|
|
121
124
|
background: $code-00;
|
|
122
|
-
padding:
|
|
125
|
+
padding: $padding;
|
|
123
126
|
overflow: auto;
|
|
124
127
|
position: relative;
|
|
125
|
-
border:
|
|
128
|
+
border: $border-width solid $code-02;
|
|
129
|
+
|
|
130
|
+
&:focus {
|
|
131
|
+
padding: $padding - ($govuk-focus-width - $border-width);
|
|
132
|
+
border: $govuk-focus-width solid $govuk-focus-text-colour;
|
|
133
|
+
outline: $govuk-focus-width solid $govuk-focus-colour;
|
|
134
|
+
}
|
|
126
135
|
}
|
|
127
136
|
|
|
128
137
|
pre code {
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
display: block;
|
|
128
128
|
position: relative;
|
|
129
129
|
z-index: 10;
|
|
130
|
-
|
|
130
|
+
width: 100%;
|
|
131
131
|
padding: govuk-spacing(3) govuk-spacing(3) 10px;
|
|
132
132
|
|
|
133
133
|
background: govuk-colour("light-grey");
|
|
@@ -135,10 +135,12 @@
|
|
|
135
135
|
background: transparentize(govuk-colour("light-grey"), 0.05);
|
|
136
136
|
backdrop-filter: blur(2px);
|
|
137
137
|
}
|
|
138
|
+
border: 0;
|
|
138
139
|
border-bottom: 1px solid govuk-colour("mid-grey");
|
|
139
140
|
box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
|
|
140
141
|
color: $govuk-text-colour;
|
|
141
142
|
text-decoration: none;
|
|
143
|
+
text-align: left;
|
|
142
144
|
|
|
143
145
|
&:focus {
|
|
144
146
|
@include govuk-focused-text;
|
|
@@ -163,6 +165,9 @@
|
|
|
163
165
|
|
|
164
166
|
.toc__list {
|
|
165
167
|
margin-right: govuk-spacing(7);
|
|
168
|
+
&.search-results-open {
|
|
169
|
+
display: none;
|
|
170
|
+
}
|
|
166
171
|
}
|
|
167
172
|
|
|
168
173
|
.toc__close {
|
|
@@ -170,7 +175,7 @@
|
|
|
170
175
|
position: sticky;
|
|
171
176
|
right: 0;
|
|
172
177
|
top: 0;
|
|
173
|
-
|
|
178
|
+
border: 0;
|
|
174
179
|
float: right;
|
|
175
180
|
width: 20px;
|
|
176
181
|
height: 20px;
|
|
@@ -207,6 +212,10 @@
|
|
|
207
212
|
height: 100%;
|
|
208
213
|
overflow: hidden;
|
|
209
214
|
pointer-events: none;
|
|
215
|
+
// set visibility hidden on the body when TOC is open
|
|
216
|
+
// this is a hack to prevent tabbing to out-of-view elements when the TOC is active
|
|
217
|
+
// it's preferable to keyboard trapping... probably.
|
|
218
|
+
visibility: hidden;
|
|
210
219
|
}
|
|
211
220
|
|
|
212
221
|
.toc-show {
|
|
@@ -214,6 +223,7 @@
|
|
|
214
223
|
}
|
|
215
224
|
|
|
216
225
|
.toc {
|
|
226
|
+
visibility: visible;
|
|
217
227
|
display: block;
|
|
218
228
|
pointer-events: auto;
|
|
219
229
|
position: fixed;
|
|
@@ -20,7 +20,7 @@ module GovukTechDocs
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def image(link, *args)
|
|
23
|
-
%(<a href="#{link}"
|
|
23
|
+
%(<a href="#{link}" rel="noopener noreferrer">#{super}</a>)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def table(header, body)
|
|
@@ -30,5 +30,79 @@ module GovukTechDocs
|
|
|
30
30
|
</table>
|
|
31
31
|
</div>)
|
|
32
32
|
end
|
|
33
|
+
|
|
34
|
+
def table_row(body)
|
|
35
|
+
# Post-processing the table_cell HTML to implement row headings.
|
|
36
|
+
#
|
|
37
|
+
# Doing this in table_row instead of table_cell is a hack.
|
|
38
|
+
#
|
|
39
|
+
# Ideally, we'd use the table_cell callback like:
|
|
40
|
+
#
|
|
41
|
+
# def table_cell(content, alignment, header)
|
|
42
|
+
# if header
|
|
43
|
+
# "<th>#{content}</th>"
|
|
44
|
+
# elsif content.start_with? "# "
|
|
45
|
+
# "<th scope="row">#{content.sub(/^# /, "")}</th>"
|
|
46
|
+
# else
|
|
47
|
+
# "<td>#{content}</td>"
|
|
48
|
+
# end
|
|
49
|
+
# end
|
|
50
|
+
#
|
|
51
|
+
# Sadly, Redcarpet's table_cell callback doesn't allow you to distinguish
|
|
52
|
+
# table cells and table headings until https://github.com/vmg/redcarpet/commit/27dfb2a738a23aadd286ac9e7ecd61c4545d29de
|
|
53
|
+
# (which is not yet released). This means we can't use the table_cell callback
|
|
54
|
+
# without breaking column headers, so we're having to hack it in table_row.
|
|
55
|
+
|
|
56
|
+
fragment = Nokogiri::HTML::DocumentFragment.parse(body)
|
|
57
|
+
fragment.children.each do |cell|
|
|
58
|
+
next unless cell.name == "td"
|
|
59
|
+
next if cell.children.empty?
|
|
60
|
+
|
|
61
|
+
first_child = cell.children.first
|
|
62
|
+
next unless first_child.text?
|
|
63
|
+
|
|
64
|
+
leading_text = first_child.content
|
|
65
|
+
next unless leading_text.start_with?("#")
|
|
66
|
+
|
|
67
|
+
cell.name = "th"
|
|
68
|
+
cell["scope"] = "row"
|
|
69
|
+
first_child.content = leading_text.sub(/# */, "")
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
tr = Nokogiri::XML::Node.new "tr", fragment
|
|
73
|
+
tr.children = fragment.children
|
|
74
|
+
|
|
75
|
+
tr.to_html
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def block_code(text, lang)
|
|
79
|
+
if defined?(super)
|
|
80
|
+
# Post-processing the block_code HTML to implement tabbable code blocks.
|
|
81
|
+
#
|
|
82
|
+
# Middleman monkey patches the Middleman::Renderers::MiddlemanRedcarpetHTML
|
|
83
|
+
# to include Middleman::Syntax::RedcarpetCodeRenderer. This defines its own
|
|
84
|
+
# version of `block_code(text, lang)` which we can call with `super`.
|
|
85
|
+
|
|
86
|
+
fragment = Nokogiri::HTML::DocumentFragment.parse(super)
|
|
87
|
+
fragment.traverse do |element|
|
|
88
|
+
if element.name == "pre" && element["tabindex"].nil?
|
|
89
|
+
element["tabindex"] = "0"
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
fragment.to_html
|
|
93
|
+
else
|
|
94
|
+
# If syntax highlighting with redcarpet isn't enabled, super will not
|
|
95
|
+
# be `defined?`, so we can jump straight to rendering HTML ourselves.
|
|
96
|
+
|
|
97
|
+
fragment = Nokogiri::HTML::DocumentFragment.parse("")
|
|
98
|
+
pre = Nokogiri::XML::Node.new "pre", fragment
|
|
99
|
+
pre["tabindex"] = "0"
|
|
100
|
+
code = Nokogiri::XML::Node.new "code", fragment
|
|
101
|
+
code["class"] = lang
|
|
102
|
+
code.content = text
|
|
103
|
+
pre.add_child code
|
|
104
|
+
pre.to_html
|
|
105
|
+
end
|
|
106
|
+
end
|
|
33
107
|
end
|
|
34
108
|
end
|
|
Binary file
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
<% if config[:tech_docs][:enable_search] %>
|
|
2
2
|
<div class="search" data-module="search">
|
|
3
|
-
<form action="https://www.google.co.uk/search" method="get" role="search">
|
|
3
|
+
<form action="https://www.google.co.uk/search" method="get" role="search" class="search__form govuk-!-margin-bottom-4">
|
|
4
4
|
<input type="hidden" name="as_sitesearch" value="<%= config[:tech_docs][:host] %>"/>
|
|
5
|
-
<label class="govuk-label search__label" for="search">
|
|
5
|
+
<label class="govuk-label search__label" for="search" aria-hidden="true">
|
|
6
6
|
Search (via Google)
|
|
7
7
|
</label>
|
|
8
|
-
<input
|
|
8
|
+
<input
|
|
9
|
+
type="text"
|
|
10
|
+
id="search" name="q"
|
|
11
|
+
class="govuk-input govuk-!-margin-bottom-0 search__input"
|
|
12
|
+
aria-controls="search-results"
|
|
13
|
+
placeholder="Search">
|
|
14
|
+
<button type="submit" class="govuk-button search__button">Search</button>
|
|
9
15
|
</form>
|
|
10
16
|
<div id="search-results" class="search-results" aria-hidden="true" role="dialog" aria-labelledby="search-results-title">
|
|
11
17
|
<div class="search-results__inner">
|
|
12
18
|
<button class="search-results__close">Close<span class="search-results__close-label"> search results</span></button>
|
|
13
|
-
<h2 id="search-results-title" class="search-results__title" aria-live="
|
|
19
|
+
<h2 id="search-results-title" class="search-results__title" aria-live="assertive" role="alert">Results</h2>
|
|
14
20
|
<div class="search-results__content"></div>
|
|
15
21
|
</div>
|
|
16
22
|
</div>
|
data/lib/source/layouts/core.erb
CHANGED
|
@@ -34,18 +34,18 @@
|
|
|
34
34
|
|
|
35
35
|
<% if content_for? :sidebar %>
|
|
36
36
|
<div id="toc-heading" class="toc-show fixedsticky">
|
|
37
|
-
<
|
|
37
|
+
<button type="button" class="toc-show__label js-toc-show" aria-controls="toc">
|
|
38
38
|
Table of contents <span class="toc-show__icon"></span>
|
|
39
|
-
</
|
|
39
|
+
</button>
|
|
40
40
|
</div>
|
|
41
41
|
<% end %>
|
|
42
42
|
|
|
43
43
|
<div class="app-pane__body"<%= " data-module=\"#{yield_content(:toc_module)}\"" if content_for? :toc_module %>>
|
|
44
44
|
<% if content_for? :sidebar %>
|
|
45
45
|
<div class="app-pane__toc">
|
|
46
|
-
<div class="toc" data-module="table-of-contents">
|
|
46
|
+
<div class="toc" data-module="table-of-contents" tabindex="-1" aria-label="Table of contents" role="dialog">
|
|
47
47
|
<%= partial "layouts/search" %>
|
|
48
|
-
<
|
|
48
|
+
<button type="button" class="toc__close js-toc-close" aria-controls="toc" aria-label="Hide table of contents"></button>
|
|
49
49
|
<nav id="toc" class="js-toc-list toc__list" aria-labelledby="toc-heading"<%= " data-module=\"collapsible-navigation\"" if config[:tech_docs][:collapsible_nav] %>>
|
|
50
50
|
<%= yield_content :sidebar %>
|
|
51
51
|
</nav>
|
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.
|
|
4
|
+
version: 2.2.0
|
|
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: 2021-
|
|
11
|
+
date: 2021-03-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -327,6 +327,7 @@ extensions: []
|
|
|
327
327
|
extra_rdoc_files: []
|
|
328
328
|
files:
|
|
329
329
|
- ".editorconfig"
|
|
330
|
+
- ".github/pull_request_template.md"
|
|
330
331
|
- ".gitignore"
|
|
331
332
|
- ".nvmrc"
|
|
332
333
|
- ".rspec"
|
|
@@ -433,6 +434,7 @@ files:
|
|
|
433
434
|
- lib/source/images/govuk-icn-close@2x.png
|
|
434
435
|
- lib/source/images/govuk-icn-numbered-list.png
|
|
435
436
|
- lib/source/images/govuk-icn-numbered-list@2x.png
|
|
437
|
+
- lib/source/images/search-button.png
|
|
436
438
|
- lib/source/images/search-result-caret.svg
|
|
437
439
|
- lib/source/layouts/_analytics.erb
|
|
438
440
|
- lib/source/layouts/_footer.erb
|