summaryrefslogtreecommitdiff
path: root/CPP_STYLE_GUIDE.md
AgeCommit message (Collapse)Author
2019-11-22src,doc: add C++ internals documentationAnna Henningsen
This aims to help explain some of the internal patterns and utilities that we use. It is by no means exhaustive, and suggestions for additions are welcome. Some of this is based on the existing work from #26929. Refs: https://github.com/nodejs/node/pull/26929 PR-URL: https://github.com/nodejs/node/pull/30552 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2019-10-15doc: prepare miscellaneous docs for new markdown lint rulesRich Trott
Prepare the final few documents that haven't been updated to always use `[]` with reference links and to escape `[` and `]` for things that aren't links in markdown files. PR-URL: https://github.com/nodejs/node/pull/29963 Reviewed-By: Masashi Hirano <shisama07@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-09-16doc: use consistent unordered list styleNick Schonning
Convert to asterisks when there are mixed styles in document. Addresses Markdownlint MD004 rule PR-URL: https://github.com/nodejs/node/pull/29516 Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-09-09doc: space around listsNick Schonning
Address markdownlint rule MD032. Flagged a few mixed list styles. PR-URL: https://github.com/nodejs/node/pull/29467 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-08-31doc: add blanks around code fencesNick Schonning
Addresses Markdownlint MD031 rule warnings PR-URL: https://github.com/nodejs/node/pull/29366 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: David Carlier <devnexen@gmail.com>
2019-08-31doc: remove multiple consecutive blank linesNick Schonning
These are rendered as single breaks. Addresses Markdownlint MD012 rule. PR-URL: https://github.com/nodejs/node/pull/29352 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-06-23doc: remove "note that" from CPP_STYLE_GUIDE.mdRich Trott
Refs: https://github.com/nodejs/remark-preset-lint-node/pull/16 PR-URL: https://github.com/nodejs/node/pull/28329 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-01-08doc: fix heading in cpp style guideKazushi Kitaya
Names of c-like structs do not have to end with an underscore. PR-URL: https://github.com/nodejs/node/pull/25303 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-12-04doc: add a note on usage scope of AliasedBufferGireesh Punathil
Explain usage context and scope of AliasedBuffer API and its function in the C++ style guide. Provide an example code. Fixes: https://github.com/nodejs/node/issues/22977 PR-URL: https://github.com/nodejs/node/pull/24724 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
2018-10-25doc: document nullptr comparisons in style guideAnna Henningsen
This documents existing practices. PR-URL: https://github.com/nodejs/node/pull/23805 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2018-10-21doc: formalize non-const reference usage in C++ style guideAnna Henningsen
We generally avoid using non-const references if not necessary. This formalizes this rules by writing them down in the C++ style guide. (Note: Some reviews are from the original PR.) Refs: https://github.com/nodejs/node/pull/23028 PR-URL: https://github.com/nodejs/node/pull/23155 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
2018-10-16doc: cleanup and references in C++ guideRefael Ackermann
PR-URL: https://github.com/nodejs/node/pull/23650 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-10-13doc,meta: add references to outside C++ guidesRefael Ackermann
with explicit priorities PR-URL: https://github.com/nodejs/node/pull/23317 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-09-30doc: formalize `auto` usage in C++ style guideAnna Henningsen
We generally avoid using `auto` if not necessary. This formalizes this rules by writing them down in the C++ style guide. PR-URL: https://github.com/nodejs/node/pull/23028 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2018-09-24doc: fix heading levels in C++ style guideAnna Henningsen
Adjust heading levels to align with the table of contents. Refs: https://github.com/nodejs/node/pull/23028 PR-URL: https://github.com/nodejs/node/pull/23061 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2018-05-06doc: add snake_case section for C-like structsDaniel Bevenius
This commit adds a section mentioning that for C-like structs it is alright to use snake_case. PR-URL: https://github.com/nodejs/node/pull/20423 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-03-10doc: update internal errors documentationMichaël Zasso
PR-URL: https://github.com/nodejs/node/pull/19203 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2018-01-17doc: suggest not to throw JS errors from C++Joyee Cheung
Also provide an example on how to use internal/errors to handle errors in C++. PR-URL: https://github.com/nodejs/node/pull/18149 Refs: https://github.com/nodejs/node/issues/18106 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2017-12-15doc: add C++ style comments to the style guideMatheus Marchini
Adds instructions on how to format C++ comments to the C++ style guide, as `cpplint.py` doesn't complain about C-style comments on the code. PR-URL: https://github.com/nodejs/node/pull/17617 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2017-12-05doc: add serial comma in CPP_STYLE_GUIDE.mdRich Trott
PR-URL: https://github.com/nodejs/node/pull/17464 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-12-03doc: introduce categories to Cpp style guideFranziska Hinkelmann
Ref: https://github.com/nodejs/node/pull/17052#discussion_r151228700 PR-URL: https://github.com/nodejs/node/pull/17095 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-12-01doc: add missing serial commasRich Trott
PR-URL: https://github.com/nodejs/node/pull/17384 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2017-11-17doc: mention smart pointers in Cpp style guideFranziska Hinkelmann
Add rule for smart pointers, i.e., std::unique_ptr and std::shared_ptr, to the Cpp style guide. Mostly copied from the Google style guide. PR-URL: https://github.com/nodejs/node/pull/17055 Ref: https://github.com/nodejs/node/pull/16970 Ref: https://github.com/nodejs/node/pull/16974 Ref: https://github.com/nodejs/node/pull/17000 Ref: https://github.com/nodejs/node/pull/17012 Ref: https://github.com/nodejs/node/pull/17020 Ref: https://github.com/nodejs/node/pull/17030 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-11-16doc: add Table of Contents to Cpp style guideFranziska Hinkelmann
The Cpp style guide is growing. IMHO, a Table of Contents makes it easier to navigate. PR-URL: https://github.com/nodejs/node/pull/17052 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2017-10-30doc: add *-inl.h include rule to C++ style guideJoyee Cheung
PR-URL: https://github.com/nodejs/node/pull/16548 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-10-14doc: add basic C++ style guideAnna Henningsen
Ideally, most of these things would be enforced via linter rules. This is a first step into having a style guide that goes beyond what the linter currently enforces. PR-URL: https://github.com/nodejs/node/pull/16090 Fixes: https://github.com/nodejs/node/issues/12636 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>