You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/contributor/pages/code-style-guide.adoc
+82Lines changed: 82 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -275,6 +275,88 @@ If any of the items are commented, all items should be.
275
275
It should however also be noted that there is no requirement to comment fields or variants.
276
276
Comments should only be added if they provide additional information not available from context.
277
277
278
+
== Comments
279
+
280
+
General rules apply for both doc comments and developer comments.
281
+
The comments should not exceed a line-width of 100 characters with the exception of URLs.
282
+
Long inline URLs should be avoided.
283
+
Put links onto their own line or reference them with Markdown references instead.
284
+
Comments should always form complete sentences with full stops at the end.
285
+
286
+
[TIP.code-rule,caption=Examples of correct code for this rule]
287
+
====
288
+
289
+
[source]
290
+
----
291
+
100 characters v
292
+
|
293
+
/// This is my comment which exceeds
294
+
/// the width of 100 characters and|
295
+
/// thus needs to [wrap][1]. |
296
+
/// |
297
+
/// Another comment where the |
298
+
/// final dot exceeds the |
299
+
/// line-width. |
300
+
/// |
301
+
/// [1]: https::example.com/path/to/file.html
302
+
----
303
+
304
+
'''
305
+
306
+
[source]
307
+
----
308
+
100 characters v
309
+
|
310
+
// This is a dev comment which links
311
+
// to a bunch of PRs. See: |
312
+
// |
313
+
// - https://example.com/project/pull/123
314
+
// - https://example.com/project/pull/321
315
+
----
316
+
317
+
====
318
+
319
+
[WARNING.code-rule,caption=Examples of incorrect code for this rule]
320
+
====
321
+
322
+
[source]
323
+
----
324
+
100 characters v
325
+
|
326
+
/// This is my comment which exceeds the
327
+
/// width of 100 characters and thus needs
328
+
/// to [wrap](https::example.com/path/to/file.html).
329
+
/// |
330
+
/// Another comment where the |
331
+
/// final dot exceeds the line-width.
332
+
----
333
+
334
+
'''
335
+
336
+
[source]
337
+
----
338
+
100 characters v
339
+
|
340
+
// This is a dev comment which links
341
+
// to a bunch of PRs. See: https://example.com/project/pull/123
342
+
// and https://example.com/project/pull/321
343
+
----
344
+
345
+
====
346
+
347
+
Additionally, doc comments should follow the structure outlined by the Rust project, which is described https://doc.rust-lang.org/rustdoc/how-to-write-documentation.html#documenting-components[here]:
348
+
349
+
[source]
350
+
----
351
+
[short sentence explaining what it is]
352
+
353
+
[more detailed explanation]
354
+
355
+
[at least one code example that users can copy/paste to try it]
0 commit comments