Skip to content

Latest commit

 

History

History
162 lines (91 loc) · 3.97 KB

config.md

File metadata and controls

162 lines (91 loc) · 3.97 KB

Text Proto Formatter - Configuration

txtpbfmt provides several configuration options that customize the specifics of the output format. These are configured by adding a comment line to top of the proto file (before the first non-empty non-comment line) of the form:

# txtpbfmt: [config-option]

This doc describes each of these options.

AllowTripleQuotedStrings

# txtpbfmt: allow_triple_quoted_strings

Permit usage of Python-style """ or ''' delimited strings.

AllowUnnamedNodesEverywhere

# txtpbfmt: allow_unnamed_nodes_everywhere

Allow unnamed nodes everywhere. Default is to allow only top-level nodes to be unnamed.

ExpandAllChildren

# txtpbfmt: expand_all_children

Expand all children irrespective of the initial state.

Before formatting

Example

After formatting

Example

PreserveAngleBrackets

# txtpbfmt: preserve_angle_brackets

Whether angle brackets used instead of curly braces should be preserved when outputting a formatted textproto.

Before formatting

Example

After formatting

Example

RemoveDuplicateValuesForRepeatedFields

# txtpbfmt: remove_duplicate_values_for_repeated_fields

Remove lines that have the same field name and scalar value as another.

Before formatting

Example

After formatting

Example

SkipAllColons

# txtpbfmt: skip_all_colons

Skip colons whenever possible.

Before formatting

Example

After formatting

Example

SmartQuotes

# txtpbfmt: smartquotes

Use single quotes around strings that contain double but not single quotes.

Before formatting

Example

After formatting

Example

SortFieldsByFieldName

# txtpbfmt: sort_fields_by_field_name

Sort fields by field name.

Before formatting

Example

After formatting

Example

SortRepeatedFieldsByContent

# txtpbfmt: sort_repeated_fields_by_content

Sort adjacent scalar fields of the same field name by their contents.

Before formatting

Example

After formatting

Example

SortRepeatedFieldsBySubfield

# txtpbfmt: sort_repeated_fields_by_subfield=[subfieldSpec]

Sort adjacent message fields of the given field name by the contents of the given subfield. subfieldSpec is of one of two forms

  • fieldName.subfieldName, which will sort fields named fieldName by the value of their subfield named subfieldName.
  • subfieldName, which will sort any field by its subfield named subfieldName

Before formatting

Example

After formatting

Example

WrapHTMLStrings

# txtpbfmt: wrap_html_strings

Whether strings that appear to contain HTML tags should be wrapped (requires WrapStringsAtColumn to be set).

Before formatting

Example

After formatting

Example

WrapStringsAtColumn

# txtpbfmt: wrap_strings_at_column=[column]

Max columns for string field values. If zero, no string wrapping will occur. Strings that may contain HTML tags will not be wrapped unless wrap_html_strings is also specified.

Before formatting

Example

After formatting

Example