govuk_tech_docs 6.2.2 → 6.2.4
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/workflows/dependency-review.yaml +1 -1
- data/.github/workflows/publish.yaml +2 -2
- data/.github/workflows/test.yaml +6 -1
- data/CHANGELOG.md +8 -0
- data/example/source/pets.yml +4 -0
- data/govuk_tech_docs.gemspec +1 -1
- data/lib/assets/javascripts/_modules/in-page-navigation.js +14 -32
- data/lib/govuk_tech_docs/api_reference/api_reference_renderer.rb +6 -5
- data/lib/govuk_tech_docs/api_reference/templates/responses.html.erb +20 -10
- data/lib/govuk_tech_docs/version.rb +1 -1
- metadata +11 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 74dc4c44fa70d8f29bb050007da7bfc8740e690f3dda8b4220fc1cbf6246d08d
|
|
4
|
+
data.tar.gz: 972e4b78381b8a0d07384fd65dc8a40889b56458d31e3bfca60098a053e5b794
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c9289ca8f68a4b0327d71355929f319dea91d1a8a72dcbb10a7190a51e6cf59f06ed5df79ed7acf3efa7989c180c29c43727931e64b8045741df4a6fa7b25495
|
|
7
|
+
data.tar.gz: 7e02307c317a55e7075c71d537fa0e11c60c7250af9c6851f2e45e6068cb8f8fde3236f9202811049e557047c078a5bd9a48e324ff6f19ae57ae651b4f556dae
|
|
@@ -15,7 +15,7 @@ jobs:
|
|
|
15
15
|
- name: 'Checkout Repository'
|
|
16
16
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
17
17
|
- name: 'Dependency Review'
|
|
18
|
-
uses: actions/dependency-review-action@
|
|
18
|
+
uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 #5.0.0
|
|
19
19
|
with:
|
|
20
20
|
# If it's a PR, use the target branch. If it's a push, use 'main'.
|
|
21
21
|
base-ref: ${{ github.event.pull_request.base.ref || 'main' }}
|
|
@@ -20,7 +20,7 @@ jobs:
|
|
|
20
20
|
with:
|
|
21
21
|
show-progress: false
|
|
22
22
|
|
|
23
|
-
- uses: ruby/setup-ruby@
|
|
23
|
+
- uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
|
|
24
24
|
with:
|
|
25
25
|
ruby-version: '3'
|
|
26
26
|
|
|
@@ -57,7 +57,7 @@ jobs:
|
|
|
57
57
|
node-version-file: '.nvmrc'
|
|
58
58
|
cache: 'npm'
|
|
59
59
|
|
|
60
|
-
- uses: ruby/setup-ruby@
|
|
60
|
+
- uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
|
|
61
61
|
with:
|
|
62
62
|
ruby-version: '3'
|
|
63
63
|
bundler-cache: true
|
data/.github/workflows/test.yaml
CHANGED
|
@@ -7,6 +7,11 @@ on:
|
|
|
7
7
|
branches: [ "main" ]
|
|
8
8
|
workflow_dispatch:
|
|
9
9
|
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read # Allows the action to check out your repository code
|
|
12
|
+
pull-requests: write # Allows the action to comment on or update the Dependabot PR
|
|
13
|
+
statuses: write # Allows the action to post pass/fail build statuses
|
|
14
|
+
|
|
10
15
|
jobs:
|
|
11
16
|
test:
|
|
12
17
|
name: Test
|
|
@@ -26,7 +31,7 @@ jobs:
|
|
|
26
31
|
node-version-file: '.nvmrc'
|
|
27
32
|
cache: 'npm'
|
|
28
33
|
|
|
29
|
-
- uses: ruby/setup-ruby@
|
|
34
|
+
- uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
|
|
30
35
|
with:
|
|
31
36
|
ruby-version: ${{ matrix.ruby }}
|
|
32
37
|
bundler-cache: true
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 6.2.4
|
|
2
|
+
|
|
3
|
+
- Support non-JSON response content types in OpenAPI renderer.
|
|
4
|
+
|
|
5
|
+
## 6.2.3
|
|
6
|
+
|
|
7
|
+
- [Fix TOC sidebar not scrolling to active item on page load](https://github.com/alphagov/tech-docs-gem/pull/480)
|
|
8
|
+
|
|
1
9
|
## 6.2.2
|
|
2
10
|
|
|
3
11
|
- Update [govuk_tech_docs.gemspec](govuk_tech_docs.gemspec) to only run `npm` if `npm` is installed. Allows gem versions scans to complete properly.
|
data/example/source/pets.yml
CHANGED
data/govuk_tech_docs.gemspec
CHANGED
|
@@ -45,7 +45,7 @@ Gem::Specification.new do |spec|
|
|
|
45
45
|
spec.add_dependency "chronic"
|
|
46
46
|
spec.add_dependency "concurrent-ruby"
|
|
47
47
|
spec.add_dependency "csv" # TODO: remove once tilt declares this itself.
|
|
48
|
-
spec.add_dependency "haml", "
|
|
48
|
+
spec.add_dependency "haml", ">= 6", "< 8" # middleman-core (4.6.3) depends on haml (>= 4.0.5, < 7)
|
|
49
49
|
spec.add_dependency "middleman"
|
|
50
50
|
spec.add_dependency "middleman-autoprefixer"
|
|
51
51
|
spec.add_dependency "middleman-compass"
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
'use strict'
|
|
3
3
|
|
|
4
4
|
Modules.InPageNavigation = function InPageNavigation () {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var $targets
|
|
5
|
+
let $contentPane
|
|
6
|
+
let $tocItems
|
|
7
|
+
let $targets
|
|
9
8
|
|
|
10
9
|
this.start = function start ($element) {
|
|
11
|
-
$tocPane = $element.find('.app-pane__toc')
|
|
12
10
|
$contentPane = $element.find('.app-pane__content')
|
|
13
11
|
$tocItems = $('.js-toc-list').find('a')
|
|
14
12
|
$targets = $contentPane.find('[id]')
|
|
@@ -29,7 +27,7 @@
|
|
|
29
27
|
} else {
|
|
30
28
|
// Store the initial position so that we can restore it even if we
|
|
31
29
|
// never scroll.
|
|
32
|
-
handleInitialLoadEvent
|
|
30
|
+
window.requestAnimationFrame(handleInitialLoadEvent)
|
|
33
31
|
}
|
|
34
32
|
}
|
|
35
33
|
}
|
|
@@ -41,7 +39,7 @@
|
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
function handleInitialLoadEvent () {
|
|
44
|
-
|
|
42
|
+
let fragment = fragmentForTargetElement()
|
|
45
43
|
|
|
46
44
|
if (!fragment) {
|
|
47
45
|
fragment = fragmentForFirstElementInView()
|
|
@@ -51,7 +49,7 @@
|
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
function handleScrollEvent () {
|
|
54
|
-
|
|
52
|
+
const fragment = fragmentForFirstElementInView()
|
|
55
53
|
|
|
56
54
|
storeCurrentPositionInHistoryApi(fragment)
|
|
57
55
|
highlightActiveItemInToc(fragment)
|
|
@@ -70,8 +68,8 @@
|
|
|
70
68
|
function highlightActiveItemInToc (fragment) {
|
|
71
69
|
// Navigation items for single page navigation don't necessarily include the path name, but
|
|
72
70
|
// navigation items for multipage navigation items do include it. This checks for either case.
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
let $activeTocItem = $tocItems.filter(function (_) {
|
|
72
|
+
const url = new URL($(this).attr('href'), window.location.href)
|
|
75
73
|
return url.href === window.location.href
|
|
76
74
|
})
|
|
77
75
|
|
|
@@ -79,35 +77,19 @@
|
|
|
79
77
|
// Check to see if any nav items contain just the path name.
|
|
80
78
|
if (!$activeTocItem.get(0)) {
|
|
81
79
|
$activeTocItem = $tocItems.filter(function (_) {
|
|
82
|
-
|
|
80
|
+
const url = new URL($(this).attr('href'), window.location.href)
|
|
83
81
|
return url.hash === '' && url.pathname === window.location.pathname
|
|
84
82
|
})
|
|
85
83
|
}
|
|
86
84
|
if ($activeTocItem.get(0)) {
|
|
87
85
|
$tocItems.removeClass('toc-link--in-view')
|
|
88
86
|
$activeTocItem.addClass('toc-link--in-view')
|
|
89
|
-
scrollTocToActiveItem($activeTocItem)
|
|
87
|
+
scrollTocToActiveItem($activeTocItem.get(0))
|
|
90
88
|
}
|
|
91
89
|
}
|
|
92
90
|
|
|
93
|
-
function scrollTocToActiveItem (
|
|
94
|
-
|
|
95
|
-
var linkTop = $activeTocItem.position().top
|
|
96
|
-
var linkBottom = linkTop + $activeTocItem.outerHeight()
|
|
97
|
-
|
|
98
|
-
var offset = null
|
|
99
|
-
|
|
100
|
-
if (linkTop < 0) {
|
|
101
|
-
offset = linkTop
|
|
102
|
-
} else if (linkBottom >= paneHeight) {
|
|
103
|
-
offset = -(paneHeight - linkBottom)
|
|
104
|
-
} else {
|
|
105
|
-
return
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
var newScrollTop = $tocPane.scrollTop() + offset
|
|
109
|
-
|
|
110
|
-
$tocPane.scrollTop(newScrollTop)
|
|
91
|
+
function scrollTocToActiveItem (activeTocElement) {
|
|
92
|
+
activeTocElement.scrollIntoView({ block: 'nearest', inline: 'nearest' })
|
|
111
93
|
}
|
|
112
94
|
|
|
113
95
|
function fragmentForTargetElement () {
|
|
@@ -115,14 +97,14 @@
|
|
|
115
97
|
}
|
|
116
98
|
|
|
117
99
|
function fragmentForFirstElementInView () {
|
|
118
|
-
|
|
100
|
+
let result = null
|
|
119
101
|
|
|
120
102
|
$($targets.get().reverse()).each(function checkIfInView (index) {
|
|
121
103
|
if (result) {
|
|
122
104
|
return
|
|
123
105
|
}
|
|
124
106
|
|
|
125
|
-
|
|
107
|
+
const $this = $(this)
|
|
126
108
|
|
|
127
109
|
if (Math.floor($this.position().top) <= 0) {
|
|
128
110
|
result = $this
|
|
@@ -58,12 +58,13 @@ module GovukTechDocs
|
|
|
58
58
|
operations = get_operations(@document.paths[text])
|
|
59
59
|
schemas = operations.flat_map do |_, operation|
|
|
60
60
|
operation.responses.inject([]) do |memo, (_, response)|
|
|
61
|
-
next memo unless response.content
|
|
61
|
+
next memo unless response.content
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
response.content.values.inject(memo) do |inner_memo, media_type|
|
|
64
|
+
schema = media_type.schema
|
|
65
|
+
inner_memo << schema.name if schema.name
|
|
66
|
+
inner_memo + schemas_from_schema(schema)
|
|
67
|
+
end
|
|
67
68
|
end
|
|
68
69
|
end
|
|
69
70
|
|
|
@@ -10,21 +10,31 @@
|
|
|
10
10
|
<td><%= key %></td>
|
|
11
11
|
<td>
|
|
12
12
|
<%= render_markdown(response.description) %>
|
|
13
|
-
<% if response.content
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
<% if response.content %>
|
|
14
|
+
<% response.content.each do |content_type, media_type| %>
|
|
15
|
+
<% request_body = nil
|
|
16
|
+
if content_type.include?("json")
|
|
17
|
+
if media_type["example"]
|
|
18
|
+
request_body = json_prettyprint(media_type["example"])
|
|
19
|
+
else
|
|
20
|
+
request_body = json_output(media_type.schema)
|
|
21
|
+
end
|
|
22
|
+
elsif media_type["example"]
|
|
23
|
+
request_body = media_type["example"].to_s
|
|
19
24
|
end %>
|
|
20
25
|
<% if !request_body.blank? %>
|
|
21
|
-
<
|
|
26
|
+
<p><em><%= content_type %></em></p>
|
|
27
|
+
<pre><code><%= ERB::Util.html_escape(request_body) %></code></pre>
|
|
28
|
+
<% end %>
|
|
29
|
+
<% end %>
|
|
22
30
|
<% end %>
|
|
23
31
|
</td>
|
|
24
32
|
<td>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
<% if response.content %>
|
|
34
|
+
<% response.content.each do |content_type, media_type| %>
|
|
35
|
+
<%= get_schema_link(media_type.schema) %>
|
|
36
|
+
<% end %>
|
|
37
|
+
<% end %>
|
|
28
38
|
</td>
|
|
29
39
|
</tr>
|
|
30
40
|
<% end %>
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: govuk_tech_docs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.2.
|
|
4
|
+
version: 6.2.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Government Digital Service
|
|
@@ -69,16 +69,22 @@ dependencies:
|
|
|
69
69
|
name: haml
|
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
|
71
71
|
requirements:
|
|
72
|
-
- - "
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '6'
|
|
75
|
+
- - "<"
|
|
73
76
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: '
|
|
77
|
+
version: '8'
|
|
75
78
|
type: :runtime
|
|
76
79
|
prerelease: false
|
|
77
80
|
version_requirements: !ruby/object:Gem::Requirement
|
|
78
81
|
requirements:
|
|
79
|
-
- - "
|
|
82
|
+
- - ">="
|
|
83
|
+
- !ruby/object:Gem::Version
|
|
84
|
+
version: '6'
|
|
85
|
+
- - "<"
|
|
80
86
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '
|
|
87
|
+
version: '8'
|
|
82
88
|
- !ruby/object:Gem::Dependency
|
|
83
89
|
name: middleman
|
|
84
90
|
requirement: !ruby/object:Gem::Requirement
|