CODING_STYLE: Define our preferred form for multiline comments
PATCH v2 1/1 CODING_STYLE: Define our preferred form for multiline comments
The codebase has a bit of a mix of different multiline comment styles. State a preference for the Linux kernel style:
/*
* Star on the left for each line.
* Leading slash-star and trailing star-slash
* each go on a line of their own.
*/
---
This is not my personal favourite, but seemed to be the closest we had to consensus in the mail thread for v1; I can live with it in order to avoid getting patches which use the styles I like even less :-)
--- CODING_STYLE | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
CODING_STYLE +17 -0
@@ -124,6 +124,23 @@ We use traditional C-style /* */ comments and avoid // comments. Rationale: The // form is valid in C99, so this is purely a matter of consistency of style. The checkpatch script will warn you about this. +Multiline comments blocks should have a row of stars on the left, +and the initial /* and terminating */ both on their own lines: + /* + * like + * this + */ +This is the same format required by the Linux kernel coding style. + +(Some of the existing comments in the codebase use the GNU Coding +Standards form which does not have stars on the left, or other +variations; avoid these when writing new comments, but don't worry +about converting to the preferred form unless you're editing that +comment anyway.) + +Rationale: Consistency, and ease of visually picking out a multiline +comment from the surrounding code. + 8. trace-events style 8.1 0x prefix
Signature · 1 line
2.17.1
Quoted 9 lines · Peter Maydell
The codebase has a bit of a mix of different multiline comment styles. State a preference for the Linux kernel style:
/*
* Star on the left for each line.
* Leading slash-star and trailing star-slash
* each go on a line of their own.
*/
Quoted 6 lines
Signed-off-by Peter Maydell <[email protected]>---
This is not my personal favourite, but seemed to be the closest we had to consensus in the mail thread for v1; I can live with it in order to avoid getting patches which use the styles I like even less :-)
Ditto that sentiment.
CODING_STYLE We use traditional C-style /* */ comments and avoid // comments. · line 127
Quoted 13 lines
--- CODING_STYLE | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)CODING_STYLE +1
-0@@ -124,6 +124,23 @@ We use traditional C-style /* */ comments and avoid // comments. Rationale: The // form is valid in C99, so this is purely a matter of consistency of style. The checkpatch script will warn you about this. +Multiline comments blocks should have a row of stars on the left,
s/comments/comment/
Quoted 6 lines
CODING_STYLE +6
-0+and the initial /* and terminating */ both on their own lines: + /* + * like + * this + */ +This is the same format required by the Linux kernel coding style.
CODING_STYLE We use traditional C-style /* */ comments and avoid // comments. · line 143
Quoted 10 lines
CODING_STYLE +10
-0+ +(Some of the existing comments in the codebase use the GNU Coding +Standards form which does not have stars on the left, or other +variations; avoid these when writing new comments, but don't worry +about converting to the preferred form unless you're editing that +comment anyway.) + +Rationale: Consistency, and ease of visually picking out a multiline +comment from the surrounding code. +
With the grammar fix,
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 10 lines · On Mon, 11 Jun 2018 15:17:16 +0100 Peter Maydell <[email protected]>…
The codebase has a bit of a mix of different multiline comment styles. State a preference for the Linux kernel style:
/*
* Star on the left for each line.
* Leading slash-star and trailing star-slash
* each go on a line of their own.
*/Signed-off-by Peter Maydell <[email protected]>
Quoted 8 lines
---
This is not my personal favourite, but seemed to be the closest we had to consensus in the mail thread for v1; I can live with it in order to avoid getting patches which use the styles I like even less :-)--- CODING_STYLE | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
Quoted 10 lines · Peter Maydell
The codebase has a bit of a mix of different multiline comment styles. State a preference for the Linux kernel style:
/*
* Star on the left for each line.
* Leading slash-star and trailing star-slash
* each go on a line of their own.
*/Signed-off-by Peter Maydell <[email protected]>
Quoted 37 lines · On Mon, 11 Jun 2018 15:17:16 +0100 Peter Maydell <[email protected]>…
The codebase has a bit of a mix of different multiline comment styles. State a preference for the Linux kernel style:
/*
* Star on the left for each line.
* Leading slash-star and trailing star-slash
* each go on a line of their own.
*/Signed-off-by Peter Maydell <[email protected]>---
This is not my personal favourite, but seemed to be the closest we had to consensus in the mail thread for v1; I can live with it in order to avoid getting patches which use the styles I like even less :-)--- CODING_STYLE | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)CODING_STYLE +10
-0@@ -124,6 +124,23 @@ We use traditional C-style /* */ comments and avoid // comments. Rationale: The // form is valid in C99, so this is purely a matter of consistency of style. The checkpatch script will warn you about this. +Multiline comments blocks should have a row of stars on the left, +and the initial /* and terminating */ both on their own lines: + /* + * like + * this + */ +This is the same format required by the Linux kernel coding style. + +(Some of the existing comments in the codebase use the GNU Coding +Standards form which does not have stars on the left, or other
CODING_STYLE We use traditional C-style /* */ comments and avoid // comments. · line 146
Quoted 10 lines
CODING_STYLE +7
-0+variations; avoid these when writing new comments, but don't worry +about converting to the preferred form unless you're editing that +comment anyway.) + +Rationale: Consistency, and ease of visually picking out a multiline +comment from the surrounding code. + 8. trace-events style 8.1 0x prefix
Much preferred, thanks (tabs next? ;)
Quoted 1 line · Alex Williamson
Much preferred, thanks (tabs next? ;)
CODING_STYLE already mandates spaces-only, no-tabs...
thanks
-- PMM
Quoted 4 lines · On Mon, 11 Jun 2018 17:40:35 +0100 Peter Maydell <[email protected]>…
Quoted 1 line · Alex Williamson
Much preferred, thanks (tabs next? ;)
CODING_STYLEalready mandates spaces-only, no-tabs...
That was a joke, note the smiley. I know, I just don't like it. Thanks,
Alex
Quoted 33 lines · Peter Maydell
The codebase has a bit of a mix of different multiline comment styles. State a preference for the Linux kernel style:
/*
* Star on the left for each line.
* Leading slash-star and trailing star-slash
* each go on a line of their own.
*/Signed-off-by Peter Maydell <[email protected]>---
This is not my personal favourite, but seemed to be the closest we had to consensus in the mail thread for v1; I can live with it in order to avoid getting patches which use the styles I like even less :-)--- CODING_STYLE | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)CODING_STYLE +6
-0@@ -124,6 +124,23 @@ We use traditional C-style /* */ comments and avoid // comments. Rationale: The // form is valid in C99, so this is purely a matter of consistency of style. The checkpatch script will warn you about this. +Multiline comments blocks should have a row of stars on the left, +and the initial /* and terminating */ both on their own lines: + /* + * like + * this + */
CODING_STYLE We use traditional C-style /* */ comments and avoid // comments. · line 142
Quoted 10 lines
CODING_STYLE +10
-0+This is the same format required by the Linux kernel coding style. + +(Some of the existing comments in the codebase use the GNU Coding +Standards form which does not have stars on the left, or other +variations; avoid these when writing new comments, but don't worry +about converting to the preferred form unless you're editing that +comment anyway.) + +Rationale: Consistency, and ease of visually picking out a multiline +comment from the surrounding code.
s/multiline/multi-line/g maybe? That seems to be the more common spelling...? Anyway:
Quoted 9 lines · Peter Maydell
The codebase has a bit of a mix of different multiline comment styles. State a preference for the Linux kernel style:
/*
* Star on the left for each line.
* Leading slash-star and trailing star-slash
* each go on a line of their own.
*/
Quoted 6 lines
Signed-off-by Peter Maydell <[email protected]>---
This is not my personal favourite, but seemed to be the closest we had to consensus in the mail thread for v1; I can live with it in order to avoid getting patches which use the styles I like even less :-)
"Same."
Well, at least it's not asymmetric.
Quoted 33 lines
--- CODING_STYLE | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)CODING_STYLE +17
-0@@ -124,6 +124,23 @@ We use traditional C-style /* */ comments and avoid // comments. Rationale: The // form is valid in C99, so this is purely a matter of consistency of style. The checkpatch script will warn you about this. +Multiline comments blocks should have a row of stars on the left, +and the initial /* and terminating */ both on their own lines: + /* + * like + * this + */ +This is the same format required by the Linux kernel coding style. + +(Some of the existing comments in the codebase use the GNU Coding +Standards form which does not have stars on the left, or other +variations; avoid these when writing new comments, but don't worry +about converting to the preferred form unless you're editing that +comment anyway.) + +Rationale: Consistency, and ease of visually picking out a multiline +comment from the surrounding code. + 8. trace-events style 8.1 0x prefix
Quoted 9 lines · Peter Maydell
The codebase has a bit of a mix of different multiline comment styles. State a preference for the Linux kernel style:
/*
* Star on the left for each line.
* Leading slash-star and trailing star-slash
* each go on a line of their own.
*/
Quoted 6 lines
Signed-off-by Peter Maydell <[email protected]>---
This is not my personal favourite, but seemed to be the closest we had to consensus in the mail thread for v1; I can live with it in order to avoid getting patches which use the styles I like even less :-)
Honestly, I don't like this except for "important" comments.
A "small" comment, e.g. one that doesn't quite fit on a single line, now takes 4 lines instead of 2. Which is really annoying and IMO tends to break flow.
If you don't like
/* gnu
style */
or
/* whatever
* this is */
could you live with
// c99/c++
// comments
(I know we currently deny those in checkpatch, but that's easy enough to remove if we're changing policy. I have no idea why we don't like them in the first place. Or other c99 features like mid-block or control declarations, for that matter.)
r~
Quoted 34 lines · Richard Henderson
Quoted 9 lines · Peter Maydell
The codebase has a bit of a mix of different multiline comment styles. State a preference for the Linux kernel style:
/*
* Star on the left for each line.
* Leading slash-star and trailing star-slash
* each go on a line of their own.
*/Quoted 6 lines
Signed-off-by Peter Maydell <[email protected]>---
This is not my personal favourite, but seemed to be the closest we had to consensus in the mail thread for v1; I can live with it in order to avoid getting patches which use the styles I like even less :-)Honestly, I don't like this except for "important" comments.
A "small" comment, e.g. one that doesn't quite fit on a single line, now takes 4 lines instead of 2. Which is really annoying and IMO tends to break flow.
If you don't like
/* gnu
style */or
/* whatever
* this is */could you live with
Quoted 7 lines
// c99/c++
// comments(I know we currently deny those in checkpatch, but that's easy enough to remove if we're changing policy. I have no idea why we don't like them in the first place. Or other c99 features like mid-block or control declarations, for that matter.)
+1 for control declarations :) Code is easier to read and keep focus on.
3.0 release is a good opportunity to establish such disruptive changes.
Quoted 29 lines · Richard Henderson
Quoted 9 lines · Peter Maydell
The codebase has a bit of a mix of different multiline comment styles. State a preference for the Linux kernel style:
/*
* Star on the left for each line.
* Leading slash-star and trailing star-slash
* each go on a line of their own.
*/Quoted 6 lines
Signed-off-by Peter Maydell <[email protected]>---
This is not my personal favourite, but seemed to be the closest we had to consensus in the mail thread for v1; I can live with it in order to avoid getting patches which use the styles I like even less :-)Honestly, I don't like this except for "important" comments.
A "small" comment, e.g. one that doesn't quite fit on a single line, now takes 4 lines instead of 2. Which is really annoying and IMO tends to break flow.
If you don't like
/* gnu
style */or
Quoted 7 lines
/* whatever
* this is */could you live with
// c99/c++
// comments
FWIW:
+1 for one or two of those compact styles for two- or three-line comments.
Thomas
Quoted 33 lines · On Tue, 12 Jun 2018 20:12:02 +0200 Thomas Huth <[email protected]> wrote:
Quoted 32 lines · Richard Henderson
Quoted 9 lines · Peter Maydell
The codebase has a bit of a mix of different multiline comment styles. State a preference for the Linux kernel style:
/*
* Star on the left for each line.
* Leading slash-star and trailing star-slash
* each go on a line of their own.
*/Quoted 6 lines
Signed-off-by Peter Maydell <[email protected]>---
This is not my personal favourite, but seemed to be the closest we had to consensus in the mail thread for v1; I can live with it in order to avoid getting patches which use the styles I like even less :-)Honestly, I don't like this except for "important" comments.
A "small" comment, e.g. one that doesn't quite fit on a single line, now takes 4 lines instead of 2. Which is really annoying and IMO tends to break flow.
If you don't like
/* gnu
style */or
/* whatever
* this is */
Quoted 8 lines
Quoted 4 lines
could you live with
// c99/c++
// commentsFWIW:
+1 for one or two of those compact styles for two- or three-line comments.
or four-line or single paragraphs or comments that rhyme with "orange"... If the comment is too large for a single line, then take some time to say it more concisely, or maybe it does deserve enough thought to frame a nice paragraph for it. We're well into personal style here, so either this is important enough to make some people unhappy or we should leave it to maintainer preference and consistency within a file/area. Thanks,
Alex
Quoted 45 lines · On Tue, 12 Jun 2018 12:47:29 -0600 Alex Williamson…
Quoted 33 lines · On Tue, 12 Jun 2018 20:12:02 +0200 Thomas Huth <[email protected]> wrote:
Quoted 32 lines · Richard Henderson
Quoted 9 lines · Peter Maydell
The codebase has a bit of a mix of different multiline comment styles. State a preference for the Linux kernel style:
/*
* Star on the left for each line.
* Leading slash-star and trailing star-slash
* each go on a line of their own.
*/Quoted 6 lines
Signed-off-by Peter Maydell <[email protected]>---
This is not my personal favourite, but seemed to be the closest we had to consensus in the mail thread for v1; I can live with it in order to avoid getting patches which use the styles I like even less :-)Honestly, I don't like this except for "important" comments.
A "small" comment, e.g. one that doesn't quite fit on a single line, now takes 4 lines instead of 2. Which is really annoying and IMO tends to break flow.
If you don't like
/* gnu
style */or
/* whatever
* this is */Quoted 8 lines
Quoted 4 lines
could you live with
// c99/c++
// commentsFWIW:
+1 for one or two of those compact styles for two- or three-line comments.
Quoted 7 lines
or four-line or single paragraphs or comments that rhyme with "orange"... If the comment is too large for a single line, then take some time to say it more concisely, or maybe it does deserve enough thought to frame a nice paragraph for it. We're well into personal style here, so either this is important enough to make some people unhappy or we should leave it to maintainer preference and consistency within a file/area. Thanks,
+1 to maintainer judgment and consistency.
(And FWIW, c++ style comments are what I use when I comment something out for debugging, so I don't like them in regular code :)
Quoted 17 lines · Richard Henderson
Quoted 9 lines · Peter Maydell
The codebase has a bit of a mix of different multiline comment styles. State a preference for the Linux kernel style:
/*
* Star on the left for each line.
* Leading slash-star and trailing star-slash
* each go on a line of their own.
*/Quoted 6 lines
Signed-off-by Peter Maydell <[email protected]>---
This is not my personal favourite, but seemed to be the closest we had to consensus in the mail thread for v1; I can live with it in order to avoid getting patches which use the styles I like even less :-)
Quoted 4 lines
Honestly, I don't like this except for "important" comments.
A "small" comment, e.g. one that doesn't quite fit on a single line, now takes 4 lines instead of 2. Which is really annoying and IMO tends to break flow.
That's why I prefer
/* two
* lines
*/
style over kernel-style. But apparently nobody else does...
thanks
-- PMM
Quoted 21 lines · Peter Maydell
Quoted 19 lines · Richard Henderson
Quoted 9 lines · Peter Maydell
The codebase has a bit of a mix of different multiline comment styles. State a preference for the Linux kernel style:
/*
* Star on the left for each line.
* Leading slash-star and trailing star-slash
* each go on a line of their own.
*/Quoted 6 lines
Signed-off-by Peter Maydell <[email protected]>---
This is not my personal favourite, but seemed to be the closest we had to consensus in the mail thread for v1; I can live with it in order to avoid getting patches which use the styles I like even less :-)Honestly, I don't like this except for "important" comments.
Quoted 8 lines
Quoted 2 lines
A "small" comment, e.g. one that doesn't quite fit on a single line, now takes 4 lines instead of 2. Which is really annoying and IMO tends to break flow.
That's why I prefer
/* two
* lines
*/
style over kernel-style. But apparently nobody else does...
The same reasoning could be used to justify
/* two
* lines */
as it's ... actually just two lines. I think people don't seem to like this much either (why? does it look 'naked' on the end?) and seemingly the asymmetry is a bit of a killer for the isolated close-comment style:
/* asymmetric
* three lines
*/
so we seemed to have arrived on the vertically symmetric:
/*
* four
* lines
*/
style. I think this is a pretty reasonable compromise with the tastes of the various maintainers that have chimed in so far -- it seems to be nobody's favorite but everyone's second choice :)
If there is concern this will balloon "almost" single line comments into four lines, I think the overall strategy of being either more concise (or being 70 characters more detailed!) is probably reasonable enough.
...Overall I think it probably doesn't matter too much as long as comments in each individual file are consistent.
It would only begin to matter terribly much if we actually decided we wanted to do a doxygen-style doc generation for our internal APIs for compatibility with, say, fancier IDEs than vim/emacs.
As it stands, we're pretty inconsistent about which exact style we apply when we "document" internal functions -- sometimes we document the header, sometimes the implementation, sometimes both (but differently!) and always with different styles all over the place. That's the real problem, IMO.
For non-javadoc style comments that aren't intended to document a function in some methodical way, I think as long as it looks nice in the file as deemed by the maintainer and it's consistent, it's probably fine.
Quoted 4 lines
thanks
-- PMM
Now I can say after working at Red Hat for four years that I've finally had a real life "tabs vs spaces" argument, too. I guess I had a good run without :)
--js
Quoted 7 lines · John Snow
The same reasoning could be used to justify
/* two
* lines */as it's ... actually just two lines. I think people don't seem to like this much either (why? does it look 'naked' on the end?)
I dislike the way it breaks up the line of stars. For me it is the /*
*
*/
shape that defines a multiline comment, and where exactly the text is on the RHS of it is not important to my sense of visual neatness :-)
Quoted 3 lines
It would only begin to matter terribly much if we actually decided we wanted to do a doxygen-style doc generation for our internal APIs for compatibility with, say, fancier IDEs than vim/emacs.
We ought to do that at some point -- I had some prototype patches for it. Doc-comment comments always start /** on a line of its own, though.
Quoted 5 lines
As it stands, we're pretty inconsistent about which exact style we apply when we "document" internal functions -- sometimes we document the header, sometimes the implementation, sometimes both (but differently!) and always with different styles all over the place. That's the real problem, IMO.
IMHO -- global functions should always be documented in the header with the prototype, and any new global function should get a doc comment (I require this for code I review...) I should be able to read about the API your code exposes to the rest of QEMU purely by looking at your headers.
thanks
-- PMM
Quoted 9 lines · Peter Maydell
Quoted 7 lines · John Snow
The same reasoning could be used to justify
/* two
* lines */as it's ... actually just two lines. I think people don't seem to like this much either (why? does it look 'naked' on the end?)
Quoted 7 lines
I dislike the way it breaks up the line of stars. For me it is the /*
*
*/
shape that defines a multiline comment, and where exactly the text is on the RHS of it is not important to my sense of visual neatness :-)
Yours does look an awful lot more symmetrical once you remove the text, yeah.
*cough* I hate the way it looks too, but C99 comments have a few things going for them:
// A multi-line comment block like this has no extra lines and every // line in the comment is prefaced individually which aids grep // readability, while maintained good vertical symmetry.
I think we hate C99 comments, though? Certainly we don't use them at all right now, so it's not a good fit.
Quoted 8 lines
Quoted 3 lines
It would only begin to matter terribly much if we actually decided we wanted to do a doxygen-style doc generation for our internal APIs for compatibility with, say, fancier IDEs than vim/emacs.
We ought to do that at some point -- I had some prototype patches for it. Doc-comment comments always start /** on a line of its own, though.
I'd love this! I love vim/emacs, but my usage of it is not wizard-tier and in the past when working on large C++ projects I have benefited from the magical refactoring click-buttons, tool-tips and etc. These operations are infrequent enough that I believe it's reasonable to not know how to do them in traditional CLI editors. If we want to lure in new contributors, maybe this could sweeten the pot a bit?
Rigorous, mechanically verifiable function documentation is quite nice to have in these cases. It'd be nice in general, really. It would go a long way to help us attract less "hardcore" developers implementing devices and features for QEMU without such a steep onboarding curve.
Do you have a proposed standard / do we have some consensus on which generator tool or doc format we'd most like to see in QEMU? I could put in some elbow grease to shine up the block layer if so...
Quoted 6 lines
Quoted 5 lines
As it stands, we're pretty inconsistent about which exact style we apply when we "document" internal functions -- sometimes we document the header, sometimes the implementation, sometimes both (but differently!) and always with different styles all over the place. That's the real problem, IMO.
Quoted 6 lines
IMHO -- global functions should always be documented in the header with the prototype, and any new global function should get a doc comment (I require this for code I review...) I should be able to read about the API your code exposes to the rest of QEMU purely by looking at your headers.
This makes sense, though the way C code is laid out makes it unfortunate you don't get to see the same comment right beside the implementation if that's what you're working on -- but I suppose this is why we have tabs, multi-monitors and IDEs with tooltips.
Quoted 3 lines
thanks
-- PMM
Quoted 69 lines · John Snow
Quoted 9 lines · Peter Maydell
Quoted 7 lines · John Snow
The same reasoning could be used to justify
/* two
* lines */as it's ... actually just two lines. I think people don't seem to like this much either (why? does it look 'naked' on the end?)
Quoted 7 lines
I dislike the way it breaks up the line of stars. For me it is the /*
*
*/
shape that defines a multiline comment, and where exactly the text is on the RHS of it is not important to my sense of visual neatness :-)Yours does look an awful lot more symmetrical once you remove the text, yeah.
*cough* I hate the way it looks too, but C99 comments have a few things going for them:
// A multi-line comment block like this has no extra lines and every // line in the comment is prefaced individually which aids grep // readability, while maintained good vertical symmetry.
I think we hate C99 comments, though? Certainly we don't use them at all right now, so it's not a good fit.
Quoted 8 lines
Quoted 3 lines
It would only begin to matter terribly much if we actually decided we wanted to do a doxygen-style doc generation for our internal APIs for compatibility with, say, fancier IDEs than vim/emacs.
We ought to do that at some point -- I had some prototype patches for it. Doc-comment comments always start /** on a line of its own, though.
I'd love this! I love vim/emacs, but my usage of it is not wizard-tier and in the past when working on large C++ projects I have benefited from the magical refactoring click-buttons, tool-tips and etc. These operations are infrequent enough that I believe it's reasonable to not know how to do them in traditional CLI editors. If we want to lure in new contributors, maybe this could sweeten the pot a bit?
Rigorous, mechanically verifiable function documentation is quite nice to have in these cases. It'd be nice in general, really. It would go a long way to help us attract less "hardcore" developers implementing devices and features for QEMU without such a steep onboarding curve.
Do you have a proposed standard / do we have some consensus on which generator tool or doc format we'd most like to see in QEMU? I could put in some elbow grease to shine up the block layer if so...
Quoted 6 lines
Quoted 5 lines
As it stands, we're pretty inconsistent about which exact style we apply when we "document" internal functions -- sometimes we document the header, sometimes the implementation, sometimes both (but differently!) and always with different styles all over the place. That's the real problem, IMO.
Quoted 6 lines
IMHO -- global functions should always be documented in the header with the prototype, and any new global function should get a doc comment (I require this for code I review...) I should be able to read about the API your code exposes to the rest of QEMU purely by looking at your headers.
Quoted 4 lines
This makes sense, though the way C code is laid out makes it unfortunate you don't get to see the same comment right beside the implementation if that's what you're working on -- but I suppose this is why we have tabs, multi-monitors and IDEs with tooltips.
Thanks to tabs we don't need multi-monitors of 1600+ resolution to fit 80 chars per line.
Quoted 2 lines · John Snow
On 06/14/2018 06:46 AM, Peter Maydell wrote:
[...]
Quoted 10 lines
*cough* I hate the way it looks too, but C99 comments have a few things going for them:
// A multi-line comment block like this has no extra lines and every // line in the comment is prefaced individually which aids grep // readability, while maintained good vertical symmetry.
I think we hate C99 comments, though? Certainly we don't use them at all right now, so it's not a good fit.
But why do we hate them? I remember there were some reasons for not using them 10 or 15 years ago (some old C-compilers still did not support them yet), but today? ... it's likely just a legacy feeling. Maybe it's time to get over that feeling now?
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
It would only begin to matter terribly much if we actually decided we wanted to do a doxygen-style doc generation for our internal APIs for compatibility with, say, fancier IDEs than vim/emacs.
[...]
Quoted 3 lines
Do you have a proposed standard / do we have some consensus on which generator tool or doc format we'd most like to see in QEMU? I could put in some elbow grease to shine up the block layer if so...
I remember that some years ago, somebody (I forgot who it was, sorry) once told me that we should use the same format in QEMU as in glib, i.e. GTK-Doc. But citing the GTK-Doc homepage: "For a more polished general-purpose documentation tool you may want to look at Doxygen" - so maybe that's the better choice instead.
Thomas
Quoted 10 lines · Thomas Huth
Quoted 3 lines · John Snow
Do you have a proposed standard / do we have some consensus on which generator tool or doc format we'd most like to see in QEMU? I could put in some elbow grease to shine up the block layer if so...
I remember that some years ago, somebody (I forgot who it was, sorry) once told me that we should use the same format in QEMU as in glib, i.e. GTK-Doc. But citing the GTK-Doc homepage: "For a more polished general-purpose documentation tool you may want to look at Doxygen" - so maybe that's the better choice instead.
The last round of email threads on this basically concluded that we should use sphinx, which is what the kernel uses. So kernel-doc comment format, and rst for standalone docs files. Some tidying up of our current doc comments would be required (which are a bit of a mishmash of styles plus syntax errors because we've never done any kind of processing of them to keep us from making mistakes).
thanks
-- PMM
Quoted 1 line · Peter Maydell
On 13 June 2018 at 17:55, John Snow <[email protected]> wrote:
[...]
Quoted 14 lines
Quoted 3 lines
It would only begin to matter terribly much if we actually decided we wanted to do a doxygen-style doc generation for our internal APIs for compatibility with, say, fancier IDEs than vim/emacs.
We ought to do that at some point -- I had some prototype patches for it. Doc-comment comments always start /** on a line of its own, though.
Quoted 5 lines
As it stands, we're pretty inconsistent about which exact style we apply when we "document" internal functions -- sometimes we document the header, sometimes the implementation, sometimes both (but differently!) and always with different styles all over the place. That's the real problem, IMO.
Quoted 5 lines
IMHO -- global functions should always be documented in the header with the prototype, and any new global function should get a doc comment (I require this for code I review...) I should be able to read about the API your code exposes to the rest of QEMU purely by looking at your headers.
Putting the function contract far from the actual function is a proven way to end up with a contract that is far from what the function actually does.
With a documentation generator such as Sphinx, the usual argument for putting the contracts in headers "I want API documentation in one place, without clutter" carries a lot less weight: the generated documentation is exactly that.
Quoted 10 lines · Peter Maydell
The codebase has a bit of a mix of different multiline comment styles. State a preference for the Linux kernel style:
/*
* Star on the left for each line.
* Leading slash-star and trailing star-slash
* each go on a line of their own.
*/Signed-off-by Peter Maydell <[email protected]>
Quoted 8 lines
---
This is not my personal favourite, but seemed to be the closest we had to consensus in the mail thread for v1; I can live with it in order to avoid getting patches which use the styles I like even less :-)--- CODING_STYLE | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)