From 58723d7deaffd9a7e3f2e96e1d3b007bd2026ec5 Mon Sep 17 00:00:00 2001 From: bmorelli25 Date: Wed, 4 Dec 2024 11:57:14 -0800 Subject: [PATCH 1/3] add copy to clipboard cta tracking --- .../spec/helper/console_alternative_examples.rb | 6 +++--- .../lib/docbook_compat/convert_listing.rb | 2 +- resources/asciidoctor/spec/docbook_compat_spec.rb | 4 ++-- resources/web/style/code.pcss | 14 ++++++++++++++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/integtest/spec/helper/console_alternative_examples.rb b/integtest/spec/helper/console_alternative_examples.rb index 8048eabafaab6..5a2c346214c32 100644 --- a/integtest/spec/helper/console_alternative_examples.rb +++ b/integtest/spec/helper/console_alternative_examples.rb @@ -47,7 +47,7 @@ module ConsoleExamples it 'contains the js listing followed by the csharp listing' do expect(body).to include(<<~HTML.strip)
-
+
Copy to clipboard
const result = await client.search({
           body: { query: 'foo bar' } 
         })
@@ -58,7 +58,7 @@ module ConsoleExamples it 'contains the csharp listing followed by the default listing' do expect(body).to include(<<~HTML.strip)
-
+
Copy to clipboard
var searchResponse = _client.Search<Project>(s => s
             .Query(q => q
                 .QueryString(m => m
@@ -74,7 +74,7 @@ module ConsoleExamples
     it 'contains the default listing followed by the console widget' do
       expect(body).to include(<<~HTML.strip)
         
-
+
Copy to clipboard
GET /_search
         {
             "query": "foo bar" 
diff --git a/resources/asciidoctor/lib/docbook_compat/convert_listing.rb b/resources/asciidoctor/lib/docbook_compat/convert_listing.rb
index 3be679bc25d44..e0c502930e44b 100644
--- a/resources/asciidoctor/lib/docbook_compat/convert_listing.rb
+++ b/resources/asciidoctor/lib/docbook_compat/convert_listing.rb
@@ -52,7 +52,7 @@ def convert_listing_body_with_language(node, lang)
       pre_classes = "programlisting prettyprint lang-#{lang}#{extra_classes}"
       [
         %(
), - %(
), + %(
Copy to clipboard
), %(
#{node.content || ''}
), %(
), ].join "\n" diff --git a/resources/asciidoctor/spec/docbook_compat_spec.rb b/resources/asciidoctor/spec/docbook_compat_spec.rb index 2790fced2f6a9..43088ca649445 100644 --- a/resources/asciidoctor/spec/docbook_compat_spec.rb +++ b/resources/asciidoctor/spec/docbook_compat_spec.rb @@ -995,7 +995,7 @@ # It is important that there isn't any extra space around the
 tags
       expect(converted).to include(<<~HTML)
         
-
+
Copy to clipboard
cpanm Search::Elasticsearch
HTML @@ -1184,7 +1184,7 @@ it 'the role is included as a class' do expect(converted).to include(<<~HTML)
-
+
Copy to clipboard
cpanm Search::Elasticsearch
HTML diff --git a/resources/web/style/code.pcss b/resources/web/style/code.pcss index cea09130cb2cf..580bd76c8f703 100644 --- a/resources/web/style/code.pcss +++ b/resources/web/style/code.pcss @@ -83,4 +83,18 @@ .alternative { display: none; } + + /* Hide "Copy to Clipboard" text */ + .visually-hidden { + position: absolute; + width: 1px; + height: 1px; + margin: -1px; + padding: 0; + border: 0; + overflow: hidden; + clip: rect(0, 0, 0, 0); + clip-path: inset(50%); + white-space: nowrap; /* Avoid line breaks */ + } } From 978fba0022577e44aff08ac6f9707cab5f7bc4b2 Mon Sep 17 00:00:00 2001 From: bmorelli25 Date: Wed, 4 Dec 2024 13:43:35 -0800 Subject: [PATCH 2/3] fix ruby tests --- README.asciidoc | 13 +++++++++++-- .../lib/docbook_compat/convert_listing.rb | 4 +++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index b0ebc68c53f8c..d2b2534d4417f 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -238,8 +238,6 @@ To force *all* versions of the documentation to be rebuilt (not just the calcula @elasticmachine, run elasticsearch-ci/docs rebuild ---------------------------- - - [[config]] == Adding new docs or new branches @@ -276,6 +274,17 @@ want to build a version called "4.2" but have it build out of a branch called `branches` list. Everywhere else in `conf.yaml`, continue to use `branch-for-4.2`. +[[config]] +== Run tests + +When developing new features or fixing bugs in the build process, run the test suite locally with: + +[source,bash] +---- +make asciidoctor_check +---- + + [[asciidoc-guide]] = Asciidoc Guide diff --git a/resources/asciidoctor/lib/docbook_compat/convert_listing.rb b/resources/asciidoctor/lib/docbook_compat/convert_listing.rb index e0c502930e44b..9b25d7abed4d8 100644 --- a/resources/asciidoctor/lib/docbook_compat/convert_listing.rb +++ b/resources/asciidoctor/lib/docbook_compat/convert_listing.rb @@ -50,9 +50,11 @@ def convert_listing_body(node) def convert_listing_body_with_language(node, lang) extra_classes = node.roles.empty? ? '' : " #{node.roles.join ' '}" pre_classes = "programlisting prettyprint lang-#{lang}#{extra_classes}" + c_cla = '"console_code_copy" title="Copy to clipboard" data-track="cta"' + span = 'Copy to clipboard' [ %(
), - %(
Copy to clipboard
), + %(
#{span}
), %(
#{node.content || ''}
), %(
), ].join "\n" From e028a2ce14d8d7349bacccdc7998b308703eadc8 Mon Sep 17 00:00:00 2001 From: bmorelli25 Date: Wed, 4 Dec 2024 14:44:29 -0800 Subject: [PATCH 3/3] fix duplicate heading bug and update readme --- README.asciidoc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index d2b2534d4417f..0bcd011be5b88 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -274,16 +274,22 @@ want to build a version called "4.2" but have it build out of a branch called `branches` list. Everywhere else in `conf.yaml`, continue to use `branch-for-4.2`. -[[config]] +[[run-tests]] == Run tests When developing new features or fixing bugs in the build process, run the test suite locally with: [source,bash] ---- -make asciidoctor_check +make ---- +Alternatively, run just the Asciidoctor tests with: + +[source,bash] +---- +make asciidoctor_check +---- [[asciidoc-guide]] = Asciidoc Guide