Skip to content

Commit

Permalink
Add some more admonitions
Browse files Browse the repository at this point in the history
  • Loading branch information
lcawl committed Oct 10, 2024
1 parent 873ec2c commit 9015cad
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 8 deletions.
84 changes: 83 additions & 1 deletion resources/asciidoctor/lib/care_admonition/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,42 @@
require 'asciidoctor/extensions'

##
# Extensions for marking something as `beta`, `dev`, or technical `preview`.
# Extensions for marking something as `beta`, `beta_serverless`, `beta_ess`, `dev`, `dev_serverless`, `dev_ess`, technical `preview`, `preview_serverless`, `preview_ess`, `ga_serverless`, `ga_ess`.
#
# Usage
#
# beta::[]
# dev::[]
# preview::[]
# beta_ess::[]
# beta_serverless::[]
# dev_ess::[]
# dev_serverless::[]
# ga_serverless::[]
# ga_stack::[]
# deprecated_ess::[]
# deprecated_serverless::[]
# discontinued_ess::[]
# discontinued_serverless::[]
# coming_ess::[]
# coming_serverless::[]
# Foo beta:[]
# Foo dev:[]
# Foo preview:[]
# Foo beta_ess:[]
# Foo beta_serverless:[]
# Foo dev_ess:[]
# Foo dev_serverless:[]
# Foo preview_ess:[]
# Foo preview_serverless:[]
# Foo ga_ess:[]
# Foo ga_serverless:[]
# Foo deprecated_ess:[]
# Foo deprecated_serverless:[]
# Foo discontinued_ess:[]
# Foo discontinued_serverless:[]
# Foo coming_ess:[]
# Foo coming_serverless::[]
#
# !! `experimental:[]` is supported as a deprecated alternative to `preview:[]`.
# !! But please use `preview:[]` instead.
Expand All @@ -21,19 +47,75 @@ class CareAdmonition < Asciidoctor::Extensions::Group
BETA_DEFAULT_TEXT = <<~TEXT.strip
This functionality is in beta and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Beta features are not subject to the support SLA of official GA features.
TEXT
BETA_SERVERLESS_TEXT = <<~TEXT.strip
This functionality is in beta in Elastic Serverless and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Beta features are not subject to the support SLA of official GA features.
TEXT
BETA_ESS_TEXT = <<~TEXT.strip
This functionality is in beta in Elasticsearch Service and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Beta features are not subject to the support SLA of official GA features.
TEXT
DEV_DEFAULT_TEXT = <<~TEXT.strip
This functionality is in development and may be changed or removed completely in a future release. These features are unsupported and not subject to the support SLA of official GA features.
TEXT
DEV_SERVERLESS_TEXT = <<~TEXT.strip
This functionality is in development in Elastic Serverless and may be changed or removed completely in a future release. These features are unsupported and not subject to the support SLA of official GA features.
TEXT
DEV_ESS_TEXT = <<~TEXT.strip
This functionality is in development in Elasticsearch Service and may be changed or removed completely in a future release. These features are unsupported and not subject to the support SLA of official GA features.
TEXT
PREVIEW_DEFAULT_TEXT = <<~TEXT.strip
This functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.
TEXT
PREVIEW_SERVERLESS_TEXT = <<~TEXT.strip
This functionality is in technical preview in Elastic Serverless and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.
TEXT
PREVIEW_ESS_TEXT = <<~TEXT.strip
This functionality is in technical in preview in Elasticsearch Service and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.
TEXT
DEPRECATED_ESS_TEXT = <<~TEXT.strip
This functionality is deprecated in Elasticsearch Service and will be removed in a future release.
TEXT
DEPRECATED_SERVERLESS_TEXT = <<~TEXT.strip
This functionality is deprecated in Elastic Serverless and will be removed in a future release.
TEXT
DISCONTINUED_ESS_TEXT = <<~TEXT.strip
This functionality is discontinued in Elasticsearch Service.
TEXT
DISCONTINUED_SERVERLESS_TEXT = <<~TEXT.strip
This functionality is discontinued in Elastic Serverless.
TEXT
COMING_ESS_TEXT = <<~TEXT.strip
This functionality is coming in Elasticsearch Service.
TEXT
COMING_SERVERLESS_TEXT = <<~TEXT.strip
This functionality is coming in Elastic Serverless.
TEXT
GA_ESS_TEXT = <<~TEXT.strip
This functionality is generally available in Elasticsearch Service.
TEXT
GA_SERVERLESS_TEXT = <<~TEXT.strip
This functionality is generally available in Elastic Serverless.
TEXT

