Skip to content

Commit 2782993

Browse files
authored
Asciidoctor: Fix deprecation (#639)
When I added deprecations I created a `note` element but it should have been a `warning` element. This is one of the things that the new `html_diff`-based integration tests caught!
1 parent 8c35b23 commit 2782993

File tree

3 files changed

+29
-28
lines changed

3 files changed

+29
-28
lines changed

resources/asciidoctor/lib/change_admonition/extension.rb

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
class ChangeAdmonition < Asciidoctor::Extensions::Group
1919
def activate(registry)
2020
[
21-
[:added, 'added'],
22-
[:coming, 'changed'],
23-
[:deprecated, 'deleted'],
24-
].each do |(name, revisionflag)|
25-
registry.block_macro ChangeAdmonitionBlock.new(revisionflag), name
21+
[:added, 'added', 'note'],
22+
[:coming, 'changed', 'note'],
23+
[:deprecated, 'deleted', 'warning'],
24+
].each do |(name, revisionflag, tag)|
25+
registry.block_macro ChangeAdmonitionBlock.new(revisionflag, tag), name
2626
registry.inline_macro ChangeAdmonitionInline.new(revisionflag), name
2727
end
2828
end
@@ -33,24 +33,25 @@ class ChangeAdmonitionBlock < Asciidoctor::Extensions::BlockMacroProcessor
3333
use_dsl
3434
name_positional_attributes :version, :passtext
3535

36-
def initialize(revisionflag)
37-
super
36+
def initialize(revisionflag, tag)
37+
super(nil)
3838
@revisionflag = revisionflag
39+
@tag = tag
3940
end
4041

4142
def process(parent, _target, attrs)
4243
version = attrs[:version]
4344
# We can *almost* go through the standard :admonition conversion but
4445
# that won't render the revisionflag or the revision. So we have to
4546
# go with this funny compound pass thing.
46-
note = Asciidoctor::Block.new(parent, :pass, :content_model => :compound)
47-
note << Asciidoctor::Block.new(note, :pass,
48-
:source => "<note revisionflag=\"#{@revisionflag}\" revision=\"#{version}\">",
47+
admon = Asciidoctor::Block.new(parent, :pass, :content_model => :compound)
48+
admon << Asciidoctor::Block.new(admon, :pass,
49+
:source => "<#{@tag} revisionflag=\"#{@revisionflag}\" revision=\"#{version}\">",
4950
:attributes => { 'revisionflag' => @revisionflag })
50-
note << Asciidoctor::Block.new(note, :paragraph,
51+
admon << Asciidoctor::Block.new(admon, :paragraph,
5152
:source => attrs[:passtext],
5253
:subs => Asciidoctor::Substitutors::NORMAL_SUBS)
53-
note << Asciidoctor::Block.new(note, :pass, :source => "</note>")
54+
admon << Asciidoctor::Block.new(admon, :pass, :source => "</#{@tag}>")
5455
end
5556
end
5657

@@ -62,7 +63,7 @@ class ChangeAdmonitionInline < Asciidoctor::Extensions::InlineMacroProcessor
6263
with_format :short
6364

6465
def initialize(revisionflag)
65-
super
66+
super(nil)
6667
@revisionflag = revisionflag
6768
end
6869

resources/asciidoctor/spec/change_admonishment_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@
1212
end
1313

1414
[
15-
%w[added added],
16-
%w[coming changed],
17-
%w[deprecated deleted],
18-
].each do |(name, revisionflag)|
19-
it "#{name}'s block version creates a note" do
15+
%w[added added note],
16+
%w[coming changed note],
17+
%w[deprecated deleted warning],
18+
].each do |(name, revisionflag, tag)|
19+
it "#{name}'s block version creates a #{tag}" do
2020
actual = convert <<~ASCIIDOC
2121
== Example
2222
#{name}::[some_version]
2323
ASCIIDOC
2424
expected = <<~DOCBOOK
2525
<chapter id="_example">
2626
<title>Example</title>
27-
<note revisionflag="#{revisionflag}" revision="some_version">
27+
<#{tag} revisionflag="#{revisionflag}" revision="some_version">
2828
<simpara></simpara>
29-
</note>
29+
</#{tag}>
3030
</chapter>
3131
DOCBOOK
3232
expect(actual).to eq(expected.strip)
@@ -42,9 +42,9 @@
4242
expected = <<~DOCBOOK
4343
<chapter id="_example">
4444
<title>Example</title>
45-
<note revisionflag="#{revisionflag}" revision="some_version">
45+
<#{tag} revisionflag="#{revisionflag}" revision="some_version">
4646
<simpara>See <xref linkend="some-reference"/></simpara>
47-
</note>
47+
</#{tag}>
4848
<section id="some-reference">
4949
<title>Some Reference</title>
5050

resources/asciidoctor/spec/elastic_compat_preprocessor_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
include_examples "doesn't break line numbers"
2222

2323
[
24-
%w[added added],
25-
%w[coming changed],
26-
%w[deprecated deleted],
27-
].each do |(name, revisionflag)|
24+
%w[added added note],
25+
%w[coming changed note],
26+
%w[deprecated deleted warning],
27+
].each do |(name, revisionflag, tag)|
2828
it "invokes the #{name} block macro when #{name}[version] starts a line" do
2929
actual = convert <<~ASCIIDOC
3030
== Example
@@ -33,9 +33,9 @@
3333
expected = <<~DOCBOOK
3434
<chapter id="_example">
3535
<title>Example</title>
36-
<note revisionflag="#{revisionflag}" revision="some_version">
36+
<#{tag} revisionflag="#{revisionflag}" revision="some_version">
3737
<simpara></simpara>
38-
</note>
38+
</#{tag}>
3939
</chapter>
4040
DOCBOOK
4141
expect(actual).to eq(expected.strip)

0 commit comments

Comments
 (0)