wrap-comments.fmt.sol 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // config: line_length = 40
  2. // config: wrap_comments = true
  3. pragma solidity ^0.8.13;
  4. /// @title A Hello world example
  5. contract HelloWorld {
  6. /// Some example struct
  7. struct Person {
  8. uint256 age;
  9. address wallet;
  10. }
  11. /**
  12. * Here's a more double asterix
  13. * comment
  14. */
  15. Person public theDude;
  16. /// Constructs the dude
  17. /// @param age The dude's age
  18. constructor(uint256 age) {
  19. theDude = Person({
  20. age: age,
  21. wallet: msg.sender
  22. });
  23. }
  24. /**
  25. * @dev does nothing
  26. */
  27. function example() public {
  28. /**
  29. * Does this add a whitespace
  30. * error?
  31. *
  32. * Let's find out.
  33. */
  34. }
  35. /**
  36. * @dev Calculates a rectangle's
  37. * surface and perimeter.
  38. * @param w Width of the rectangle.
  39. * @param h Height of the rectangle.
  40. * @return s The calculated surface.
  41. * @return p The calculated
  42. * perimeter.
  43. */
  44. function rectangle(
  45. uint256 w,
  46. uint256 h
  47. )
  48. public
  49. pure
  50. returns (uint256 s, uint256 p)
  51. {
  52. s = w * h;
  53. p = 2 * (w + h);
  54. }
  55. /// A long doc line comment that
  56. /// will be wrapped
  57. function docLineOverflow()
  58. external
  59. {}
  60. function docLinePostfixOverflow()
  61. external
  62. {}
  63. /// A long doc line comment that
  64. /// will be wrapped
  65. /**
  66. * @notice Here is my comment
  67. * - item 1
  68. * - item 2
  69. * Some equations:
  70. * y = mx + b
  71. */
  72. function anotherExample()
  73. external
  74. {}
  75. /**
  76. * contract A {
  77. * function foo() public {
  78. * // does nothing.
  79. * }
  80. * }
  81. */
  82. function multilineIndent()
  83. external
  84. {}
  85. /**
  86. * contract A {
  87. * function foo() public {
  88. * // does nothing.
  89. * }
  90. * }
  91. */
  92. function multilineMalformedIndent()
  93. external
  94. {}
  95. /**
  96. * contract A {
  97. * function
  98. * withALongNameThatWillCauseCommentWrap()
  99. * public {
  100. * // does nothing.
  101. * }
  102. * }
  103. */
  104. function malformedIndentOverflow()
  105. external
  106. {}
  107. }
  108. /**
  109. * contract A {
  110. * function foo() public {
  111. * // does nothing.
  112. * }
  113. * }
  114. */
  115. function freeFloatingMultilineIndent() {}