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

Make comment at beginning of input file available to plugin authors #1385

Closed
estan opened this issue Apr 3, 2016 · 4 comments
Closed

Make comment at beginning of input file available to plugin authors #1385

estan opened this issue Apr 3, 2016 · 4 comments

Comments

@estan
Copy link

estan commented Apr 3, 2016

For documentation generator plugins such as my own protoc-gen-doc it would be great if the comment (if any) at the very top of an input .proto file was made available somehow in FileDescriptor.

A documentation comment at the top of a file is commonly used in documentation tools for providing documentation for the file as a whole, but currently it's only possible to get at the comments surrounding language constructs (e.g. messages, fields, enums et.c.) through SourceLocation::leading_comments and SourceLocation::trailing_comments.

@estan
Copy link
Author

estan commented Apr 23, 2016

@xfxyjwf: Hey Feng, any news on this? You mentioned on the Google group that something like this may already exist in Google's internal version, and that you would check on the status of it?

@xfxyjwf xfxyjwf assigned liujisi and unassigned xfxyjwf Apr 28, 2016
@xfxyjwf
Copy link
Contributor

xfxyjwf commented Apr 28, 2016

@pherl I remember the support for comments at the beginning of a .proto file is already supported. Jisi, could you comment on this?

@liujisi
Copy link
Contributor

liujisi commented Apr 28, 2016

Yes, they are already supported. They should probably in the leading_detached_comments of the syntax location. See the test here: https://github.com/google/protobuf/blob/master/src/google/protobuf/compiler/parser_unittest.cc#L1850

@estan
Copy link
Author

estan commented Apr 29, 2016

@pherl: Ah, thanks! I was only looking at 2.6.1. Closing this issue now.

Do you know if there's a way in 2.5 / 2.6 to get those comments? If not, do you know of a way to get the full on-disk path to an input proto from a compiler plugin, so that I can parse them out myself as a workaround (short of re-implementing all the command line parsing / SourceTree building that the compiler does)? My compiler plugin must support 2.5 and 2.6 as well, so I'm looking for a way to get those comments from there. Feel free to answer this last question on my mail thread.

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

No branches or pull requests

3 participants