Skip to content

Asciidoctor: Fix deprecation #639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 14 additions & 13 deletions resources/asciidoctor/lib/change_admonition/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
class ChangeAdmonition < Asciidoctor::Extensions::Group
def activate(registry)
[
[:added, 'added'],
[:coming, 'changed'],
[:deprecated, 'deleted'],
].each do |(name, revisionflag)|
registry.block_macro ChangeAdmonitionBlock.new(revisionflag), name
[:added, 'added', 'note'],
[:coming, 'changed', 'note'],
[:deprecated, 'deleted', 'warning'],
].each do |(name, revisionflag, tag)|
registry.block_macro ChangeAdmonitionBlock.new(revisionflag, tag), name
registry.inline_macro ChangeAdmonitionInline.new(revisionflag), name
end
end
Expand All @@ -33,24 +33,25 @@ class ChangeAdmonitionBlock < Asciidoctor::Extensions::BlockMacroProcessor
use_dsl
name_positional_attributes :version, :passtext

def initialize(revisionflag)
super
def initialize(revisionflag, tag)
super(nil)
@revisionflag = revisionflag
@tag = tag
end

def process(parent, _target, attrs)
version = attrs[:version]
# We can *almost* go through the standard :admonition conversion but
# that won't render the revisionflag or the revision. So we have to
# go with this funny compound pass thing.
note = Asciidoctor::Block.new(parent, :pass, :content_model => :compound)
note << Asciidoctor::Block.new(note, :pass,
:source => "<note revisionflag=\"#{@revisionflag}\" revision=\"#{version}\">",
admon = Asciidoctor::Block.new(parent, :pass, :content_model => :compound)
admon << Asciidoctor::Block.new(admon, :pass,
:source => "<#{@tag} revisionflag=\"#{@revisionflag}\" revision=\"#{version}\">",
:attributes => { 'revisionflag' => @revisionflag })
note << Asciidoctor::Block.new(note, :paragraph,
admon << Asciidoctor::Block.new(admon, :paragraph,
:source => attrs[:passtext],
:subs => Asciidoctor::Substitutors::NORMAL_SUBS)
note << Asciidoctor::Block.new(note, :pass, :source => "</note>")
admon << Asciidoctor::Block.new(admon, :pass, :source => "</#{@tag}>")
end
end

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

def initialize(revisionflag)
super
super(nil)
@revisionflag = revisionflag
end

Expand Down
18 changes: 9 additions & 9 deletions resources/asciidoctor/spec/change_admonishment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
end

[
%w[added added],
%w[coming changed],
%w[deprecated deleted],
].each do |(name, revisionflag)|
it "#{name}'s block version creates a note" do
%w[added added note],
%w[coming changed note],
%w[deprecated deleted warning],
].each do |(name, revisionflag, tag)|
it "#{name}'s block version creates a #{tag}" do
actual = convert <<~ASCIIDOC
== Example
#{name}::[some_version]
ASCIIDOC
expected = <<~DOCBOOK
<chapter id="_example">
<title>Example</title>
<note revisionflag="#{revisionflag}" revision="some_version">
<#{tag} revisionflag="#{revisionflag}" revision="some_version">
<simpara></simpara>
</note>
</#{tag}>
</chapter>
DOCBOOK
expect(actual).to eq(expected.strip)
Expand All @@ -42,9 +42,9 @@
expected = <<~DOCBOOK
<chapter id="_example">
<title>Example</title>
<note revisionflag="#{revisionflag}" revision="some_version">
<#{tag} revisionflag="#{revisionflag}" revision="some_version">
<simpara>See <xref linkend="some-reference"/></simpara>
</note>
</#{tag}>
<section id="some-reference">
<title>Some Reference</title>

Expand Down
12 changes: 6 additions & 6 deletions resources/asciidoctor/spec/elastic_compat_preprocessor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
include_examples "doesn't break line numbers"

[
%w[added added],
%w[coming changed],
%w[deprecated deleted],
].each do |(name, revisionflag)|
%w[added added note],
%w[coming changed note],
%w[deprecated deleted warning],
].each do |(name, revisionflag, tag)|
it "invokes the #{name} block macro when #{name}[version] starts a line" do
actual = convert <<~ASCIIDOC
== Example
Expand All @@ -33,9 +33,9 @@
expected = <<~DOCBOOK
<chapter id="_example">
<title>Example</title>
<note revisionflag="#{revisionflag}" revision="some_version">
<#{tag} revisionflag="#{revisionflag}" revision="some_version">
<simpara></simpara>
</note>
</#{tag}>
</chapter>
DOCBOOK
expect(actual).to eq(expected.strip)
Expand Down