def activate(registry)
[
[:beta, 'beta', BETA_DEFAULT_TEXT],
[:beta_serverless, 'beta', BETA_SERVERLESS_TEXT],
[:beta_ess, 'beta', BETA_ESS_TEXT],
[:dev, 'dev', DEV_DEFAULT_TEXT],
[:dev_serverless, 'dev', DEV_SERVERLESS_TEXT],
[:dev_ess, 'dev', DEV_ESS_TEXT],
[:experimental, 'preview', PREVIEW_DEFAULT_TEXT],
[:preview, 'preview', PREVIEW_DEFAULT_TEXT],
[:preview_serverless, 'preview', PREVIEW_SERVERLESS_TEXT],
[:preview_ess, 'preview', PREVIEW_ESS_TEXT],
[:deprecated_serverless, 'deprecated', DEPRECATED_SERVERLESS_TEXT],
[:deprecated_ess, 'deprecated', DEPRECATED_ESS_TEXT],
[:discontinued_serverless, 'discontinued', DISCONTINUED_SERVERLESS_TEXT],
[:discontinued_ess, 'discontinued', DISCONTINUED_ESS_TEXT],
[:coming_serverless, 'coming', COMING_SERVERLESS_TEXT],
[:coming_ess, 'coming', COMING_ESS_TEXT],
[:ga_serverless, 'added', GA_SERVERLESS_TEXT],
[:ga_ess, 'added', GA_ESS_TEXT]
].each do |(name, role, default_text)|
registry.block_macro ChangeAdmonitionBlock.new(role, default_text), name
registry.inline_macro ChangeAdmonitionInline.new(role, default_text), name
Expand Down
6 changes: 6 additions & 0 deletions resources/asciidoctor/lib/change_admonition/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,23 @@
# Usage
#
# added::[6.0.0-beta1]
# gastack::[8.10]
# coming::[6.0.0-beta1]
# deprecated::[6.0.0-beta1]
# discontinuedstack::[9.0.0]
# Foo added:[6.0.0-beta1]
# Foo coming:[6.0.0-beta1]
# Foo deprecated:[6.0.0-beta1]
# Foo gastack:[8.10]
# Foo discontinuedstack:[9.0.0]
#
class ChangeAdmonition < Asciidoctor::Extensions::Group
MACRO_CONF = [
[:added, 'added', 'note', 'Added in', nil],
[:coming, 'changed', 'note', 'Coming in', nil],
[:deprecated, 'deleted', 'warning', 'Deprecated in', ' u-strikethrough'],
[:ga_stack, 'added', 'note', 'Generally available in Elack Stack in', nil],
[:discontinued_stack, 'deleted', 'warning', 'Discontinued in', ' u-strikethrough']
].freeze
def activate(registry)
MACRO_CONF.each do |(name, revisionflag, tag, message, title_class)|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,29 @@
# added[6.0.0-beta1]
# coming[6.0.0-beta1]
# deprecated[6.0.0-beta1]
# discontinued-stack[9.0.0]
# ga_stack[8.10]
# Into
# added::[6.0.0-beta1]
# coming::[6.0.0-beta1]
# deprecated::[6.0.0-beta1]
# discontinued-stack[9.0.0]
# ga_stack::[8.10]
# Because `::` is required by asciidoctor to invoke block macros but isn't
# required by asciidoc.
#
# Turns
# words words added[6.0.0-beta1]
# words words changed[6.0.0-beta1]
# words words deprecated[6.0.0-beta1]
# words words discontinued[9.0.0]
# words words ga_stack[8.10]
# Into
# words words added:[6.0.0-beta1]
# words words changed:[6.0.0-beta1]
# words words deprecated:[6.0.0-beta1]
# words words discontinued:[9.0.0]
# words words ga_stack:[8.10]
# Because `:` is required by asciidoctor to invoke inline macros but isn't
# required by asciidoc.
#
Expand Down Expand Up @@ -116,7 +124,7 @@ class ElasticCompatPreprocessor < Asciidoctor::Extensions::Preprocessor
/^\["source", ?"[^"]+", ?subs="(#{Asciidoctor::CC_ANY}+)"\]$/
CODE_BLOCK_RX = /^-----*$/
SNIPPET_RX = %r{^//\s*(AUTOSENSE|KIBANA|CONSOLE|SENSE:[^\n<]+)$}
LEGACY_MACROS = 'added|beta|coming|deprecated|dev|experimental'
LEGACY_MACROS = 'added|beta|coming|deprecated|dev|experimental|ga_stack|ga_serverless|ga_ess|beta_serverless|beta_ess|coming_serverless|coming_ess|deprecated_serverless|deprecated_ess|dev_serverless|dev_ess|preview_serverless|preview_ess|discontinued_stack|discontinued_ess|discontinued_serverless'
LEGACY_BLOCK_MACRO_RX = /^\s*(#{LEGACY_MACROS})\[(.*)\]\s*$/
LEGACY_INLINE_MACRO_RX = /(#{LEGACY_MACROS})\[(.*)\]/

Expand Down
10 changes: 10 additions & 0 deletions resources/asciidoctor/spec/care_admonition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,16 @@ def expect_inline_admonition(text)
end
include_examples 'care admonition'
end
context 'beta-serverless' do
let(:key) { 'beta-serverless' }
let(:admon_class) { 'warning' }
let(:default_text) do
<<~TEXT.strip
This functionality is in beta in Elastic Serverless and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Beta features are not subject to the support SLA of official GA features.
TEXT
end
include_examples 'care admonition'
end
context 'dev' do
let(:key) { 'dev' }
let(:admon_class) { 'warning' }
Expand Down
40 changes: 38 additions & 2 deletions resources/asciidoctor/spec/change_admonition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def expect_block_admonition(body)
HTML
end
end
context 'without content' do
context 'with version without content' do
let(:input) do
<<~ASCIIDOC
#{key}::[7.0.0-beta1]
Expand All @@ -50,6 +50,16 @@ def expect_block_admonition(body)
expect_block_admonition "<p>#{message} in 7.0.0-beta1.</p>"
end
end
context 'without content' do
let(:input) do
<<~ASCIIDOC
#{key}::[]
ASCIIDOC
end
it 'has default text' do
expect_block_admonition "<p>#{message}</p>"
end
end
context 'with complex content' do
let(:input) do
<<~ASCIIDOC
Expand Down Expand Up @@ -99,7 +109,7 @@ def expect_inline_admonition(version, text)
)
end
end
context 'without text' do
context 'with version without text' do
let(:input) do
<<~ASCIIDOC
Words #{key}:[7.0.0-beta1] words.
Expand All @@ -111,6 +121,18 @@ def expect_inline_admonition(version, text)
)
end
end
context 'without text' do
let(:input) do
<<~ASCIIDOC
Words #{key}:[] words.
ASCIIDOC
end
it 'has default text' do
expect_inline_admonition(
'', "#{message}"
)
end
end
context 'inside the document title' do
let(:standalone) { true }
let(:convert_attributes) do
Expand Down Expand Up @@ -195,6 +217,13 @@ def expect_inline_admonition(version, text)
let(:extra_class) { '' }
include_examples 'change admonition'
end
context 'ga in stack' do
let(:key) { 'ga_stack' }
let(:admon_class) { 'note' }
let(:message) { 'Generally available in Elastic Stack' }
let(:extra_class) { '' }
include_examples 'change admonition'
end
context 'coming' do
let(:key) { 'coming' }
let(:admon_class) { 'note' }
Expand All @@ -209,4 +238,11 @@ def expect_inline_admonition(version, text)
let(:extra_class) { ' u-strikethrough' }
include_examples 'change admonition'
end
context 'discontinued in stack' do
let(:key) { 'discontinued_stack' }
let(:admon_class) { 'warning' }
let(:message) { 'Discontinued' }
let(:extra_class) { ' u-strikethrough' }
include_examples 'change admonition'
end
end
Loading

0 comments on commit 9015cad

Please sign in to comment.