Giter Site home page Giter Site logo

Comments (2)

jhump avatar jhump commented on August 25, 2024

I have thought about writing out proto files from a descriptor. I agree it would be a neat feature.

Making it lossless, for cases where source_code_info is present, is actually very complicated because of the way the source_code_info models language elements and file locations. Also, the way extra comments are represented, like inline comments between elements, makes it really hard to preserve all comments in the output. For example:

message Foo {
  /* comment 1 */ optional /* comment 2 */ /* comment 3 */ string
    // yet another comment
    fieldNameBar = /* more comments */ 3 [ /* some option comments! */ default = 
    // another line comment, inside options
     "baz" ]/* another one! */ ; // trailer
}

I believe there is enough info in source_code_info to be aware of all of the comments, but not enough to actually preserve formatting and placement.


I have seriously looked at preserving comments in the protoparse package. It is a hefty change that would involve quite a lot of boiler-plate -- wrapping every value in the parse tree with a new struct that includes position information and comments. There would also be some non-trivial work to make sure comments are attributed to elements correctly (to match protoc behavior).

I'll add this as a separate issue.

from protoreflect.

jhump avatar jhump commented on August 25, 2024

Feature implemented in #84

from protoreflect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.