govuk_tech_docs 3.0.0 → 3.2.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.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE.md +13 -0
- data/.github/pull_request_template.md +14 -1
- data/.github/workflows/publish.yaml +76 -0
- data/.github/workflows/test.yaml +23 -0
- data/CHANGELOG.md +30 -0
- data/lib/assets/javascripts/_modules/collapsible-navigation.js +13 -7
- data/lib/assets/javascripts/_modules/in-page-navigation.js +9 -4
- data/lib/assets/javascripts/_modules/search.js +11 -7
- data/lib/assets/stylesheets/_govuk_tech_docs.scss +1 -1
- data/lib/assets/stylesheets/modules/_anchored-heading.scss +2 -2
- data/lib/assets/stylesheets/modules/_search.scss +2 -2
- data/lib/assets/stylesheets/modules/_toc.scss +4 -4
- data/lib/govuk_tech_docs/api_reference/api_reference_renderer.rb +10 -0
- data/lib/govuk_tech_docs/api_reference/templates/api_reference_full.html.erb +2 -2
- data/lib/govuk_tech_docs/api_reference/templates/operation.html.erb +1 -1
- data/lib/govuk_tech_docs/api_reference/templates/parameters.html.erb +1 -1
- data/lib/govuk_tech_docs/api_reference/templates/responses.html.erb +1 -1
- data/lib/govuk_tech_docs/api_reference/templates/schema.html.erb +2 -2
- data/lib/govuk_tech_docs/contribution_banner.rb +8 -2
- data/lib/govuk_tech_docs/pages.rb +4 -2
- data/lib/govuk_tech_docs/path_helpers.rb +30 -0
- data/lib/govuk_tech_docs/table_of_contents/helpers.rb +7 -7
- data/lib/govuk_tech_docs/version.rb +1 -1
- data/lib/govuk_tech_docs.rb +1 -0
- data/lib/source/api/pages.json.erb +1 -1
- data/lib/source/layouts/_header.erb +3 -3
- data/lib/source/layouts/_search.erb +1 -1
- data/lib/source/layouts/core.erb +1 -1
- data/node_modules/govuk-frontend/govuk/all.js +272 -75
- data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +275 -98
- data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +169 -65
- data/node_modules/govuk-frontend/govuk/components/button/_index.scss +3 -4
- data/node_modules/govuk-frontend/govuk/components/button/button.js +2 -2
- data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +3 -3
- data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +14 -0
- data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +8 -10
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/_index.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/details/_index.scss +2 -1
- data/node_modules/govuk-frontend/govuk/components/details/details.js +2 -2
- data/node_modules/govuk-frontend/govuk/components/error-message/_index.scss +1 -0
- data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +2 -2
- data/node_modules/govuk-frontend/govuk/components/file-upload/_index.scss +1 -0
- data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +6 -37
- data/node_modules/govuk-frontend/govuk/components/header/_index.scss +10 -4
- data/node_modules/govuk-frontend/govuk/components/header/header.js +4 -4
- data/node_modules/govuk-frontend/govuk/components/hint/_index.scss +1 -3
- data/node_modules/govuk-frontend/govuk/components/input/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +499 -2
- data/node_modules/govuk-frontend/govuk/components/panel/_index.scss +13 -1
- data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +14 -0
- data/node_modules/govuk-frontend/govuk/components/radios/radios.js +4 -4
- data/node_modules/govuk-frontend/govuk/components/select/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +13 -0
- data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +1108 -0
- data/node_modules/govuk-frontend/govuk/components/summary-list/_index.scss +15 -23
- data/node_modules/govuk-frontend/govuk/components/tabs/_index.scss +2 -2
- data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +2 -2
- data/node_modules/govuk-frontend/govuk/components/tag/_index.scss +0 -5
- data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/core/_all.scss +0 -1
- data/node_modules/govuk-frontend/govuk/core/_global-styles.scss +0 -6
- data/node_modules/govuk-frontend/govuk/core/_links.scss +0 -6
- data/node_modules/govuk-frontend/govuk/core/_lists.scss +0 -6
- data/node_modules/govuk-frontend/govuk/core/_section-break.scss +0 -6
- data/node_modules/govuk-frontend/govuk/core/_typography.scss +0 -6
- data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +2 -2
- data/node_modules/govuk-frontend/govuk/helpers/_spacing.scss +22 -4
- data/node_modules/govuk-frontend/govuk/objects/_all.scss +1 -0
- data/node_modules/govuk-frontend/govuk/objects/_main-wrapper.scss +15 -30
- data/node_modules/govuk-frontend/govuk/{core → objects}/_template.scss +1 -5
- data/node_modules/govuk-frontend/govuk/overrides/_all.scss +1 -0
- data/node_modules/govuk-frontend/govuk/overrides/_display.scss +0 -6
- data/node_modules/govuk-frontend/govuk/overrides/_spacing.scss +0 -6
- data/node_modules/govuk-frontend/govuk/overrides/_text-align.scss +14 -0
- data/node_modules/govuk-frontend/govuk/overrides/_typography.scss +0 -6
- data/node_modules/govuk-frontend/govuk/overrides/_width.scss +0 -6
- data/node_modules/govuk-frontend/govuk/settings/_colours-organisations.scss +3 -0
- data/node_modules/govuk-frontend/govuk/settings/_measurements.scss +0 -10
- data/node_modules/govuk-frontend/govuk/tools/_all.scss +0 -1
- data/package-lock.json +6 -6
- data/package.json +1 -1
- metadata +13 -9
- data/.travis.yml +0 -19
- data/node_modules/govuk-frontend/govuk/tools/_iff.scss +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06ad063ddc3de387b2bae379df43d4ecd6996a42bdc1f0472e2eb46b404b5701
|
4
|
+
data.tar.gz: 23b17f1d49d77303d7acb06be0ee2f30cd8ec9b40407b18689696008bf594b89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfff9af883e1eb613f704789bd55f65947309e5df3a7a1d1280f4a28483a55d38200108d9808279d3985e2fd75bdc86adccea94520bb7469a78cdfa654def53c
|
7
|
+
data.tar.gz: '09ae4a42091646b3850af6e4db030a0912e48a10df7b0db296621cdaa58c5df236c17399374201fe2f4af4bd38ce9525837a0811145cfea5fa380b70c5836541'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<!--
|
2
|
+
Please fill in the sections below.
|
3
|
+
|
4
|
+
After you submit your issue, the technical writing team from the Central Digital and Data Office (CDDO) will discuss and prioritise it at our fortnightly triage meeting. We’ll then let you know if and when we’ll move it forward.
|
5
|
+
-->
|
6
|
+
|
7
|
+
## What should change
|
8
|
+
|
9
|
+
<!-- What would fix the issue? Is this something you think should behave differently, or something that you currently cannot do? -->
|
10
|
+
|
11
|
+
## User need
|
12
|
+
|
13
|
+
<!-- Do you have evidence that this meets the needs of users? Let us know about any user research or testing you’ve done. -->
|
@@ -1 +1,14 @@
|
|
1
|
-
|
1
|
+
<!--
|
2
|
+
## Please fill in the sections below
|
3
|
+
|
4
|
+
After you submit your pull request, the technical writing team from the Central Digital and Data Office (CDDO) will discuss and prioritise it at our fortnightly triage meeting. We’ll then let you know if and when we’ll move it forward.
|
5
|
+
-->
|
6
|
+
|
7
|
+
## What’s changed
|
8
|
+
|
9
|
+
<!-- What are you trying to do? Is this something that changes how the Tech Docs Template behaves, or is it fixing a bug? -->
|
10
|
+
|
11
|
+
|
12
|
+
## Identifying a user need
|
13
|
+
|
14
|
+
<!-- Do you have evidence that this meets the needs of users? Let us know about any user research or testing you’ve done. -->
|
@@ -0,0 +1,76 @@
|
|
1
|
+
name: Publish
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
workflow_dispatch:
|
8
|
+
|
9
|
+
concurrency: rubygems
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
pre:
|
13
|
+
name: Pre-flight checks
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
outputs:
|
16
|
+
go: ${{ steps.gem_version.outputs.new_version }}
|
17
|
+
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v2
|
20
|
+
|
21
|
+
- uses: ruby/setup-ruby@v1
|
22
|
+
|
23
|
+
- name: Check if new version to release
|
24
|
+
id: gem_version
|
25
|
+
run: |
|
26
|
+
gem_version=$(ruby -r rubygems -e "puts Gem::Specification::load('govuk_tech_docs.gemspec').version")
|
27
|
+
echo "::set-output name=gem_version::$gem_version"
|
28
|
+
|
29
|
+
if git fetch origin "refs/tags/v$gem_version" >/dev/null 2>&1
|
30
|
+
then
|
31
|
+
echo "Tag 'v$gem_version' already exists"
|
32
|
+
echo "::set-output name=new_version::false"
|
33
|
+
else
|
34
|
+
echo "::set-output name=new_version::true"
|
35
|
+
fi
|
36
|
+
|
37
|
+
deploy:
|
38
|
+
name: Publish Ruby Gem
|
39
|
+
environment: rubygems
|
40
|
+
permissions:
|
41
|
+
contents: write # needed to be able to tag the release
|
42
|
+
runs-on: ubuntu-latest
|
43
|
+
needs: pre
|
44
|
+
if: ${{ needs.pre.outputs.go == 'true' }}
|
45
|
+
|
46
|
+
steps:
|
47
|
+
- uses: actions/checkout@v2
|
48
|
+
|
49
|
+
- uses: actions/setup-node@v2
|
50
|
+
with:
|
51
|
+
cache: 'npm'
|
52
|
+
node-version: '14'
|
53
|
+
|
54
|
+
- uses: ruby/setup-ruby@v1
|
55
|
+
with:
|
56
|
+
bundler-cache: true
|
57
|
+
|
58
|
+
- name: Publish
|
59
|
+
env:
|
60
|
+
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
|
61
|
+
run: |
|
62
|
+
mkdir -p ~/.gem
|
63
|
+
|
64
|
+
cat << EOF > ~/.gem/credentials
|
65
|
+
---
|
66
|
+
:rubygems_api_key: ${RUBYGEMS_API_KEY}
|
67
|
+
EOF
|
68
|
+
|
69
|
+
chmod 0600 ~/.gem/credentials
|
70
|
+
|
71
|
+
# tag will be associated with github-actions bot user, see
|
72
|
+
# https://github.community/t/github-actions-bot-email-address/17204
|
73
|
+
git config user.name "github-actions[bot]"
|
74
|
+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
75
|
+
|
76
|
+
bundle exec rake release
|
@@ -0,0 +1,23 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
name: Test
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v2
|
12
|
+
|
13
|
+
- uses: actions/setup-node@v2
|
14
|
+
with:
|
15
|
+
node-version: '14'
|
16
|
+
cache: 'npm'
|
17
|
+
|
18
|
+
- uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
bundler-cache: true
|
21
|
+
|
22
|
+
- name: Run tests
|
23
|
+
run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,36 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 3.2.0
|
6
|
+
|
7
|
+
### New features
|
8
|
+
|
9
|
+
You can now [configure your Tech Docs Template (TDT) to build your documentation site to use relative links to pages and assets](https://tdt-documentation.london.cloudapps.digital/configure_project/global_configuration/#build-your-site-using-relative-links).
|
10
|
+
|
11
|
+
Thanks [@eddgrant](https://github.com/eddgrant) for contributing this feature and the associated fixes.
|
12
|
+
|
13
|
+
This change was introduced in [pull request #291: Support sites deployed on paths other than "/" (by generating relative links)](https://github.com/alphagov/tech-docs-gem/pull/291).
|
14
|
+
|
15
|
+
## 3.1.0
|
16
|
+
|
17
|
+
### New features
|
18
|
+
|
19
|
+
There are some steps you should follow as the Technical Documentation Template (TDT) now uses GOV.UK Frontend 4.0.0.
|
20
|
+
|
21
|
+
1. Update your documentation site to use the latest template version. You can [follow the TDT guidance on using the latest template version](https://tdt-documentation.london.cloudapps.digital/maintain_project/use_latest_template/).
|
22
|
+
2. Check your documentation site displays correctly. If your site does not display correctly, you can refer to the [GOV.UK Frontend 4.0.0 release note](https://github.com/alphagov/govuk-frontend/releases/tag/v4.0.0) for more information.
|
23
|
+
|
24
|
+
## 3.0.1
|
25
|
+
|
26
|
+
### Fixes
|
27
|
+
|
28
|
+
We’ve made the following fixes to the tech docs gem in [pull request #281: Don't break TOC when OpenAPI description includes headers](https://github.com/alphagov/tech-docs-gem/pull/281):
|
29
|
+
|
30
|
+
* we now render OpenAPI Markdown with the same Markdown renderer as other documents
|
31
|
+
* table of contents (TOC) uses `TechDocsHTMLRenderer` to render the headings with IDs
|
32
|
+
|
33
|
+
Thanks to [@jamietanna](https://github.com/jamietanna) for contributing to this issue and its solution.
|
34
|
+
|
5
35
|
## 3.0.0
|
6
36
|
|
7
37
|
### Breaking changes
|
@@ -57,25 +57,31 @@
|
|
57
57
|
$toggleLabel.text(setOpen ? 'Collapse ' + $heading.text() : 'Expand ' + $heading.text())
|
58
58
|
}
|
59
59
|
|
60
|
+
/**
|
61
|
+
* Returns an absolute pathname to $target by combining it with window.location.href
|
62
|
+
* @param $target The target whose pathname to return. This may be an anchor with an absolute or relative href.
|
63
|
+
* @returns {string} The absolute pathname of $target
|
64
|
+
*/
|
65
|
+
function getAbsolutePath ($target) {
|
66
|
+
return new URL($target.attr('href'), window.location.href).pathname
|
67
|
+
}
|
68
|
+
|
60
69
|
function openActiveHeading () {
|
61
70
|
var $activeElement
|
62
71
|
var currentPath = window.location.pathname
|
63
|
-
var isActiveTrail = '[href*="' + currentPath + '"]'
|
64
|
-
// Add an exception for the root page, as every href includes /
|
65
|
-
if (currentPath === '/') {
|
66
|
-
isActiveTrail = '[href="' + currentPath + window.location.hash + '"]'
|
67
|
-
}
|
68
72
|
for (var i = $topLevelItems.length - 1; i >= 0; i--) {
|
69
73
|
var $element = $($topLevelItems[i])
|
70
74
|
var $heading = $element.find('> a')
|
71
75
|
// Check if this item href matches
|
72
|
-
if ($heading
|
76
|
+
if (getAbsolutePath($heading) === currentPath) {
|
73
77
|
$activeElement = $element
|
74
78
|
break
|
75
79
|
}
|
76
80
|
// Otherwise check the children
|
77
81
|
var $children = $element.find('li > a')
|
78
|
-
var $matchingChildren = $children.filter(
|
82
|
+
var $matchingChildren = $children.filter(function (_) {
|
83
|
+
return getAbsolutePath($(this)) === currentPath
|
84
|
+
})
|
79
85
|
if ($matchingChildren.length) {
|
80
86
|
$activeElement = $element
|
81
87
|
break
|
@@ -70,13 +70,18 @@
|
|
70
70
|
function highlightActiveItemInToc (fragment) {
|
71
71
|
// Navigation items for single page navigation don't necessarily include the path name, but
|
72
72
|
// navigation items for multipage navigation items do include it. This checks for either case.
|
73
|
-
var $activeTocItem = $tocItems.filter(
|
74
|
-
'
|
75
|
-
|
73
|
+
var $activeTocItem = $tocItems.filter(function (_) {
|
74
|
+
var url = new URL($(this).attr('href'), window.location.href)
|
75
|
+
return url.href === window.location.href
|
76
|
+
})
|
77
|
+
|
76
78
|
// Navigation items with children don't contain fragments in their url
|
77
79
|
// Check to see if any nav items contain just the path name.
|
78
80
|
if (!$activeTocItem.get(0)) {
|
79
|
-
$activeTocItem = $tocItems.filter(
|
81
|
+
$activeTocItem = $tocItems.filter(function (_) {
|
82
|
+
var url = new URL($(this).attr('href'), window.location.href)
|
83
|
+
return url.hash === '' && url.pathname === window.location.pathname
|
84
|
+
})
|
80
85
|
}
|
81
86
|
if ($activeTocItem.get(0)) {
|
82
87
|
$tocItems.removeClass('toc-link--in-view')
|
@@ -16,6 +16,7 @@
|
|
16
16
|
var results
|
17
17
|
var query
|
18
18
|
var maxSearchEntries = 20
|
19
|
+
var pathToSiteRoot
|
19
20
|
|
20
21
|
this.start = function start ($element) {
|
21
22
|
$searchForm = $element.find('form')
|
@@ -25,6 +26,7 @@
|
|
25
26
|
$searchResults = $searchResultsWrapper.find('.search-results__content')
|
26
27
|
$searchResultsTitle = $searchResultsWrapper.find('.search-results__title')
|
27
28
|
$searchHelp = $('#search-help')
|
29
|
+
pathToSiteRoot = $element.data('pathToSiteRoot')
|
28
30
|
|
29
31
|
changeSearchAction()
|
30
32
|
changeSearchLabel()
|
@@ -38,7 +40,7 @@
|
|
38
40
|
query = s.getQuery()
|
39
41
|
if (query) {
|
40
42
|
$searchInput.val(query)
|
41
|
-
doSearch(query)
|
43
|
+
doSearch(query, pathToSiteRoot)
|
42
44
|
doAnalytics()
|
43
45
|
document.title = query + ' - ' + document.title
|
44
46
|
}
|
@@ -49,7 +51,7 @@
|
|
49
51
|
this.downloadSearchIndex = function downloadSearchIndex () {
|
50
52
|
updateTitle('Loading search results')
|
51
53
|
$.ajax({
|
52
|
-
url: '
|
54
|
+
url: pathToSiteRoot + 'search.json',
|
53
55
|
cache: true,
|
54
56
|
method: 'GET',
|
55
57
|
success: function (data) {
|
@@ -65,7 +67,7 @@
|
|
65
67
|
// We need JavaScript to do search, so if JS is not available the search
|
66
68
|
// input sends the query string to Google. This JS function changes the
|
67
69
|
// input to instead send it to the search page.
|
68
|
-
$searchForm.prop('action', '/
|
70
|
+
$searchForm.prop('action', pathToSiteRoot + 'search/index.html')
|
69
71
|
$searchForm.find('input[name="as_sitesearch"]').remove()
|
70
72
|
}
|
71
73
|
|
@@ -86,10 +88,10 @@
|
|
86
88
|
return query
|
87
89
|
}
|
88
90
|
|
89
|
-
function doSearch (query) {
|
91
|
+
function doSearch (query, pathToSiteRoot) {
|
90
92
|
s.search(query, function (r) {
|
91
93
|
results = r
|
92
|
-
renderResults(query)
|
94
|
+
renderResults(query, pathToSiteRoot)
|
93
95
|
updateTitle()
|
94
96
|
})
|
95
97
|
}
|
@@ -138,7 +140,7 @@
|
|
138
140
|
callback(getResults(query))
|
139
141
|
}
|
140
142
|
|
141
|
-
function renderResults (query) {
|
143
|
+
function renderResults (query, pathToSiteRoot) {
|
142
144
|
var output = ''
|
143
145
|
if (results.length === 0) {
|
144
146
|
output += '<p>Nothing found</p>'
|
@@ -149,7 +151,9 @@
|
|
149
151
|
var content = s.processContent(result.content, query)
|
150
152
|
output += '<li class="search-result">'
|
151
153
|
output += '<h3 class="search-result__title">'
|
152
|
-
|
154
|
+
var pagePathWithoutLeadingSlash = result.url.startsWith('/') ? result.url.slice(1) : result.url
|
155
|
+
var url = pathToSiteRoot.startsWith('.') ? pathToSiteRoot + pagePathWithoutLeadingSlash : '/' + pagePathWithoutLeadingSlash
|
156
|
+
output += '<a href="' + url + '">'
|
153
157
|
output += result.title
|
154
158
|
output += '</a>'
|
155
159
|
output += '</h3>'
|
@@ -18,12 +18,12 @@
|
|
18
18
|
text-decoration: none;
|
19
19
|
text-indent: -9999em;
|
20
20
|
|
21
|
-
background-image: url('/images/anchored-heading-icon.png');
|
21
|
+
background-image: image-url('/images/anchored-heading-icon.png');
|
22
22
|
background-repeat: no-repeat;
|
23
23
|
background-position: center center;
|
24
24
|
|
25
25
|
@include govuk-device-pixel-ratio {
|
26
|
-
background-image: url('/images/anchored-heading-icon-2x.png');
|
26
|
+
background-image: image-url('/images/anchored-heading-icon-2x.png');
|
27
27
|
background-size: $icon-width $icon-height;
|
28
28
|
}
|
29
29
|
|
@@ -36,7 +36,7 @@ $input-size: 40px;
|
|
36
36
|
padding: 0;
|
37
37
|
width: $input-size;
|
38
38
|
height: 100%;
|
39
|
-
background-image: url('/images/search-button.png');
|
39
|
+
background-image: image-url('/images/search-button.png');
|
40
40
|
background-repeat: no-repeat;
|
41
41
|
background-position: 2px 50%;
|
42
42
|
text-indent: -5000px;
|
@@ -104,7 +104,7 @@ $input-size: 40px;
|
|
104
104
|
left: -9px;
|
105
105
|
width: 10px;
|
106
106
|
height: 20px;
|
107
|
-
background: no-repeat url('/images/search-result-caret.svg') center right;
|
107
|
+
background: no-repeat image-url('/images/search-result-caret.svg') center right;
|
108
108
|
background-size: contain;
|
109
109
|
}
|
110
110
|
}
|
@@ -152,12 +152,12 @@
|
|
152
152
|
height: 20px;
|
153
153
|
float: right;
|
154
154
|
|
155
|
-
background-image: url('/images/govuk-icn-numbered-list.png');
|
155
|
+
background-image: image-url('/images/govuk-icn-numbered-list.png');
|
156
156
|
background-repeat: no-repeat;
|
157
157
|
background-position: left center;
|
158
158
|
|
159
159
|
@include govuk-device-pixel-ratio {
|
160
|
-
background-image: url('/images/govuk-icn-numbered-list@2x.png');
|
160
|
+
background-image: image-url('/images/govuk-icn-numbered-list@2x.png');
|
161
161
|
background-size: 20px 20px;
|
162
162
|
}
|
163
163
|
}
|
@@ -178,12 +178,12 @@
|
|
178
178
|
height: 20px;
|
179
179
|
cursor: pointer;
|
180
180
|
|
181
|
-
background-image: url('/images/govuk-icn-close.png');
|
181
|
+
background-image: image-url('/images/govuk-icn-close.png');
|
182
182
|
background-repeat: no-repeat;
|
183
183
|
background-position: left center;
|
184
184
|
|
185
185
|
@include govuk-device-pixel-ratio {
|
186
|
-
background-image: url('/images/govuk-icn-close@2x.png');
|
186
|
+
background-image: image-url('/images/govuk-icn-close@2x.png');
|
187
187
|
background-size: 20px 20px;
|
188
188
|
}
|
189
189
|
|
@@ -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.
|
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 %>
|
@@ -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.
|
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.
|
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.
|
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.
|
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
|
28
|
+
url = "#{repo_url}/issues/new"
|
29
|
+
params["labels"] = "bug"
|
30
|
+
params["title"] = "Re: '#{current_page.data.title}'"
|
26
31
|
else
|
27
|
-
"
|
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,10 +1,12 @@
|
|
1
1
|
module GovukTechDocs
|
2
2
|
class Pages
|
3
|
+
include GovukTechDocs::PathHelpers
|
3
4
|
attr_reader :sitemap
|
4
5
|
|
5
|
-
def initialize(sitemap, config)
|
6
|
+
def initialize(sitemap, config, current_page)
|
6
7
|
@sitemap = sitemap
|
7
8
|
@config = config
|
9
|
+
@current_page = current_page
|
8
10
|
end
|
9
11
|
|
10
12
|
def to_json(*_args)
|
@@ -18,7 +20,7 @@ module GovukTechDocs
|
|
18
20
|
review = PageReview.new(page, @config)
|
19
21
|
{
|
20
22
|
title: page.data.title,
|
21
|
-
url:
|
23
|
+
url: get_path_to_resource(@config, page, @current_page).to_s,
|
22
24
|
review_by: review.review_by,
|
23
25
|
owner_slack: review.owner_slack,
|
24
26
|
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module GovukTechDocs
|
2
|
+
module PathHelpers
|
3
|
+
def get_path_to_resource(config, resource, current_page)
|
4
|
+
if config[:relative_links]
|
5
|
+
resource_path_segments = resource.path.split("/").reject(&:empty?)[0..-2]
|
6
|
+
resource_file_name = resource.path.split("/")[-1]
|
7
|
+
|
8
|
+
path_to_site_root = path_to_site_root config, current_page.path
|
9
|
+
resource_path = path_to_site_root + resource_path_segments
|
10
|
+
.push(resource_file_name)
|
11
|
+
.join("/")
|
12
|
+
else
|
13
|
+
resource_path = resource.url
|
14
|
+
end
|
15
|
+
resource_path
|
16
|
+
end
|
17
|
+
|
18
|
+
def path_to_site_root(config, page_path)
|
19
|
+
if config[:relative_links]
|
20
|
+
number_of_ascents_to_site_root = page_path.to_s.split("/").reject(&:empty?)[0..-2].length
|
21
|
+
ascents = number_of_ascents_to_site_root.zero? ? ["."] : number_of_ascents_to_site_root.times.collect { ".." }
|
22
|
+
path_to_site_root = ascents.join("/").concat("/")
|
23
|
+
else
|
24
|
+
middleman_http_prefix = config[:http_prefix]
|
25
|
+
path_to_site_root = middleman_http_prefix.end_with?("/") ? middleman_http_prefix : "#{middleman_http_prefix}/"
|
26
|
+
end
|
27
|
+
path_to_site_root
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "govuk_tech_docs/path_helpers"
|
1
2
|
require "govuk_tech_docs/table_of_contents/heading_tree_builder"
|
2
3
|
require "govuk_tech_docs/table_of_contents/heading_tree_renderer"
|
3
4
|
require "govuk_tech_docs/table_of_contents/heading_tree"
|
@@ -7,6 +8,8 @@ require "govuk_tech_docs/table_of_contents/headings_builder"
|
|
7
8
|
module GovukTechDocs
|
8
9
|
module TableOfContents
|
9
10
|
module Helpers
|
11
|
+
include GovukTechDocs::PathHelpers
|
12
|
+
|
10
13
|
def single_page_table_of_contents(html, url: "", max_level: nil)
|
11
14
|
output = "<ul>\n"
|
12
15
|
output += list_items_from_headings(html, url: url, max_level: max_level)
|
@@ -48,11 +51,7 @@ module GovukTechDocs
|
|
48
51
|
|
49
52
|
# Reuse the generated content for the active page
|
50
53
|
# If we generate it twice it increments the heading ids
|
51
|
-
content =
|
52
|
-
current_page_html
|
53
|
-
else
|
54
|
-
resource.render(layout: false)
|
55
|
-
end
|
54
|
+
content = current_page.url == resource.url && current_page_html ? current_page_html : resource.render(layout: false)
|
56
55
|
# Avoid redirect pages
|
57
56
|
next if content.include? "http-equiv=refresh"
|
58
57
|
|
@@ -71,15 +70,16 @@ module GovukTechDocs
|
|
71
70
|
config[:http_prefix] + "/"
|
72
71
|
end
|
73
72
|
|
73
|
+
link_value = get_path_to_resource(config, resource, current_page)
|
74
74
|
if resource.children.any? && resource.url != home_url
|
75
|
-
output += %{<li><a href="#{
|
75
|
+
output += %{<li><a href="#{link_value}"><span>#{resource.data.title}</span></a>\n}
|
76
76
|
output += render_page_tree(resource.children, current_page, config, current_page_html)
|
77
77
|
output += "</li>\n"
|
78
78
|
else
|
79
79
|
output +=
|
80
80
|
list_items_from_headings(
|
81
81
|
content,
|
82
|
-
url:
|
82
|
+
url: link_value,
|
83
83
|
max_level: config[:tech_docs][:max_toc_heading_level],
|
84
84
|
)
|
85
85
|
end
|
data/lib/govuk_tech_docs.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
<%= GovukTechDocs::Pages.new(sitemap, config).to_json %>
|
1
|
+
<%= GovukTechDocs::Pages.new(sitemap, config, current_page).to_json %>
|
@@ -41,9 +41,9 @@
|
|
41
41
|
</div>
|
42
42
|
<% if config[:tech_docs][:header_links] %>
|
43
43
|
<div class="govuk-header__content">
|
44
|
-
<
|
45
|
-
|
46
|
-
<ul id="navigation" class="govuk-header__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>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% if config[:tech_docs][:enable_search] %>
|
2
|
-
<div class="search" data-module="search">
|
2
|
+
<div class="search" data-module="search" data-path-to-site-root="<%= path_to_site_root config, current_page.path %>">
|
3
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
5
|
<label class="govuk-label search__label" for="search" aria-hidden="true">
|