Skip to content
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

Improve link extraction for Kibana link checking #2085

Merged
merged 1 commit into from
Mar 17, 2021
Merged
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
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