Skip to content

Add Github link support to beta and experimental macros #1705

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 12 commits into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
25 changes: 23 additions & 2 deletions README.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,13 @@ Text about old functionality...
== Experimental and Beta

APIs or parameters that are experimental or in beta can be marked as such, using
markup similar to that used in <<changes>>. For instance:
markup similar to that used in <<changes>>.

In the block format, you have the option of adding a related GitHub issue. If
both custom text and a GitHub issue are provided, the GitHub issue **must** be
provided second.

For instance:

[source,asciidoc]
----------------------------------
Expand All @@ -1488,8 +1494,12 @@ markup similar to that used in <<changes>>. For instance:

experimental::[]

experimental::[https://github.com/elastic/docs/issues/505]

experimental::[Custom text goes here]

experimental::[Custom text goes here,https://github.com/elastic/docs/issues/505]

Text about new feature...

[[old-feature]]
Expand All @@ -1510,10 +1520,13 @@ a new experimental parameter:

experimental::[]

experimental::[https://github.com/elastic/docs/issues/505]

experimental::[Custom text goes here]

Text about new feature...
experimental::[Custom text goes here,https://github.com/elastic/docs/issues/505]

Text about new feature...
[[old-feature]]
=== Established feature

Expand All @@ -1532,8 +1545,12 @@ a new experimental parameter:

beta::[]

beta::[https://github.com/elastic/docs/issues/505]

beta::[Custom text goes here]

beta::[Custom text goes here,https://github.com/elastic/docs/issues/505]

Text about new feature...

[[old-beta-feature]]
Expand All @@ -1554,8 +1571,12 @@ a new beta parameter:

beta::[]

beta::[https://github.com/elastic/docs/issues/505]

beta::[Custom text goes here]

beta::[Custom text goes here,https://github.com/elastic/docs/issues/505]

Text about new feature...

[[old-beta-feature]]
Expand Down
20 changes: 18 additions & 2 deletions resources/asciidoctor/lib/care_admonition/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def activate(registry)
# Block care admonition.
class ChangeAdmonitionBlock < Asciidoctor::Extensions::BlockMacroProcessor
use_dsl
name_positional_attributes :passtext
name_positional_attributes :passtext, :github

def initialize(role, default_text)
super(nil)
Expand All @@ -43,9 +43,25 @@ def initialize(role, default_text)
end

def process(parent, _target, attrs)
text = attrs[:passtext]
gh_pattern = %r{^https?:\/\/github\.com\/elastic\/\S+[^\/]\/issues\/\d+$}
if text&.match(gh_pattern)
github_link = attrs[:passtext]
text = @default_text
else
github_link = attrs[:github]
text ||= @default_text
end
if github_link
github_issue = github_link.split('/').last
github_text = <<~TEXT
For feature status, see #{github_link}[\##{github_issue}].
TEXT
text += ' ' + github_text
end
Asciidoctor::Block.new(
parent, :admonition,
source: attrs[:passtext] || @default_text,
source: text,
attributes: {
'role' => @role,
'name' => 'warning',
Expand Down