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

Preserve comments and newlines #1096

Open
ReyOrtiz opened this issue Dec 23, 2024 · 0 comments
Open

Preserve comments and newlines #1096

ReyOrtiz opened this issue Dec 23, 2024 · 0 comments

Comments

@ReyOrtiz
Copy link

ReyOrtiz commented Dec 23, 2024

Hello and thanks for creating this, very helpful!

Is it possible to preserve all the comments and new lines generated by buf?

For example, this part:

# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: project/protos/abc.proto
# Protobuf Python Version: 5.28.2
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import runtime_version as _runtime_version
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.internal import builder as _builder
_runtime_version.ValidateProtobufRuntimeVersion(
    _runtime_version.Domain.PUBLIC,
    5,
    28,
    2,
    '',
    'project/protos/abc.proto'
)
# @@protoc_insertion_point(imports)

_sym_db = _symbol_database.Default()


from validate import validate_pb2 as validate_dot_validate__pb2
from google.protobuf import struct_pb2 as google_dot_protobuf_dot_struct__pb2

is rewritten as

"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import runtime_version as _runtime_version
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.internal import builder as _builder
_runtime_version.ValidateProtobufRuntimeVersion(_runtime_version.Domain.PUBLIC, 5, 28, 2, '', 'project/protos/abc.proto')
_sym_db = _symbol_database.Default()
from ...validate import validate_pb2 as validate_dot_validate__pb2
from google.protobuf import struct_pb2 as google_dot_protobuf_dot_struct__pb2

It removed all the # comments and removed the new lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant