Skip to content

Commit bfaab26

Browse files
reakaleekbmorelli25eedugoncolleenmcginnis
authored
Add version mapping and bump to 8.18 (#3198)
* inject test * try again * test * test again * test * test * ok * commit am speed up * Revert conf * ok * Try without file read * test * fix * test * fix * test * ok * Remove /guide prefix * Refactor and cleanup * Revert nav.rb * Update v3-mapping.json (not finalized yet) * Refactor to satisfy rubocop * bumping current docs to 8.18 * Update stacklive * remove 404ing redirects * Fix styling * update with FINAL redirects * fix 404 * Adjust wording * Add old elastic docs experience warning * Remove 404ing beats links * css updates for landing page and text update * Fix z-index * Increase font-weight for h2 and h3 tags * update landing page to point to 8.18, etc. * fix * Move heading * Update documentation links to version 8.18 * one row --------- Co-authored-by: Brandon Morelli <[email protected]> Co-authored-by: Edu González de la Herrán <[email protected]> Co-authored-by: Colleen McGinnis <[email protected]>
1 parent a50dabd commit bfaab26

File tree

8 files changed

+18646
-116
lines changed

8 files changed

+18646
-116
lines changed

conf.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ contents_title: Elastic documentation
8080
# <key>: &<variable> <value>
8181
# The keys don't really matter, but by convention the are the same as the variable.
8282
variables:
83-
stackcurrent: &stackcurrent 8.17
84-
stacklive: &stacklive [ 8.17, 7.17 ]
83+
stackcurrent: &stackcurrent 8.18
84+
stacklive: &stacklive [ 8.18 ]
8585

8686
cloudSaasCurrent: &cloudSaasCurrent ms-122
8787

@@ -2289,7 +2289,7 @@ contents:
22892289
-
22902290
repo: docs
22912291
path: shared/versions/stack/current.asciidoc
2292-
- title: Legacy Documentation
2292+
- title: Archive
22932293
sections:
22942294
- title: Elastic Stack and Google Cloud's Anthos
22952295
noindex: 1

extra/docs_landing.html

+297-110
Large diffs are not rendered by default.

resources/asciidoctor/lib/chunker/extension.rb

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
require_relative 'find_related'
1010
require_relative 'footnotes'
1111
require_relative 'nav'
12+
require_relative 'url_to_v3'
1213

1314
##
1415
# HTML5 converter that chunks like docbook.
@@ -49,6 +50,7 @@ def convert_document(doc)
4950
)
5051
doc.attributes['next_section'] = find_next_in doc, 0
5152
add_nav doc
53+
add_url_to_v3 doc
5254
yield
5355
end
5456

@@ -81,6 +83,11 @@ def add_nav(doc)
8183
doc.blocks.append nav.footer
8284
end
8385

86+
def add_url_to_v3(doc)
87+
url_to_v3 = UrlToV3.new doc
88+
doc.blocks.insert 0, url_to_v3.url
89+
end
90+
8491
def correct_xref(node)
8592
refid = node.attributes['refid']
8693
return unless (ref = node.document.catalog[:refs][refid])
@@ -108,6 +115,8 @@ def form_section_into_page(doc, section, html)
108115

109116
def add_subdoc_sections(doc, subdoc, html)
110117
nav = Nav.new subdoc
118+
url_to_v3 = UrlToV3.new subdoc
119+
subdoc << url_to_v3.url
111120
subdoc << nav.header
112121
subdoc << Asciidoctor::Block.new(subdoc, :pass, source: html)
113122
subdoc << footnotes(doc, subdoc) if doc.footnotes?
@@ -143,6 +152,7 @@ def subdoc_attrs(doc, section)
143152
attrs['subdoc'] = true # Mark the subdoc so we don't try and chunk it
144153
attrs['title-separator'] = ''
145154
attrs['canonical-url'] = section.attributes['canonical-url']
155+
attrs['current-url'] = "#{section.id}.html"
146156
attrs.merge! find_related(section)
147157
attrs
148158
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# frozen_string_literal: true
2+
3+
module Chunker
4+
# Add a warning to the page with a link to docs v3
5+
class UrlToV3
6+
attr_reader :url
7+
8+
def initialize(doc)
9+
current_url = doc.attr('current-url')
10+
outdir = doc.attr('outdir')
11+
current_url ||= 'index.html'
12+
m = mapping
13+
# This only works in CI.
14+
segments = outdir.sub('/tmp/docsbuild/target_repo/raw', '').split('/')
15+
version = segments[-1] || 'unknown'
16+
actual_url = get_actual_url(outdir, current_url)
17+
new_url = if m.key?(actual_url)
18+
m[actual_url]
19+
else
20+
'/docs'
21+
end
22+
render_warning(doc, version, new_url)
23+
end
24+
25+
def mapping
26+
file_path = File.expand_path('v3-mapping.json', __dir__)
27+
JSON.parse(File.read(file_path)) if File.exist?(file_path)
28+
end
29+
30+
def get_path_dir(outdir)
31+
segments = outdir.sub('/tmp/docsbuild/target_repo/raw', '').split('/')
32+
if segments.empty?
33+
''
34+
elsif segments.length > 1
35+
segments[0...-1].join('/')
36+
else
37+
segments[0]
38+
end
39+
end
40+
41+
def get_actual_url(outdir, current_url)
42+
get_path_dir(outdir) + '/*/' + current_url
43+
end
44+
45+
def render_warning(doc, version, new_url)
46+
if version == '8.18'
47+
@url = Asciidoctor::Block.new(doc, :pass, source: <<~HTML)
48+
<div id="url-to-v3" class="version-warning">
49+
A newer version is available. Check out the <a href="https://www.elastic.co#{new_url}">latest documentation</a>.
50+
</div>
51+
HTML
52+
else
53+
@url = Asciidoctor::Block.new(doc, :pass, source: <<~HTML)
54+
<div id="url-to-v3" class="version-warning">
55+
<strong>IMPORTANT</strong>: This documentation is no longer updated. Refer to <a href="https://www.elastic.co/support/eol">Elastic's version policy</a> and the <a href="https://www.elastic.co#{new_url}">latest documentation</a>.
56+
</div>
57+
HTML
58+
end
59+
end
60+
end
61+
end

resources/asciidoctor/lib/chunker/v3-mapping.json

+18,262
Large diffs are not rendered by default.

resources/web/style/page_header.pcss

+11-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,19 @@
55
border: 1px solid #ccc;
66
background: #FFFFD2;
77
color: black;
8+
display: none;
89
}
910

10-
.abstract .page_header {
11+
.version-warning {
12+
padding: 1em;
13+
margin-bottom: 1em;
14+
border: 1px solid #ccc;
15+
background: #FFFFD2;
16+
color: black;
17+
}
18+
19+
.abstract .page_header,
20+
.abstract .version-warning {
1121
width: 100%;
1222
}
1323
}

shared/versions/stack/8.17.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ release-state can be: released | prerelease | unreleased
2929
//////////
3030
is-current-version can be: true | false
3131
//////////
32-
:is-current-version: true
32+
:is-current-version: false
3333

3434
//////////
3535
hide-xpack-tags defaults to "false" (they are shown unless set to "true")
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include::8.17.asciidoc[]
1+
include::8.18.asciidoc[]

0 commit comments

Comments
 (0)