Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildkite/scripts/build_pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ if [[ "${GITHUB_PR_BASE_REPO}" != 'docs' ]]; then
# test glob
"ecs-logging")
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs/**/*.asciidoc)
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- "**/*.asciidoc")
;;

# repositories with a docs dir
Expand Down
6 changes: 3 additions & 3 deletions conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ contents_title: Elastic documentation
# <key>: &<variable> <value>
# The keys don't really matter, but by convention the are the same as the variable.
variables:
stackcurrent: &stackcurrent 8.17
stacklive: &stacklive [ 8.17, 7.17 ]
stackcurrent: &stackcurrent 8.18
stacklive: &stacklive [ 8.18 ]

cloudSaasCurrent: &cloudSaasCurrent ms-121
cloudSaasCurrent: &cloudSaasCurrent ms-122

mapCloudEceToClientsTeam: &mapCloudEceToClientsTeam
ms-105: main
Expand Down
10 changes: 10 additions & 0 deletions resources/asciidoctor/lib/chunker/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
require_relative 'find_related'
require_relative 'footnotes'
require_relative 'nav'
require_relative 'url_to_v3'

##
# HTML5 converter that chunks like docbook.
Expand Down Expand Up @@ -49,6 +50,7 @@ def convert_document(doc)
)
doc.attributes['next_section'] = find_next_in doc, 0
add_nav doc
add_url_to_v3 doc
yield
end

Expand Down Expand Up @@ -81,6 +83,11 @@ def add_nav(doc)
doc.blocks.append nav.footer
end

def add_url_to_v3(doc)
url_to_v3 = UrlToV3.new doc
doc.blocks.insert 0, url_to_v3.url
end

def correct_xref(node)
refid = node.attributes['refid']
return unless (ref = node.document.catalog[:refs][refid])
Expand Down Expand Up @@ -108,6 +115,8 @@ def form_section_into_page(doc, section, html)

def add_subdoc_sections(doc, subdoc, html)
nav = Nav.new subdoc
url_to_v3 = UrlToV3.new subdoc
subdoc << url_to_v3.url
subdoc << nav.header
subdoc << Asciidoctor::Block.new(subdoc, :pass, source: html)
subdoc << footnotes(doc, subdoc) if doc.footnotes?
Expand Down Expand Up @@ -143,6 +152,7 @@ def subdoc_attrs(doc, section)
attrs['subdoc'] = true # Mark the subdoc so we don't try and chunk it
attrs['title-separator'] = ''
attrs['canonical-url'] = section.attributes['canonical-url']
attrs['current-url'] = "#{section.id}.html"
attrs.merge! find_related(section)
attrs
end
Expand Down
61 changes: 61 additions & 0 deletions resources/asciidoctor/lib/chunker/url_to_v3.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# frozen_string_literal: true

module Chunker
# Add a warning to the page with a link to docs v3
class UrlToV3
attr_reader :url

def initialize(doc)
current_url = doc.attr('current-url')
outdir = doc.attr('outdir')
current_url ||= 'index.html'
m = mapping
# This only works in CI.
segments = outdir.sub('/tmp/docsbuild/target_repo/raw', '').split('/')
version = segments[-1] || 'unknown'
actual_url = get_actual_url(outdir, current_url)
new_url = if m.key?(actual_url)
m[actual_url]
else
'/docs'
end
render_warning(doc, version, new_url)
end

def mapping
file_path = File.expand_path('v3-mapping.json', __dir__)
JSON.parse(File.read(file_path)) if File.exist?(file_path)
end

def get_path_dir(outdir)
segments = outdir.sub('/tmp/docsbuild/target_repo/raw', '').split('/')
if segments.empty?
''
elsif segments.length > 1
segments[0...-1].join('/')
else
segments[0]
end
end

def get_actual_url(outdir, current_url)
get_path_dir(outdir) + '/*/' + current_url
end

def render_warning(doc, version, new_url)
if version == '8.18'
@url = Asciidoctor::Block.new(doc, :pass, source: <<~HTML)
<div id="url-to-v3" style="version-warning">
A newer version is available. For the latest information, see the <a href="https://www.elastic.co#{new_url}">current release documentation</a>
</div>
HTML
else
@url = Asciidoctor::Block.new(doc, :pass, source: <<~HTML)
<div id="url-to-v3" class="version-warning">
<bold>IMPORTANT</bold>: No additional bug fixes or documentation updates will be released for this version. For the latest information, see the <a href="https://www.elastic.co#{new_url}">current release documentation</a>
</div>
HTML
end
end
end
end
12,852 changes: 12,852 additions & 0 deletions resources/asciidoctor/lib/chunker/v3-mapping.json

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion resources/web/style/page_header.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@
border: 1px solid #ccc;
background: #FFFFD2;
color: black;
display: none;
}

.abstract .page_header {
.version-warning {
padding: 1em;
margin-bottom: 1em;
border: 1px solid #ccc;
background: #FFFFD2;
color: black;
}

.abstract .page_header,
.abstract .version-warning {
width: 100%;
}
}
12 changes: 6 additions & 6 deletions shared/versions/stack/8.16.asciidoc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
:version: 8.16.5
:version: 8.16.6
////
bare_version never includes -alpha or -beta
////
:bare_version: 8.16.5
:logstash_version: 8.16.5
:elasticsearch_version: 8.16.5
:kibana_version: 8.16.5
:apm_server_version: 8.16.5
:bare_version: 8.16.6
:logstash_version: 8.16.6
:elasticsearch_version: 8.16.6
:kibana_version: 8.16.6
:apm_server_version: 8.16.6
// branch is 8.16 instead of 8.x for long-term linking purposes
:branch: 8.16
:minor-version: 8.16
Expand Down
14 changes: 7 additions & 7 deletions shared/versions/stack/8.17.asciidoc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
:version: 8.17.3
:version: 8.17.4
////
bare_version never includes -alpha or -beta
////
:bare_version: 8.17.3
:logstash_version: 8.17.3
:elasticsearch_version: 8.17.3
:kibana_version: 8.17.3
:apm_server_version: 8.17.3
:bare_version: 8.17.4
:logstash_version: 8.17.4
:elasticsearch_version: 8.17.4
:kibana_version: 8.17.4
:apm_server_version: 8.17.4
// branch is 8.17 instead of 8.x for long-term linking purposes
:branch: 8.17
:minor-version: 8.17
Expand All @@ -29,7 +29,7 @@ release-state can be: released | prerelease | unreleased
//////////
is-current-version can be: true | false
//////////
:is-current-version: true
:is-current-version: false

//////////
hide-xpack-tags defaults to "false" (they are shown unless set to "true")
Expand Down
2 changes: 1 addition & 1 deletion shared/versions/stack/9.0.asciidoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:version: 9.0.0-beta1
:version: 9.0.0-rc1
////
bare_version never includes -alpha or -beta
////
Expand Down
2 changes: 1 addition & 1 deletion shared/versions/stack/current.asciidoc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include::8.17.asciidoc[]
include::8.18.asciidoc[]