Skip to content
Open
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: 17 additions & 10 deletions versioned_plugins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,7 @@ def extract_doc(doc, plugin_full_name, release_tag, release_date, changelog_url)
.gsub(":include_path: ../../../logstash/docs/include", ":include_path: ../include/6.x")
.gsub(/[\t\r ]+$/,"")

content = content
.gsub("<<string,string>>", "{logstash-ref}/configuration-file-structure.html#string[string]")
.gsub("<<array,array>>", "{logstash-ref}/configuration-file-structure.html#array[array]")
.gsub("<<number,number>>", "{logstash-ref}/configuration-file-structure.html#number[number]")
.gsub("<<boolean,boolean>>", "{logstash-ref}/configuration-file-structure.html#boolean[boolean]")
.gsub("<<hash,hash>>", "{logstash-ref}/configuration-file-structure.html#hash[hash]")
.gsub("<<password,password>>", "{logstash-ref}/configuration-file-structure.html#password[password]")
.gsub("<<path,path>>", "{logstash-ref}/configuration-file-structure.html#path[path]")
.gsub("<<uri,uri>>", "{logstash-ref}/configuration-file-structure.html#uri[uri]")
.gsub("<<bytes,bytes>>", "{logstash-ref}/configuration-file-structure.html#bytes[bytes]")
content = fix_configuration_file_structure_links(content)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you find this more readable if you had an "intercept_anchors" helper that took the content, a list of anchors to intercept, and the page to re-route them to like:

      content = intercept_anchors(content, %w(string array number boolean hash password path uri bytes), "{logstash-ref}/configuration-file-structure.html")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we want to make deviating from the standard so easy. If we add a new input type, we should vet it and possibly update the lists of inputs.

logstash-plugins/logstash-filter-elasticsearch#166 (comment)

.gsub("<<event-api,Event API>>", "{logstash-ref}/event-api.html[Event API]")
.gsub("<<dead-letter-queues>>", '{logstash-ref}/dead-letter-queues.html[dead-letter-queues]')
.gsub("<<logstash-config-field-references>>", "{logstash-ref}/event-dependent-configuration.html#logstash-config-field-references[Field References]")
Expand Down Expand Up @@ -381,6 +372,22 @@ def extract_doc(doc, plugin_full_name, release_tag, release_date, changelog_url)

write_stack_versions(content, type)
end

# transforms '<<ANCHOR,ANYTHING>>' into {logstash-ref}/configuration-file-structure.html#ANCHOR[ANYTHING]
def fix_configuration_file_structure_links(content)
anchors = %w(
string
array
number
boolean
hash
password
path
uri
bytes
)
content.gsub(/<<(#{Regexp.union(anchors)}),(.+?)>>/, '{logstash-ref}/configuration-file-structure.html#\1[\2]')
end

def versions_index_exists?(name, type)
File.exist?("#{logstash_docs_path}/docs/versioned-plugins/#{type}s/#{name}-index.asciidoc")
Expand Down