...

Text file src/github.com/protocolbuffers/txtpbfmt/README.md

Documentation: github.com/protocolbuffers/txtpbfmt

     1# Text Proto Formatter
     2
     3`txtpbfmt` parses, edits and formats text proto files in a way that preserves comments.
     4
     5This saves development (read/edit/review) time and enables automated edits.
     6
     7## How to format existing text proto files?
     8
     9Install:
    10
    11```shell
    12$ go install github.com/protocolbuffers/txtpbfmt/cmd/txtpbfmt@latest
    13```
    14
    15Format files in-place:
    16
    17```shell
    18$ ${GOPATH}/bin/txtpbfmt [FILES]
    19```
    20
    21Write formatted input to stdout:
    22
    23```shell
    24$ ${GOPATH}/bin/txtpbfmt < [FILE]
    25```
    26
    27## What does it do?
    28
    29Main features:
    30
    31![main features](docs/features.png)
    32
    33Configurable features:
    34
    35-   Fields on
    36    [`parser.Config`](https://github.com/search?q=repo%3Aprotocolbuffers%2Ftxtpbfmt+%22type+Config+struct%22&type=code)
    37-   Corresponding `# txtpbfmt: feature` names on
    38    [`parser.addToConfig`](https://github.com/search?q=repo%3Aprotocolbuffers%2Ftxtpbfmt+%22func+addToConfig%28%22&type=code)
    39-   Examples on [config.md](docs/config.md)
    40
    41## Is there an API to edit text proto files while preserving comments?
    42
    43Yes, see [ast.go](ast/ast.go).
    44
    45## How to disable it?
    46
    47You can disable formatting for a whole file by adding a comment with "#
    48txtpbfmt: disable" to the top of the file (before the first non-empty
    49non-comment line), eg:
    50
    51```textproto
    52# File overview ...
    53
    54# txtpbfmt: disable
    55
    56content: { ... }
    57```
    58
    59## Which file extension should I use for my text proto files?
    60
    61The `.textproto` extension is the most used extension inside Google (the second
    62most popular choice is `.textpb`).
    63
    64## Which tools support it? How to format on save?
    65
    66Currently there is no open source integration with any editor.
    67
    68## See also
    69
    70* [Text Format Language Specification](https://developers.google.com/protocol-buffers/docs/text-format-spec)

View as plain text