Skip to content

Commit

Permalink
Merge pull request #2085 from elastic/gtback/ignore-checking-nondoc-l…
Browse files Browse the repository at this point in the history
…inks

Improve link extraction for Kibana link checking
  • Loading branch information
gtback committed Mar 17, 2021
2 parents d3fe10b + fecb18e commit a7c1a22
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions build_docs.pl
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,21 @@ sub check_kibana_links {
my $extractor = sub {
my $contents = shift;
return sub {
while ( $contents =~ m!`(\$\{(?:baseUrl|ELASTIC_.+)\}[^`]+)`!g ) {
while ( $contents =~ m!`(\$\{(?:baseUrl|ELASTIC.+)\}[^`]+)`!g ) {
my $path = $1;
$path =~ s/\$\{(?:DOC_LINK_VERSION|urlVersion)\}/$branch/;
$path
=~ s!\$\{ELASTIC_DOCS\}!en/elasticsearch/reference/$branch/!
|| $path =~ s!\$\{(?:baseUrl|ELASTIC_WEBSITE_URL)\}guide/!!;
# In older versions, the variable `${ELASTIC_DOCS}` referred to
# the Elasticsearch Reference Guide. In newer branches, the
# variable is called `${ELASTICSEARCH_DOCS}`
$path =~ s!\$\{ELASTIC_DOCS\}!en/elasticsearch/reference/$branch/!;
$path =~ s!\$\{ELASTICSEARCH_DOCS\}!en/elasticsearch/reference/$branch/!;
# Replace the "https://www.elastic.co/guide/" URL prefix so that
# it becomes a file path in the built docs.
$path =~ s!\$\{(?:baseUrl|ELASTIC_WEBSITE_URL)\}guide/!!;
# We don't want to check any links to www.elastic.co that aren't
# part of the docs.
return "" if $path =~ m/\$\{(?:baseUrl|ELASTIC_WEBSITE_URL)\}.*/;
# Otherwise, return the link to check
return ( split /#/, $path );
}
return;
Expand Down

0 comments on commit a7c1a22

Please sign in to comment.