Module: ElasticGraph::ProtoIngestion::SchemaDefinition::SchemaElements::ProtoDocumentation Private

Defined in:
elasticgraph-proto_ingestion/lib/elastic_graph/proto_ingestion/schema_definition/schema_elements/proto_documentation.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Formats ElasticGraph schema element documentation as protobuf comments.

Class Method Summary collapse

Class Method Details

.comment_lines_for(doc_comment, indent: "") ⇒ Array<String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Formats documentation as line comments.

Parameters:

  • doc_comment (String, nil) —

    schema element documentation

  • indent (String) (defaults to: "") —

    indentation to put before each comment

Returns:

  • (Array<String>) —

    formatted protobuf comment lines



32
33
34
35
36
37
38
# File 'elasticgraph-proto_ingestion/lib/elastic_graph/proto_ingestion/schema_definition/schema_elements/proto_documentation.rb', line 32

def self.comment_lines_for(doc_comment, indent: "")
  return [] unless doc_comment

  doc_comment.chomp.lines(chomp: true).map do |line|
    line.empty? ? "#{indent}//" : "#{indent}// #{line}"
  end
end

.join_definitions(definitions) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Joins field or enum value definitions, separating documented entries with blank lines.

Parameters:

  • definitions (Array<String>) —

    declarations with any leading comments

Returns:

  • (String) —

    formatted protobuf declarations



21
22
23
24
25
# File 'elasticgraph-proto_ingestion/lib/elastic_graph/proto_ingestion/schema_definition/schema_elements/proto_documentation.rb', line 21

def self.join_definitions(definitions)
  definitions.chunk_while do |previous, following|
    !previous.include?("\n") && !following.include?("\n")
  end.map { |group| group.join("\n") }.join("\n\n")
end