govuk_tech_docs 1.5.0 → 1.6.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/.rubocop.yml +3 -0
- data/CHANGELOG.md +90 -0
- data/docs/configuration.md +15 -0
- data/docs/frontmatter.md +2 -14
- data/docs/page-expiry.md +69 -0
- data/example/Gemfile +1 -0
- data/example/config/tech-docs.yml +6 -0
- data/example/source/api-path.html.md +7 -0
- data/example/source/api-reference.html.md +5 -0
- data/example/source/pets.yml +106 -0
- data/govuk_tech_docs.gemspec +2 -0
- data/lib/assets/javascripts/_analytics.js +12 -0
- data/lib/assets/javascripts/_modules/collapsible-navigation.js +5 -3
- data/lib/assets/javascripts/_modules/search.js +175 -6
- data/lib/assets/stylesheets/modules/_collapsible.scss +12 -5
- data/lib/assets/stylesheets/modules/_technical-documentation.scss +16 -11
- data/lib/assets/stylesheets/modules/_toc.scss +1 -1
- data/lib/govuk_tech_docs.rb +13 -2
- data/lib/govuk_tech_docs/api_reference/api_reference_extension.rb +100 -0
- data/lib/govuk_tech_docs/api_reference/api_reference_renderer.rb +279 -0
- data/lib/govuk_tech_docs/api_reference/templates/api_reference_full.html.erb +9 -0
- data/lib/govuk_tech_docs/api_reference/templates/operation.html.erb +11 -0
- data/lib/govuk_tech_docs/api_reference/templates/parameters.html.erb +28 -0
- data/lib/govuk_tech_docs/api_reference/templates/path.html.erb +4 -0
- data/lib/govuk_tech_docs/api_reference/templates/responses.html.erb +33 -0
- data/lib/govuk_tech_docs/api_reference/templates/schema.html.erb +29 -0
- data/lib/govuk_tech_docs/page_review.rb +15 -3
- data/lib/govuk_tech_docs/pages.rb +3 -2
- data/lib/govuk_tech_docs/tech_docs_html_renderer.rb +10 -0
- data/lib/govuk_tech_docs/version.rb +1 -1
- data/lib/source/layouts/_header.erb +2 -4
- metadata +42 -4
- data/lib/source/images/arrow-down.svg +0 -9
- data/lib/source/images/arrow-up.svg +0 -9
@@ -0,0 +1,9 @@
|
|
1
|
+
<h1 id="<%= info.title.parameterize %>"><%= info.title %> v<%= info.version %></h1>
|
2
|
+
<%= markdown(info.description) %>
|
3
|
+
<% if server %>
|
4
|
+
<h2 id="base-url">Base URL</h2>
|
5
|
+
<p><strong><%= server.url %></strong></p>
|
6
|
+
<% end %>
|
7
|
+
<%= paths %>
|
8
|
+
<h2 id="schemas">Schemas</h2>
|
9
|
+
<%= schemas %>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<% if parameters.any? %>
|
2
|
+
<h4 id="<%= id %>">Parameters</h4>
|
3
|
+
<table>
|
4
|
+
<thead>
|
5
|
+
<tr><th>Parameter</th><th>In</th><th>Type</th><th>Required</th><th>Description</th></tr>
|
6
|
+
</thead>
|
7
|
+
<tbody>
|
8
|
+
<% parameters.each do |parameter| %>
|
9
|
+
<tr>
|
10
|
+
<td><%= parameter.name %></td>
|
11
|
+
<td><%= parameter.in %></td>
|
12
|
+
<td><%= parameter.schema.type %></td>
|
13
|
+
<td><%= parameter.required? %></td>
|
14
|
+
<td><%= markdown(parameter.description) %>
|
15
|
+
<% if parameter.schema.enum %>
|
16
|
+
<p>Available items:</p>
|
17
|
+
<ul>
|
18
|
+
<% parameter.schema.enum.each do |item| %>
|
19
|
+
<li><%= item %></li>
|
20
|
+
<% end %>
|
21
|
+
</ul>
|
22
|
+
<% end %>
|
23
|
+
</td>
|
24
|
+
</tr>
|
25
|
+
<% end %>
|
26
|
+
</tbody>
|
27
|
+
</table>
|
28
|
+
<% end %>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<% if responses.any? %>
|
2
|
+
<h4 id="<%= id %>">Responses</h4>
|
3
|
+
<table>
|
4
|
+
<thead>
|
5
|
+
<tr><th>Status</th><th>Description</th><th>Schema</th></tr>
|
6
|
+
</thead>
|
7
|
+
<tbody>
|
8
|
+
<% responses.each do |key,response| %>
|
9
|
+
<tr>
|
10
|
+
<td><%= key %></td>
|
11
|
+
<td>
|
12
|
+
<%= markdown(response.description) %>
|
13
|
+
<% if response.content['application/json']
|
14
|
+
if response.content['application/json']["example"]
|
15
|
+
request_body = json_prettyprint(response.content['application/json']["example"])
|
16
|
+
else
|
17
|
+
request_body = json_output(response.content['application/json'].schema)
|
18
|
+
end
|
19
|
+
end %>
|
20
|
+
<% if !request_body.blank? %>
|
21
|
+
<pre><code><%= request_body %></code></pre>
|
22
|
+
<% end %>
|
23
|
+
</td>
|
24
|
+
<td>
|
25
|
+
<%= if response.content['application/json']
|
26
|
+
get_schema_link(response.content['application/json'].schema)
|
27
|
+
end %>
|
28
|
+
</td>
|
29
|
+
</tr>
|
30
|
+
<% end %>
|
31
|
+
</tbody>
|
32
|
+
</table>
|
33
|
+
<% end %>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<h3 id="<%= id = 'schema-' + title; id.parameterize %>"><%= title %></h3>
|
2
|
+
<%= markdown(schema.description) %>
|
3
|
+
<% if properties.any? %>
|
4
|
+
<table>
|
5
|
+
<thead>
|
6
|
+
<tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th><th>Schema</th></tr>
|
7
|
+
</thead>
|
8
|
+
<tbody>
|
9
|
+
<% properties.each do |property| %>
|
10
|
+
<tr>
|
11
|
+
<td><%= property[0] %></td>
|
12
|
+
<td><%= property[1].type %></td>
|
13
|
+
<td><%= property[1].required.present? %></td>
|
14
|
+
<td><%= markdown(property[1].description) %></td>
|
15
|
+
<td>
|
16
|
+
<%=
|
17
|
+
schema = property[1]
|
18
|
+
# If property is an array, check the items property for a reference.
|
19
|
+
if property[1].type == 'array'
|
20
|
+
schema = property[1]['items']
|
21
|
+
end
|
22
|
+
# Only print a link if it's a referenced object.
|
23
|
+
get_schema_link(schema) if schema.node_context.referenced_by.to_s.include? '#/components/schemas' and !schema.node_context.source_location.to_s.include? '/properties/' %>
|
24
|
+
</td>
|
25
|
+
</tr>
|
26
|
+
<% end %>
|
27
|
+
</tbody>
|
28
|
+
</table>
|
29
|
+
<% end %>
|
@@ -2,8 +2,9 @@ module GovukTechDocs
|
|
2
2
|
class PageReview
|
3
3
|
attr_reader :page
|
4
4
|
|
5
|
-
def initialize(page)
|
5
|
+
def initialize(page, config = {})
|
6
6
|
@page = page
|
7
|
+
@config = config
|
7
8
|
end
|
8
9
|
|
9
10
|
def review_by
|
@@ -24,13 +25,24 @@ module GovukTechDocs
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def owner_slack
|
27
|
-
page.data.owner_slack
|
28
|
+
page.data.owner_slack || default_owner_slack
|
28
29
|
end
|
29
30
|
|
30
31
|
def owner_slack_url
|
32
|
+
return "" unless owner_slack_workspace
|
31
33
|
# Slack URLs don't have the # (channels) or @ (usernames)
|
32
34
|
slack_identifier = owner_slack.to_s.delete('#').delete('@')
|
33
|
-
"https
|
35
|
+
"https://#{owner_slack_workspace}.slack.com/messages/#{slack_identifier}"
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def default_owner_slack
|
41
|
+
@config[:tech_docs][:default_owner_slack]
|
42
|
+
end
|
43
|
+
|
44
|
+
def owner_slack_workspace
|
45
|
+
@config[:tech_docs][:owner_slack_workspace]
|
34
46
|
end
|
35
47
|
end
|
36
48
|
end
|
@@ -15,11 +15,12 @@ module GovukTechDocs
|
|
15
15
|
|
16
16
|
def as_json
|
17
17
|
pages.map do |page|
|
18
|
+
review = PageReview.new(page, @config)
|
18
19
|
{
|
19
20
|
title: page.data.title,
|
20
21
|
url: "#{@config[:tech_docs][:host]}#{page.url}",
|
21
|
-
review_by:
|
22
|
-
owner_slack:
|
22
|
+
review_by: review.review_by,
|
23
|
+
owner_slack: review.owner_slack,
|
23
24
|
}
|
24
25
|
end
|
25
26
|
end
|
@@ -4,6 +4,16 @@ module GovukTechDocs
|
|
4
4
|
class TechDocsHTMLRenderer < Middleman::Renderers::MiddlemanRedcarpetHTML
|
5
5
|
include Redcarpet::Render::SmartyPants
|
6
6
|
|
7
|
+
def initialize(options = {})
|
8
|
+
@local_options = options.dup
|
9
|
+
@app = @local_options[:context].app
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
def paragraph(text)
|
14
|
+
@app.api("<p>#{text.strip}</p>\n")
|
15
|
+
end
|
16
|
+
|
7
17
|
def header(text, level)
|
8
18
|
anchor = UniqueIdentifierGenerator.instance.create(text, level)
|
9
19
|
%(<h#{level} id="#{anchor}">#{text}</h#{level}>)
|
@@ -8,7 +8,7 @@
|
|
8
8
|
<% end %>
|
9
9
|
<% if config[:tech_docs][:show_govuk_logo] %>
|
10
10
|
<span class="govuk-logo">
|
11
|
-
<img class="govuk-logo__printable-crown" src="/images/gov.uk_logotype_crown_invert_trans.png" height="32" width="36">
|
11
|
+
<img class="govuk-logo__printable-crown" src="/images/gov.uk_logotype_crown_invert_trans.png" height="32" width="36" alt="">
|
12
12
|
GOV.UK
|
13
13
|
</span>
|
14
14
|
<% end %>
|
@@ -33,9 +33,7 @@
|
|
33
33
|
<ul>
|
34
34
|
<% config[:tech_docs][:header_links].each do |title, path| %>
|
35
35
|
<li<% if active_page(path) %> class="active"<% end %>>
|
36
|
-
<a href="<%= path %>">
|
37
|
-
<%= title %>
|
38
|
-
</a>
|
36
|
+
<a href="<%= path %>"><%= title %></a>
|
39
37
|
</li>
|
40
38
|
<% end %>
|
41
39
|
</ul>
|
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: 1.
|
4
|
+
version: 1.6.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: 2018-
|
11
|
+
date: 2018-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -164,6 +164,34 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: 3.3.2
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: openapi3_parser
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: pry
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
167
195
|
- !ruby/object:Gem::Dependency
|
168
196
|
name: bundler
|
169
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -274,10 +302,13 @@ files:
|
|
274
302
|
- docs/frontmatter.md
|
275
303
|
- docs/layout-layout.png
|
276
304
|
- docs/not-expired-page.png
|
305
|
+
- docs/page-expiry.md
|
277
306
|
- example/.ruby-version
|
278
307
|
- example/Gemfile
|
279
308
|
- example/config.rb
|
280
309
|
- example/config/tech-docs.yml
|
310
|
+
- example/source/api-path.html.md
|
311
|
+
- example/source/api-reference.html.md
|
281
312
|
- example/source/child-of-expired-page.html.md
|
282
313
|
- example/source/core-layout.html.md.erb
|
283
314
|
- example/source/expired-page-with-owner.html.md
|
@@ -286,6 +317,7 @@ files:
|
|
286
317
|
- example/source/index.html.md.erb
|
287
318
|
- example/source/javascripts/application.js
|
288
319
|
- example/source/not-expired-page.html.md
|
320
|
+
- example/source/pets.yml
|
289
321
|
- example/source/stylesheets/print.css.scss
|
290
322
|
- example/source/stylesheets/screen-old-ie.css.scss
|
291
323
|
- example/source/stylesheets/screen.css.scss
|
@@ -347,6 +379,14 @@ files:
|
|
347
379
|
- lib/assets/stylesheets/utilities/_printable.scss
|
348
380
|
- lib/assets/stylesheets/vendor/_fixedsticky.scss
|
349
381
|
- lib/govuk_tech_docs.rb
|
382
|
+
- lib/govuk_tech_docs/api_reference/api_reference_extension.rb
|
383
|
+
- lib/govuk_tech_docs/api_reference/api_reference_renderer.rb
|
384
|
+
- lib/govuk_tech_docs/api_reference/templates/api_reference_full.html.erb
|
385
|
+
- lib/govuk_tech_docs/api_reference/templates/operation.html.erb
|
386
|
+
- lib/govuk_tech_docs/api_reference/templates/parameters.html.erb
|
387
|
+
- lib/govuk_tech_docs/api_reference/templates/path.html.erb
|
388
|
+
- lib/govuk_tech_docs/api_reference/templates/responses.html.erb
|
389
|
+
- lib/govuk_tech_docs/api_reference/templates/schema.html.erb
|
350
390
|
- lib/govuk_tech_docs/contribution_banner.rb
|
351
391
|
- lib/govuk_tech_docs/meta_tags.rb
|
352
392
|
- lib/govuk_tech_docs/page_review.rb
|
@@ -366,8 +406,6 @@ files:
|
|
366
406
|
- lib/source/favicon.ico
|
367
407
|
- lib/source/images/anchored-heading-icon-2x.png
|
368
408
|
- lib/source/images/anchored-heading-icon.png
|
369
|
-
- lib/source/images/arrow-down.svg
|
370
|
-
- lib/source/images/arrow-up.svg
|
371
409
|
- lib/source/images/gov.uk_logotype_crown-2x.png
|
372
410
|
- lib/source/images/gov.uk_logotype_crown.png
|
373
411
|
- lib/source/images/gov.uk_logotype_crown_invert_trans.png
|
@@ -1,9 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
2
|
-
<!-- Generator: Adobe Illustrator 22.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3
|
-
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
4
|
-
viewBox="0 0 34 34" style="enable-background:new 0 0 34 34;" xml:space="preserve">
|
5
|
-
<style type="text/css">
|
6
|
-
.st0{fill:#0B0C0C;}
|
7
|
-
</style>
|
8
|
-
<polygon class="st0" points="17,25.7 1.6,11.5 4.4,8.5 17,20.3 29.6,8.5 32.4,11.5 "/>
|
9
|
-
</svg>
|
@@ -1,9 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
2
|
-
<!-- Generator: Adobe Illustrator 22.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3
|
-
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
4
|
-
viewBox="0 0 34 34" style="enable-background:new 0 0 34 34;" xml:space="preserve">
|
5
|
-
<style type="text/css">
|
6
|
-
.st0{fill:#0B0C0C;}
|
7
|
-
</style>
|
8
|
-
<polygon class="st0" points="29.6,25.5 17,13.7 4.4,25.5 1.6,22.5 17,8.3 32.4,22.5 "/>
|
9
|
-
</svg>
|