format-docstring 0.4.0__tar.gz → 0.4.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) hide show
  1. {format_docstring-0.4.0 → format_docstring-0.4.2}/AGENTS.md +7 -0
  2. {format_docstring-0.4.0 → format_docstring-0.4.2}/CHANGELOG.md +32 -0
  3. {format_docstring-0.4.0 → format_docstring-0.4.2}/PKG-INFO +61 -1
  4. {format_docstring-0.4.0 → format_docstring-0.4.2}/README.md +60 -0
  5. {format_docstring-0.4.0 → format_docstring-0.4.2}/format_docstring/docstring_rewriter.py +83 -1
  6. {format_docstring-0.4.0 → format_docstring-0.4.2}/format_docstring/line_wrap_google.py +104 -44
  7. {format_docstring-0.4.0 → format_docstring-0.4.2}/format_docstring/line_wrap_numpy.py +7 -4
  8. {format_docstring-0.4.0 → format_docstring-0.4.2}/format_docstring/line_wrap_utils.py +90 -3
  9. {format_docstring-0.4.0 → format_docstring-0.4.2}/format_docstring.egg-info/PKG-INFO +61 -1
  10. {format_docstring-0.4.0 → format_docstring-0.4.2}/format_docstring.egg-info/SOURCES.txt +5 -0
  11. {format_docstring-0.4.0 → format_docstring-0.4.2}/pyproject.toml +1 -1
  12. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/empty_lines_are_respected.txt +2 -2
  13. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/four_level_nested_classes.txt +3 -3
  14. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/indent_two_levels_8_spaces.txt +5 -5
  15. format_docstring-0.4.2/tests/test_data/end_to_end/google/inline_literal_is_not_split.txt +69 -0
  16. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/new_lines_before_and_after.txt +18 -20
  17. format_docstring-0.4.2/tests/test_data/end_to_end/google/opening_width_prefixes.txt +79 -0
  18. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/sections_notes_examples.txt +3 -3
  19. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/single_line_docstring.txt +4 -6
  20. format_docstring-0.4.2/tests/test_data/end_to_end/numpy/inline_literal_is_not_split.txt +77 -0
  21. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/integration_test/google/after.ipynb +2 -2
  22. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/integration_test/google/after.py +2 -2
  23. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/integration_test/google/after_50.ipynb +2 -2
  24. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/integration_test/google/after_50.py +2 -2
  25. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/empty_lines_are_respected.txt +2 -2
  26. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/fix_rst_backticks.txt +3 -2
  27. format_docstring-0.4.2/tests/test_data/line_wrap/google/inline_literal_is_not_split.txt +44 -0
  28. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/fix_rst_backticks.txt +2 -2
  29. format_docstring-0.4.2/tests/test_data/line_wrap/numpy/inline_literal_is_not_split.txt +41 -0
  30. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_docstring_rewriter.py +262 -0
  31. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_google_fixture_inventory.py +5 -1
  32. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_line_wrap_google.py +44 -1
  33. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_line_wrap_utils.py +116 -0
  34. {format_docstring-0.4.0 → format_docstring-0.4.2}/.github/workflows/python-package.yml +0 -0
  35. {format_docstring-0.4.0 → format_docstring-0.4.2}/.github/workflows/python-publish.yml +0 -0
  36. {format_docstring-0.4.0 → format_docstring-0.4.2}/.gitignore +0 -0
  37. {format_docstring-0.4.0 → format_docstring-0.4.2}/.pre-commit-config.yaml +0 -0
  38. {format_docstring-0.4.0 → format_docstring-0.4.2}/.pre-commit-hooks.yaml +0 -0
  39. {format_docstring-0.4.0 → format_docstring-0.4.2}/LICENSE +0 -0
  40. {format_docstring-0.4.0 → format_docstring-0.4.2}/format_docstring/__init__.py +0 -0
  41. {format_docstring-0.4.0 → format_docstring-0.4.2}/format_docstring/base_fixer.py +0 -0
  42. {format_docstring-0.4.0 → format_docstring-0.4.2}/format_docstring/config.py +0 -0
  43. {format_docstring-0.4.0 → format_docstring-0.4.2}/format_docstring/main_jupyter.py +0 -0
  44. {format_docstring-0.4.0 → format_docstring-0.4.2}/format_docstring/main_py.py +0 -0
  45. {format_docstring-0.4.0 → format_docstring-0.4.2}/format_docstring/section_utils.py +0 -0
  46. {format_docstring-0.4.0 → format_docstring-0.4.2}/format_docstring.egg-info/dependency_links.txt +0 -0
  47. {format_docstring-0.4.0 → format_docstring-0.4.2}/format_docstring.egg-info/entry_points.txt +0 -0
  48. {format_docstring-0.4.0 → format_docstring-0.4.2}/format_docstring.egg-info/requires.txt +0 -0
  49. {format_docstring-0.4.0 → format_docstring-0.4.2}/format_docstring.egg-info/top_level.txt +0 -0
  50. {format_docstring-0.4.0 → format_docstring-0.4.2}/muff.toml +0 -0
  51. {format_docstring-0.4.0 → format_docstring-0.4.2}/requirements.dev +0 -0
  52. {format_docstring-0.4.0 → format_docstring-0.4.2}/setup.cfg +0 -0
  53. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/__init__.py +0 -0
  54. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/helpers.py +0 -0
  55. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_base_fixer.py +0 -0
  56. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_config.py +0 -0
  57. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/cli_options/google/include_arg_defaults_false.txt +0 -0
  58. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/cli_options/google/include_arg_types_and_defaults_false.txt +0 -0
  59. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/cli_options/google/include_arg_types_and_defaults_true.txt +0 -0
  60. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/cli_options/google/include_return_and_yield_types_false.txt +0 -0
  61. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/cli_options/numpy/include_arg_defaults_false.txt +0 -0
  62. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/cli_options/numpy/include_arg_types_and_defaults_false.txt +0 -0
  63. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/cli_options/numpy/include_arg_types_and_defaults_true.txt +0 -0
  64. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/README.md +0 -0
  65. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/arg_name_is_default.txt +0 -0
  66. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/class_attribute_type_comment_defaults.txt +0 -0
  67. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/colon_spacing_fix.txt +0 -0
  68. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/contents_that_are_not_wrapped.txt +0 -0
  69. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/custom_section_after_args.txt +0 -0
  70. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/custom_section_after_doctest.txt +0 -0
  71. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/custom_section_before_args.txt +0 -0
  72. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/default_value_standardization.txt +0 -0
  73. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/doctest_output_lines_are_preserved.txt +0 -0
  74. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/examples_plain_code_after_doctest.txt +0 -0
  75. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/examples_section.txt +0 -0
  76. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/existing_linebreaks_should_not_be_respected.txt +0 -0
  77. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/fix_rst_backticks.txt +0 -0
  78. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/indent_four_levels_16_spaces_width_10.txt +0 -0
  79. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/indent_misaligned_all.txt +0 -0
  80. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/keyword_args_section.txt +0 -0
  81. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/line_length_2.txt +0 -0
  82. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/literal_block_backticks_are_preserved.txt +0 -0
  83. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/literal_block_blank_lines_backticks_are_preserved.txt +0 -0
  84. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/module_docstring_indent_zero_is_not_inferred.txt +0 -0
  85. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/module_level_docstring.txt +0 -0
  86. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/no_format_docstring_comment.txt +0 -0
  87. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/no_terminal_whitespace_only_line.txt +0 -0
  88. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/non_ascii_docstrings.txt +0 -0
  89. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/non_ascii_single_line_length_boundary.txt +0 -0
  90. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/param_signature_without_type.txt +0 -0
  91. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/parameters_returns_raises_wrapping.txt +0 -0
  92. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/plain_examples_code_is_preserved.txt +0 -0
  93. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/rST_cross_reference.txt +0 -0
  94. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/returns_bare_type_with_description_sync.txt +0 -0
  95. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/returns_colon_description_sync.txt +0 -0
  96. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/returns_description_without_type_sync.txt +0 -0
  97. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/returns_signature_and_description.txt +0 -0
  98. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/returns_yields_type_like_description_sync.txt +0 -0
  99. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/rst_code_block_backticks_are_preserved.txt +0 -0
  100. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/section_headings_with_colons.txt +0 -0
  101. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/section_title_fixed.txt +0 -0
  102. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/signature_dont_sync_raises.txt +0 -0
  103. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/signature_line_is_not_wrapped.txt +0 -0
  104. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/signature_sync_class_docstrings.txt +0 -0
  105. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/signature_sync_parameters.txt +0 -0
  106. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/signature_sync_returns.txt +0 -0
  107. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/signature_sync_yields.txt +0 -0
  108. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/single_line_backtick_expansion_respects_line_length.txt +0 -0
  109. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/texts_are_rewrapped.txt +0 -0
  110. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/tilde_code_fence_is_preserved.txt +0 -0
  111. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/variadic_signature_without_colon.txt +0 -0
  112. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/very_long_unbreakable_word.txt +0 -0
  113. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/google/yields_iterator_item_type_sync.txt +0 -0
  114. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/README.md +0 -0
  115. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/arg_name_is_default.txt +0 -0
  116. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/class_attribute_type_comment_defaults.txt +0 -0
  117. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/colon_spacing_fix.txt +0 -0
  118. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/contents_that_are_not_wrapped.txt +0 -0
  119. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/custom_section_after_args.txt +0 -0
  120. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/custom_section_after_doctest.txt +0 -0
  121. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/custom_section_before_args.txt +0 -0
  122. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/default_value_standardization.txt +0 -0
  123. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/doctest_output_lines_are_preserved.txt +0 -0
  124. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/empty_lines_are_respected.txt +0 -0
  125. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/examples_plain_code_after_doctest.txt +0 -0
  126. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/examples_section.txt +0 -0
  127. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/existing_linebreaks_should_not_be_respected.txt +0 -0
  128. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/fix_rst_backticks.txt +0 -0
  129. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/four_level_nested_classes.txt +0 -0
  130. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/indent_four_levels_16_spaces_width_10.txt +0 -0
  131. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/indent_misaligned_all.txt +0 -0
  132. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/indent_two_levels_8_spaces.txt +0 -0
  133. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/keyword_args_section.txt +0 -0
  134. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/line_length_2.txt +0 -0
  135. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/literal_block_backticks_are_preserved.txt +0 -0
  136. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/literal_block_blank_lines_backticks_are_preserved.txt +0 -0
  137. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/mismatched_underlines.txt +0 -0
  138. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/mismatched_underlines_one_dash.txt +0 -0
  139. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/mismatched_underlines_two_dashes.txt +0 -0
  140. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/module_docstring_indent_zero_is_not_inferred.txt +0 -0
  141. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/module_level_docstring.txt +0 -0
  142. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/new_lines_before_and_after.txt +0 -0
  143. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/no_format_docstring_comment.txt +0 -0
  144. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/no_terminal_whitespace_only_line.txt +0 -0
  145. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/non_ascii_docstrings.txt +0 -0
  146. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/non_ascii_single_line_length_boundary.txt +0 -0
  147. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/param_signature_without_type.txt +0 -0
  148. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/parameters_returns_raises_wrapping.txt +0 -0
  149. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/plain_examples_code_is_preserved.txt +0 -0
  150. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/rST_cross_reference.txt +0 -0
  151. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/returns_bare_type_with_description_sync.txt +0 -0
  152. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/returns_colon_description_sync.txt +0 -0
  153. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/returns_description_without_type_sync.txt +0 -0
  154. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/returns_signature_and_description.txt +0 -0
  155. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/returns_yields_type_like_description_sync.txt +0 -0
  156. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/rst_code_block_backticks_are_preserved.txt +0 -0
  157. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/section_headings_with_colons.txt +0 -0
  158. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/section_title_fixed.txt +0 -0
  159. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/sections_notes_examples.txt +0 -0
  160. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/signature_dont_sync_raises.txt +0 -0
  161. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/signature_line_is_not_wrapped.txt +0 -0
  162. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/signature_sync_class_docstrings.txt +0 -0
  163. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/signature_sync_parameters.txt +0 -0
  164. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/signature_sync_returns.txt +0 -0
  165. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/signature_sync_yields.txt +0 -0
  166. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/single_line_backtick_expansion_respects_line_length.txt +0 -0
  167. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/single_line_docstring.txt +0 -0
  168. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/texts_are_rewrapped.txt +0 -0
  169. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/tilde_code_fence_is_preserved.txt +0 -0
  170. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/variadic_signature_without_colon.txt +0 -0
  171. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/very_long_unbreakable_word.txt +0 -0
  172. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/end_to_end/numpy/yields_iterator_item_type_sync.txt +0 -0
  173. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/integration_test/google/before.ipynb +0 -0
  174. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/integration_test/google/before.py +0 -0
  175. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/integration_test/numpy/after.ipynb +0 -0
  176. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/integration_test/numpy/after.py +0 -0
  177. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/integration_test/numpy/after_50.ipynb +0 -0
  178. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/integration_test/numpy/after_50.py +0 -0
  179. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/integration_test/numpy/before.ipynb +0 -0
  180. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/integration_test/numpy/before.py +0 -0
  181. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/jupyter/before.ipynb +0 -0
  182. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/jupyter/verbose_before.ipynb +0 -0
  183. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/README.md +0 -0
  184. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/arg_description_starts_with_bulleted_list.txt +0 -0
  185. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/arg_description_starts_with_table.txt +0 -0
  186. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/colon_spacing_fix.txt +0 -0
  187. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/contents_that_are_not_wrapped.txt +0 -0
  188. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/custom_section_after_args.txt +0 -0
  189. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/custom_section_after_doctest.txt +0 -0
  190. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/custom_section_before_args.txt +0 -0
  191. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/default_value_standardization.txt +0 -0
  192. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/doctest_output_backticks_are_preserved.txt +0 -0
  193. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/doctest_output_lines_are_preserved.txt +0 -0
  194. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/doctest_output_section_headers_are_preserved.txt +0 -0
  195. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/doctest_plain_output_is_preserved.txt +0 -0
  196. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/examples_leading_comment_is_preserved.txt +0 -0
  197. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/examples_plain_code_after_doctest.txt +0 -0
  198. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/examples_plain_output_after_code_is_preserved.txt +0 -0
  199. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/examples_section.txt +0 -0
  200. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/existing_linebreaks_should_not_be_respected.txt +0 -0
  201. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/fenced_code_backticks_are_preserved.txt +0 -0
  202. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/indent_four_levels_16_spaces_width_10.txt +0 -0
  203. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/indent_two_levels_8_spaces.txt +0 -0
  204. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/label_like_prose_in_notes.txt +0 -0
  205. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/line_length_2.txt +0 -0
  206. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/literal_block_backticks_are_preserved.txt +0 -0
  207. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/literal_block_blank_lines_backticks_are_preserved.txt +0 -0
  208. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/literal_block_marker_double_colon_preserved.txt +0 -0
  209. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/module_level_docstring.txt +0 -0
  210. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/no_terminal_whitespace_only_line.txt +0 -0
  211. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/non_ascii_docstrings.txt +0 -0
  212. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/param_signature_without_type.txt +0 -0
  213. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/parameters_returns_raises_wrapping.txt +0 -0
  214. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/plain_examples_code_is_preserved.txt +0 -0
  215. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/returns_signature_and_description.txt +0 -0
  216. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/rst_code_block_backticks_are_preserved.txt +0 -0
  217. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/section_headings_with_colons.txt +0 -0
  218. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/section_title_fixed.txt +0 -0
  219. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/sections_notes_examples.txt +0 -0
  220. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/signature_line_is_not_wrapped.txt +0 -0
  221. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/texts_are_rewrapped.txt +0 -0
  222. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/tilde_code_fence_is_preserved.txt +0 -0
  223. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/variadic_signature_without_colon.txt +0 -0
  224. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/google/very_long_unbreakable_word.txt +0 -0
  225. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/README.md +0 -0
  226. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/arg_description_starts_with_bulleted_list.txt +0 -0
  227. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/arg_description_starts_with_table.txt +0 -0
  228. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/colon_spacing_fix.txt +0 -0
  229. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/contents_that_are_not_wrapped.txt +0 -0
  230. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/custom_section_after_args.txt +0 -0
  231. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/custom_section_after_doctest.txt +0 -0
  232. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/custom_section_before_args.txt +0 -0
  233. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/default_value_standardization.txt +0 -0
  234. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/doctest_output_backticks_are_preserved.txt +0 -0
  235. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/doctest_output_lines_are_preserved.txt +0 -0
  236. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/doctest_output_section_headers_are_preserved.txt +0 -0
  237. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/doctest_plain_output_is_preserved.txt +0 -0
  238. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/empty_lines_are_respected.txt +0 -0
  239. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/examples_leading_comment_is_preserved.txt +0 -0
  240. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/examples_plain_code_after_doctest.txt +0 -0
  241. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/examples_plain_output_after_code_is_preserved.txt +0 -0
  242. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/examples_section.txt +0 -0
  243. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/existing_linebreaks_should_not_be_respected.txt +0 -0
  244. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/fenced_code_backticks_are_preserved.txt +0 -0
  245. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/indent_four_levels_16_spaces_width_10.txt +0 -0
  246. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/indent_two_levels_8_spaces.txt +0 -0
  247. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/label_like_prose_in_notes.txt +0 -0
  248. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/line_length_2.txt +0 -0
  249. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/literal_block_backticks_are_preserved.txt +0 -0
  250. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/literal_block_blank_lines_backticks_are_preserved.txt +0 -0
  251. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/literal_block_marker_double_colon_preserved.txt +0 -0
  252. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/mismatched_underlines.txt +0 -0
  253. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/mismatched_underlines_one_dash.txt +0 -0
  254. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/mismatched_underlines_two_dashes.txt +0 -0
  255. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/module_level_docstring.txt +0 -0
  256. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/no_terminal_whitespace_only_line.txt +0 -0
  257. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/non_ascii_docstrings.txt +0 -0
  258. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/param_signature_without_type.txt +0 -0
  259. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/parameters_returns_raises_wrapping.txt +0 -0
  260. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/plain_examples_code_is_preserved.txt +0 -0
  261. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/returns_signature_and_description.txt +0 -0
  262. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/rst_code_block_backticks_are_preserved.txt +0 -0
  263. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/section_headings_with_colons.txt +0 -0
  264. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/section_title_fixed.txt +0 -0
  265. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/sections_notes_examples.txt +0 -0
  266. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/signature_line_is_not_wrapped.txt +0 -0
  267. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/texts_are_rewrapped.txt +0 -0
  268. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/tilde_code_fence_is_preserved.txt +0 -0
  269. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/variadic_signature_without_colon.txt +0 -0
  270. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/line_wrap/numpy/very_long_unbreakable_word.txt +0 -0
  271. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_data/playground.py +0 -0
  272. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_line_wrap_numpy.py +0 -0
  273. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_main_jupyter.py +0 -0
  274. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_main_py.py +0 -0
  275. {format_docstring-0.4.0 → format_docstring-0.4.2}/tests/test_playground.py +0 -0
  276. {format_docstring-0.4.0 → format_docstring-0.4.2}/tox.ini +0 -0
@@ -46,6 +46,13 @@ oriented before making changes.
46
46
  mirroring tuple element splits when the docstring already enumerates them.
47
47
  - `Raises` section entries are treated like signature lines in the NumPy
48
48
  wrapper so exception names stay untouched while descriptions wrap.
49
+ - Every prose wrapper goes through
50
+ `line_wrap_utils.wrap_keeping_inline_literals`, which masks every whitespace
51
+ character inside rST inline literals (``` ``...`` ```) with a private-use
52
+ placeholder so each literal wraps as one unbreakable word; breaking inside
53
+ one would drop significant spaces. `_find_google_signature_colon` likewise
54
+ skips colons inside inline literals so a literal at the start of a prose line
55
+ is not mistaken for a signature.
49
56
  - Wrapping honors NumPy section heuristics, rST constructs, code fences,
50
57
  `Examples` prompts, and literal blocks introduced by `::`.
51
58
  - `_normalize_signature_segment` flattens multiline annotations via
@@ -6,6 +6,38 @@ The format is based on
6
6
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
7
7
  adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8
8
 
9
+ ## [0.4.2] - 2026-10-04
10
+
11
+ - Fixed
12
+ - Line wrapping no longer breaks inside rST inline literals
13
+ (``` ``...`` ```). Breaking there dropped the whitespace at the break, so a
14
+ literal such as ``` ``' '`` ``` lost its spaces. Each inline literal now
15
+ wraps as one unbreakable word, overflowing like other long words when it is
16
+ longer than the line. Re-running the formatter rejoins literals that
17
+ earlier versions split across lines. Tabs and other Unicode whitespace
18
+ inside a literal are preserved as well, instead of being expanded or
19
+ collapsed.
20
+ - Google-style compact first lines no longer collapse runs of spaces inside
21
+ inline literals.
22
+ - Google-style prose lines that start with an inline literal containing a
23
+ colon (such as ``` ``key:value`` ```) are no longer mistaken for signature
24
+ lines, which rewrote the literal's content on a second pass.
25
+ - Full diff
26
+ - https://github.com/jsh9/format-docstring/compare/0.4.1...0.4.2
27
+
28
+ ## [0.4.1] - 2026-06-30
29
+
30
+ - Fixed
31
+ - Google-style compact docstring wrapping now reserves the opening literal
32
+ width from the source, so plain triple-quoted summaries keep the correct
33
+ first-line budget while raw and Unicode prefixes still account for their
34
+ extra prefix column.
35
+ - One-character quoted docstring literals and adjacent string-token
36
+ docstrings are skipped as unsupported formatter targets, so long strings
37
+ are not wrapped into invalid multi-line source.
38
+ - Full diff
39
+ - https://github.com/jsh9/format-docstring/compare/0.4.0...0.4.1
40
+
9
41
  ## [0.4.0] - 2026-06-29
10
42
 
11
43
  - Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: format-docstring
3
- Version: 0.4.0
3
+ Version: 0.4.2
4
4
  Summary: A Python formatter to wrap/adjust docstring lines
5
5
  Author-email: jsh9 <25124332+jsh9@users.noreply.github.com>
6
6
  Maintainer-email: jsh9 <25124332+jsh9@users.noreply.github.com>
@@ -53,6 +53,7 @@ ______________________________________________________________________
53
53
  - [5.1. Command Line Interface](#51-command-line-interface)
54
54
  - [5.2. Pre-commit Hook](#52-pre-commit-hook)
55
55
  - [5.3. Opting Out of Formatting](#53-opting-out-of-formatting)
56
+ - [5.4. What Counts as a Docstring](#54-what-counts-as-a-docstring)
56
57
  - [6. Configuration](#6-configuration)
57
58
  - [6.1. Command-Line Options](#61-command-line-options)
58
59
  - [6.2. Usage Examples](#62-usage-examples)
@@ -327,6 +328,20 @@ records : list[dict[str, str]]
327
328
  """
328
329
  ```
329
330
 
331
+ **Inline literals are never split.** Each ``` ``...`` ``` span wraps as one
332
+ word, so spaces, tabs and other whitespace inside it are kept and the literal
333
+ stays greppable. A literal longer than the line overflows instead of breaking.
334
+
335
+ ```diff
336
+ """
337
+ Render a report as text.
338
+
339
+ -By default, all the nested lines in the generated report are indented with ``' '`` (two spaces) before they are written.
340
+ +By default, all the nested lines in the generated report are indented with
341
+ +``' '`` (two spaces) before they are written.
342
+ """
343
+ ```
344
+
330
345
  **Known sections are parsed, and custom sections are kept.** Recognized section
331
346
  titles such as `Parameters`, `Returns`, `Yields`, `Raises`, `Examples`, and
332
347
  `Notes` are canonicalized. Unknown underlined sections remain custom sections,
@@ -420,6 +435,20 @@ Args:
420
435
  """
421
436
  ```
422
437
 
438
+ **Inline literals are never split.** Each ``` ``...`` ``` span wraps as one
439
+ word, so spaces, tabs and other whitespace inside it are kept and the literal
440
+ stays greppable. A literal longer than the line overflows instead of breaking.
441
+
442
+ ```diff
443
+ """
444
+ Render a report as text.
445
+
446
+ -By default, all the nested lines in the generated report are indented with ``' '`` (two spaces) before they are written.
447
+ +By default, all the nested lines in the generated report are indented with
448
+ +``' '`` (two spaces) before they are written.
449
+ """
450
+ ```
451
+
423
452
  **Custom section boundaries are indentation-sensitive.** Known headers such as
424
453
  `Args:`, `Returns:`, `Raises:`, and `Examples:` are canonicalized. Unknown
425
454
  peer-level headers after summary content are treated as custom sections, so
@@ -562,6 +591,36 @@ first run `format-docstring`, accept the parts you like, revert the edits you
562
591
  dislike, and then add an inline `# no-format-docstring` comment so future runs
563
592
  leave that docstring untouched.
564
593
 
594
+ ### 5.4. What Counts as a Docstring
595
+
596
+ `format-docstring` follows [Python's docstring rule][python-docstring] to find
597
+ candidate docstrings: the first statement in a module, class, function, or
598
+ method must be a string literal. It intentionally formats only one
599
+ triple-quoted string token with a plain, raw, or Unicode prefix:
600
+
601
+ ```python
602
+ """Formatted."""
603
+ r"""Formatted."""
604
+ u"""Formatted."""
605
+ ```
606
+
607
+ Single-quoted and double-quoted one-character delimiters can be Python
608
+ docstrings, but they are outside formatter support and are left unchanged.
609
+ Adjacent or implicitly concatenated string literals, formatted string literals,
610
+ and bytes literals are also left unchanged:
611
+
612
+ ```python
613
+ 'Not formatted.'
614
+ "Not formatted."
615
+ """Not formatted.""" "Still not formatted."
616
+ f"""Not a docstring."""
617
+ rf"""Not a docstring."""
618
+ fr"""Not a docstring."""
619
+ b"""Not a docstring."""
620
+ rb"""Not a docstring."""
621
+ br"""Not a docstring."""
622
+ ```
623
+
565
624
  ## 6. Configuration
566
625
 
567
626
  ### 6.1. Command-Line Options
@@ -690,4 +749,5 @@ use AI coding assistants to rewrite the docstrings first.
690
749
  [black]: https://github.com/psf/black
691
750
  [docformatter]: https://github.com/PyCQA/docformatter
692
751
  [pydocstringformatter]: https://github.com/DanielNoord/pydocstringformatter
752
+ [python-docstring]: https://docs.python.org/3/glossary.html#term-docstring
693
753
  [ruff]: https://github.com/astral-sh/ruff
@@ -21,6 +21,7 @@ ______________________________________________________________________
21
21
  - [5.1. Command Line Interface](#51-command-line-interface)
22
22
  - [5.2. Pre-commit Hook](#52-pre-commit-hook)
23
23
  - [5.3. Opting Out of Formatting](#53-opting-out-of-formatting)
24
+ - [5.4. What Counts as a Docstring](#54-what-counts-as-a-docstring)
24
25
  - [6. Configuration](#6-configuration)
25
26
  - [6.1. Command-Line Options](#61-command-line-options)
26
27
  - [6.2. Usage Examples](#62-usage-examples)
@@ -295,6 +296,20 @@ records : list[dict[str, str]]
295
296
  """
296
297
  ```
297
298
 
299
+ **Inline literals are never split.** Each ``` ``...`` ``` span wraps as one
300
+ word, so spaces, tabs and other whitespace inside it are kept and the literal
301
+ stays greppable. A literal longer than the line overflows instead of breaking.
302
+
303
+ ```diff
304
+ """
305
+ Render a report as text.
306
+
307
+ -By default, all the nested lines in the generated report are indented with ``' '`` (two spaces) before they are written.
308
+ +By default, all the nested lines in the generated report are indented with
309
+ +``' '`` (two spaces) before they are written.
310
+ """
311
+ ```
312
+
298
313
  **Known sections are parsed, and custom sections are kept.** Recognized section
299
314
  titles such as `Parameters`, `Returns`, `Yields`, `Raises`, `Examples`, and
300
315
  `Notes` are canonicalized. Unknown underlined sections remain custom sections,
@@ -388,6 +403,20 @@ Args:
388
403
  """
389
404
  ```
390
405
 
406
+ **Inline literals are never split.** Each ``` ``...`` ``` span wraps as one
407
+ word, so spaces, tabs and other whitespace inside it are kept and the literal
408
+ stays greppable. A literal longer than the line overflows instead of breaking.
409
+
410
+ ```diff
411
+ """
412
+ Render a report as text.
413
+
414
+ -By default, all the nested lines in the generated report are indented with ``' '`` (two spaces) before they are written.
415
+ +By default, all the nested lines in the generated report are indented with
416
+ +``' '`` (two spaces) before they are written.
417
+ """
418
+ ```
419
+
391
420
  **Custom section boundaries are indentation-sensitive.** Known headers such as
392
421
  `Args:`, `Returns:`, `Raises:`, and `Examples:` are canonicalized. Unknown
393
422
  peer-level headers after summary content are treated as custom sections, so
@@ -530,6 +559,36 @@ first run `format-docstring`, accept the parts you like, revert the edits you
530
559
  dislike, and then add an inline `# no-format-docstring` comment so future runs
531
560
  leave that docstring untouched.
532
561
 
562
+ ### 5.4. What Counts as a Docstring
563
+
564
+ `format-docstring` follows [Python's docstring rule][python-docstring] to find
565
+ candidate docstrings: the first statement in a module, class, function, or
566
+ method must be a string literal. It intentionally formats only one
567
+ triple-quoted string token with a plain, raw, or Unicode prefix:
568
+
569
+ ```python
570
+ """Formatted."""
571
+ r"""Formatted."""
572
+ u"""Formatted."""
573
+ ```
574
+
575
+ Single-quoted and double-quoted one-character delimiters can be Python
576
+ docstrings, but they are outside formatter support and are left unchanged.
577
+ Adjacent or implicitly concatenated string literals, formatted string literals,
578
+ and bytes literals are also left unchanged:
579
+
580
+ ```python
581
+ 'Not formatted.'
582
+ "Not formatted."
583
+ """Not formatted.""" "Still not formatted."
584
+ f"""Not a docstring."""
585
+ rf"""Not a docstring."""
586
+ fr"""Not a docstring."""
587
+ b"""Not a docstring."""
588
+ rb"""Not a docstring."""
589
+ br"""Not a docstring."""
590
+ ```
591
+
533
592
  ## 6. Configuration
534
593
 
535
594
  ### 6.1. Command-Line Options
@@ -658,4 +717,5 @@ use AI coding assistants to rewrite the docstrings first.
658
717
  [black]: https://github.com/psf/black
659
718
  [docformatter]: https://github.com/PyCQA/docformatter
660
719
  [pydocstringformatter]: https://github.com/DanielNoord/pydocstringformatter
720
+ [python-docstring]: https://docs.python.org/3/glossary.html#term-docstring
661
721
  [ruff]: https://github.com/astral-sh/ruff
@@ -7,7 +7,10 @@ import textwrap
7
7
  import tokenize
8
8
  from typing import TYPE_CHECKING, cast
9
9
 
10
- from format_docstring.line_wrap_google import wrap_docstring_google
10
+ from format_docstring.line_wrap_google import (
11
+ GOOGLE_DEFAULT_OPENING_WIDTH,
12
+ wrap_docstring_google,
13
+ )
11
14
  from format_docstring.line_wrap_numpy import (
12
15
  handle_single_line_docstring,
13
16
  wrap_docstring_numpy,
@@ -503,6 +506,13 @@ def build_replacement_docstring(
503
506
  )
504
507
  original_literal = source_code[start:end]
505
508
 
509
+ # Python accepts one-character quote delimiters as docstrings, but this
510
+ # formatter rebuilds literals by preserving the original delimiter. Skip
511
+ # non-triple-quoted literals so wrapping cannot produce invalid multi-line
512
+ # single-quoted or double-quoted source.
513
+ if not _is_triple_quoted_literal(original_literal):
514
+ return None
515
+
506
516
  if _has_inline_no_format_comment(source_code, end):
507
517
  return None
508
518
 
@@ -556,6 +566,10 @@ def build_replacement_docstring(
556
566
  if class_attr_metadata:
557
567
  attribute_metadata = class_attr_metadata
558
568
 
569
+ # Whole-source rewrites know the original source opener. Pass that width
570
+ # through so compact Google summaries charge raw/unicode prefixes one
571
+ # extra column while direct wrapper calls keep the bare triple-quote
572
+ # default.
559
573
  wrapped: str = wrap_docstring(
560
574
  doc,
561
575
  line_length=line_length,
@@ -570,6 +584,7 @@ def build_replacement_docstring(
570
584
  include_return_and_yield_types=include_return_and_yield_types,
571
585
  compact_google_docstring=True,
572
586
  append_google_closing_indent=True,
587
+ google_opening_width=_literal_opening_width(original_literal),
573
588
  )
574
589
 
575
590
  new_literal: str | None = rebuild_literal(original_literal, wrapped)
@@ -613,6 +628,9 @@ def find_docstring(node: ModuleClassOrFunc) -> ast.Expr | None:
613
628
  return None
614
629
 
615
630
  val = first.value
631
+ # AST rewrites only handle string-valued docstrings. F-strings parse as
632
+ # ``ast.JoinedStr`` and bytes literals as ``ast.Constant[bytes]``, so they
633
+ # stay untouched instead of being rebuilt as text.
616
634
  if isinstance(val, ast.Constant) and isinstance(val.value, str):
617
635
  return first
618
636
 
@@ -712,6 +730,63 @@ def rebuild_literal(original_literal: str, content: str) -> str | None:
712
730
  return f'{prefix}{delim}{content}{delim}'
713
731
 
714
732
 
733
+ def _is_triple_quoted_literal(original_literal: str) -> bool:
734
+ """
735
+ Return True if the source slice is one triple-quoted string token.
736
+
737
+ This checks the formatter's supported source shape, not Python's broader
738
+ docstring definition. Adjacent string tokens can still become one AST
739
+ docstring value, but rebuilding them as one preserved-delimiter literal can
740
+ expose delimiter text that was safe only while split across tokens.
741
+ """
742
+ try:
743
+ string_tokens = [
744
+ tok.string
745
+ for tok in tokenize.generate_tokens(
746
+ io.StringIO(original_literal).readline
747
+ )
748
+ if tok.type == tokenize.STRING
749
+ ]
750
+ except tokenize.TokenError:
751
+ return False
752
+
753
+ if len(string_tokens) != 1:
754
+ return False
755
+
756
+ literal = string_tokens[0]
757
+ i = 0
758
+ n = len(literal)
759
+ while i < n and literal[i] in 'rRuUbBfF':
760
+ i += 1
761
+
762
+ return literal[i : i + 3] in {'"""', "'''"}
763
+
764
+
765
+ def _literal_opening_width(original_literal: str) -> int:
766
+ """
767
+ Return the source opener width before the first content character.
768
+
769
+ Compact Google rewrites keep the first summary beside the opener, so pass
770
+ two must reserve the exact prefix plus quote delimiter columns from the
771
+ source slice. This helper is intentionally syntactic: it can measure
772
+ prefixes such as ``rf``/``rb`` even though docstring detection still
773
+ decides whether such literals are format targets. If parsing fails, use the
774
+ bare triple-quote default for direct-wrapper-style fallbacks.
775
+ """
776
+ i = 0
777
+ n = len(original_literal)
778
+ while i < n and original_literal[i] in 'rRuUbBfF':
779
+ i += 1
780
+
781
+ if original_literal[i : i + 3] in {'"""', "'''"}:
782
+ return i + 3
783
+
784
+ if i < n and original_literal[i] in {'"', "'"}:
785
+ return i + 1
786
+
787
+ return GOOGLE_DEFAULT_OPENING_WIDTH
788
+
789
+
715
790
  def wrap_docstring(
716
791
  docstring: str,
717
792
  line_length: int = 79,
@@ -727,6 +802,7 @@ def wrap_docstring(
727
802
  include_return_and_yield_types: bool = True,
728
803
  compact_google_docstring: bool = False,
729
804
  append_google_closing_indent: bool = False,
805
+ google_opening_width: int = GOOGLE_DEFAULT_OPENING_WIDTH,
730
806
  ) -> str:
731
807
  """
732
808
  Wrap a docstring to the given line length (stub).
@@ -768,6 +844,11 @@ def wrap_docstring(
768
844
  append_google_closing_indent : bool, default=False
769
845
  If True, Google-style wrapping appends the indentation needed before
770
846
  closing quotes in rebuilt docstring literals.
847
+ google_opening_width : int, default=GOOGLE_DEFAULT_OPENING_WIDTH
848
+ Visible width of the opening literal prefix plus quote delimiter for
849
+ compact Google docstrings. Whole-source rewrites pass the value
850
+ measured from the source literal; direct wrapper calls use the bare
851
+ triple-quote default because no literal prefix is available.
771
852
 
772
853
  Returns
773
854
  -------
@@ -817,6 +898,7 @@ def wrap_docstring(
817
898
  include_arg_defaults=include_arg_defaults,
818
899
  include_return_and_yield_types=include_return_and_yield_types,
819
900
  compact_first_line=compact_google_docstring,
901
+ opening_width=google_opening_width,
820
902
  )
821
903
  # Default to NumPy-style for unknown/unspecified styles to be permissive.
822
904
  return wrap_docstring_numpy(
@@ -15,9 +15,12 @@ from format_docstring.line_wrap_utils import (
15
15
  is_code_fence,
16
16
  is_google_doctest_block,
17
17
  is_google_examples_code_block,
18
+ is_inside_inline_literal,
18
19
  merge_lines_and_strip,
20
+ protect_inline_literal_spaces,
19
21
  segment_lines_by_wrappability,
20
22
  validate_include_arg_defaults,
23
+ wrap_keeping_inline_literals,
21
24
  )
22
25
  from format_docstring.section_utils import (
23
26
  canonical_google_section_header,
@@ -30,10 +33,10 @@ from format_docstring.section_utils import (
30
33
  is_google_yields_section_header,
31
34
  )
32
35
 
33
- # Google docstrings can preserve string prefixes such as ``rf`` when rebuilt,
34
- # so first-line wrapping reserves two prefix characters plus opening quotes.
35
- GOOGLE_OPENING_QUOTES_WIDTH: Final[int] = 5
36
- GOOGLE_COMPACT_OPENING_QUOTES_WIDTH: Final[int] = 5
36
+ # Direct wrapper calls receive docstring content without source quotes, so use
37
+ # the bare triple-quote width. AST rewrites override this with the measured
38
+ # source-literal opener to keep compact first-line budgets exact.
39
+ GOOGLE_DEFAULT_OPENING_WIDTH: Final[int] = 3
37
40
  GOOGLE_MIN_SIGNATURE_DESC_WIDTH: Final[int] = 10
38
41
  GOOGLE_SIGNATURE_MAX_TOKENS: Final[int] = 2
39
42
 
@@ -101,7 +104,7 @@ class _GoogleWrapState:
101
104
  output: list[str]
102
105
  leading_indent: int
103
106
  line_length: int
104
- compact_first_line: bool
107
+ opening_width: int
105
108
  opening_quotes_on_own_line: bool
106
109
  include_return_and_yield_types: bool
107
110
  is_first_line: bool = True
@@ -125,6 +128,7 @@ def wrap_docstring_google(
125
128
  include_arg_defaults: bool = True,
126
129
  include_return_and_yield_types: bool = True,
127
130
  compact_first_line: bool = False,
131
+ opening_width: int = GOOGLE_DEFAULT_OPENING_WIDTH,
128
132
  ) -> str:
129
133
  """
130
134
  Wrap Google-style docstrings.
@@ -133,6 +137,11 @@ def wrap_docstring_google(
133
137
  finally wraps them to the target line length. The backtick pass must run
134
138
  first because single backticks can expand to double backticks; doing that
135
139
  after wrapping can make the final output exceed ``line_length``.
140
+
141
+ ``opening_width`` affects first-line wrapping. AST rewrites pass the
142
+ measured source-literal opener so raw/unicode prefixes reduce the first
143
+ content budget; callers without source context keep the bare-triple-quote
144
+ default.
136
145
  """
137
146
  validate_include_arg_defaults(
138
147
  include_arg_types=include_arg_types,
@@ -170,8 +179,8 @@ def wrap_docstring_google(
170
179
  line_length=line_length,
171
180
  leading_indent=leading_indent,
172
181
  closing_indent=closing_indent,
173
- compact_first_line=should_compact_first_line,
174
182
  opening_quotes_on_own_line=opening_quotes_on_own_line,
183
+ opening_width=opening_width,
175
184
  include_return_and_yield_types=include_return_and_yield_types,
176
185
  )
177
186
 
@@ -1047,8 +1056,8 @@ def _pass2_wrap_google_docstring(
1047
1056
  line_length: int,
1048
1057
  leading_indent: int | None = None,
1049
1058
  closing_indent: int | None = None,
1050
- compact_first_line: bool = False,
1051
1059
  opening_quotes_on_own_line: bool = False,
1060
+ opening_width: int = GOOGLE_DEFAULT_OPENING_WIDTH,
1052
1061
  include_return_and_yield_types: bool = True,
1053
1062
  ) -> str:
1054
1063
  """
@@ -1062,7 +1071,7 @@ def _pass2_wrap_google_docstring(
1062
1071
  output=[],
1063
1072
  leading_indent=leading_indent or 0,
1064
1073
  line_length=line_length,
1065
- compact_first_line=compact_first_line,
1074
+ opening_width=opening_width,
1066
1075
  opening_quotes_on_own_line=opening_quotes_on_own_line,
1067
1076
  include_return_and_yield_types=include_return_and_yield_types,
1068
1077
  )
@@ -1213,14 +1222,21 @@ def _google_effective_signature_indent(
1213
1222
  state: _GoogleWrapState,
1214
1223
  parts: _GoogleLineParts,
1215
1224
  ) -> int:
1216
- """Return indent used by pass-two signature context checks."""
1225
+ """
1226
+ Return first-line signature indent after accounting for opener width.
1227
+
1228
+ Compact first lines lose columns to the literal opener before content
1229
+ starts. Signature context checks need that effective indent so a first-line
1230
+ ``Args:`` item is classified the same way it would be on later physical
1231
+ lines.
1232
+ """
1217
1233
  if not state.is_first_line:
1218
1234
  return parts.indent_level
1219
1235
 
1220
1236
  if parts.indent_level < state.leading_indent:
1221
- return state.leading_indent + GOOGLE_OPENING_QUOTES_WIDTH
1237
+ return state.leading_indent + state.opening_width
1222
1238
 
1223
- return parts.indent_level + GOOGLE_OPENING_QUOTES_WIDTH
1239
+ return parts.indent_level + state.opening_width
1224
1240
 
1225
1241
 
1226
1242
  def _is_google_signature_line_in_context(
@@ -1286,15 +1302,16 @@ def _wrap_google_first_prose_line(
1286
1302
  state: _GoogleWrapState,
1287
1303
  parts: _GoogleLineParts,
1288
1304
  ) -> None:
1289
- """Wrap the first physical docstring line with opening-quote budget."""
1290
- opening_width = (
1291
- GOOGLE_COMPACT_OPENING_QUOTES_WIDTH
1292
- if state.compact_first_line
1293
- else GOOGLE_OPENING_QUOTES_WIDTH
1294
- )
1305
+ """
1306
+ Wrap the first physical docstring line with source-opener budget.
1307
+
1308
+ Compact Google output rebuilds the opener outside this content string, so
1309
+ the wrapper must reserve those columns before deciding whether the first
1310
+ summary fits.
1311
+ """
1295
1312
  first_line_width = max(
1296
1313
  1,
1297
- state.line_length - state.leading_indent - opening_width,
1314
+ state.line_length - state.leading_indent - state.opening_width,
1298
1315
  )
1299
1316
  state.output.extend(
1300
1317
  _wrap_first_line_shorter(
@@ -1319,15 +1336,19 @@ def _wrap_google_normal_prose_line(
1319
1336
  ):
1320
1337
  subsequent_indent = ' ' * state.leading_indent
1321
1338
 
1322
- wrapped = textwrap.fill(
1323
- parts.line.strip(),
1324
- width=state.line_length,
1325
- initial_indent=parts.indent_str,
1326
- subsequent_indent=subsequent_indent,
1327
- break_long_words=False,
1328
- break_on_hyphens=False,
1339
+ state.output.extend(
1340
+ wrap_keeping_inline_literals(
1341
+ parts.line.strip(),
1342
+ lambda text: textwrap.wrap(
1343
+ text,
1344
+ width=state.line_length,
1345
+ initial_indent=parts.indent_str,
1346
+ subsequent_indent=subsequent_indent,
1347
+ break_long_words=False,
1348
+ break_on_hyphens=False,
1349
+ ),
1350
+ )
1329
1351
  )
1330
- state.output.extend(wrapped.splitlines())
1331
1352
 
1332
1353
 
1333
1354
  def _wrap_google_signature_line(
@@ -1367,7 +1388,9 @@ def _wrap_google_signature_line(
1367
1388
 
1368
1389
  first_line_prefix = sig_part_stripped + ' '
1369
1390
  remaining_first = line_length - len(first_line_prefix)
1370
- first_word = desc_part.split()[0] if desc_part else ''
1391
+ # Measure the first unbreakable word: a leading inline literal containing
1392
+ # spaces must move to the continuation line as a whole when it can't fit.
1393
+ first_word = protect_inline_literal_spaces(desc_part).split()[0]
1371
1394
  if (
1372
1395
  remaining_first < GOOGLE_MIN_SIGNATURE_DESC_WIDTH
1373
1396
  or len(first_word) > remaining_first
@@ -1381,15 +1404,17 @@ def _wrap_google_signature_line(
1381
1404
  ),
1382
1405
  ]
1383
1406
 
1384
- wrapped = textwrap.fill(
1407
+ return wrap_keeping_inline_literals(
1385
1408
  desc_part,
1386
- width=line_length,
1387
- initial_indent=first_line_prefix,
1388
- subsequent_indent=subsequent_indent,
1389
- break_long_words=False,
1390
- break_on_hyphens=False,
1409
+ lambda text: textwrap.wrap(
1410
+ text,
1411
+ width=line_length,
1412
+ initial_indent=first_line_prefix,
1413
+ subsequent_indent=subsequent_indent,
1414
+ break_long_words=False,
1415
+ break_on_hyphens=False,
1416
+ ),
1391
1417
  )
1392
- return wrapped.splitlines()
1393
1418
 
1394
1419
 
1395
1420
  def _wrap_google_signature_description(
@@ -1399,15 +1424,17 @@ def _wrap_google_signature_description(
1399
1424
  subsequent_indent: str,
1400
1425
  ) -> list[str]:
1401
1426
  """Wrap a Google signature description on continuation lines."""
1402
- wrapped = textwrap.fill(
1427
+ return wrap_keeping_inline_literals(
1403
1428
  description,
1404
- width=line_length,
1405
- initial_indent=subsequent_indent,
1406
- subsequent_indent=subsequent_indent,
1407
- break_long_words=False,
1408
- break_on_hyphens=False,
1429
+ lambda text: textwrap.wrap(
1430
+ text,
1431
+ width=line_length,
1432
+ initial_indent=subsequent_indent,
1433
+ subsequent_indent=subsequent_indent,
1434
+ break_long_words=False,
1435
+ break_on_hyphens=False,
1436
+ ),
1409
1437
  )
1410
- return wrapped.splitlines()
1411
1438
 
1412
1439
 
1413
1440
  def _wrap_first_line_shorter(
@@ -1437,6 +1464,32 @@ def _wrap_first_line_shorter(
1437
1464
  if not text.strip():
1438
1465
  return [initial_indent + text] if text else []
1439
1466
 
1467
+ return wrap_keeping_inline_literals(
1468
+ text,
1469
+ lambda masked_text: _wrap_words_first_line_shorter(
1470
+ masked_text,
1471
+ first_line_width=first_line_width,
1472
+ subsequent_width=subsequent_width,
1473
+ initial_indent=initial_indent,
1474
+ subsequent_indent=subsequent_indent,
1475
+ ),
1476
+ )
1477
+
1478
+
1479
+ def _wrap_words_first_line_shorter(
1480
+ text: str,
1481
+ *,
1482
+ first_line_width: int,
1483
+ subsequent_width: int,
1484
+ initial_indent: str,
1485
+ subsequent_indent: str,
1486
+ ) -> list[str]:
1487
+ """
1488
+ Greedily fill whitespace-separated words for ``_wrap_first_line_shorter``.
1489
+
1490
+ Splitting on whitespace re-joins words with single spaces, so callers must
1491
+ mask whitespace that is significant (e.g. inside inline literals) first.
1492
+ """
1440
1493
  words = text.split()
1441
1494
  if not words:
1442
1495
  return []
@@ -1898,12 +1951,15 @@ def _rewrite_google_return_signature(line: str, annotation: str) -> str:
1898
1951
 
1899
1952
  def _find_google_signature_colon(line: str) -> int:
1900
1953
  """
1901
- Return the delimiter colon outside brackets and parentheses.
1954
+ Return the delimiter colon outside brackets, parentheses and literals.
1902
1955
 
1903
1956
  Google signatures use that colon to separate the signature from the
1904
1957
  description. Skipping nested colons prevents rare type expressions from
1905
1958
  being split in the middle before signature spacing is normalized for
1906
- malformed Google signature fixtures.
1959
+ malformed Google signature fixtures. Colons inside rST inline literals
1960
+ (``` ``key:value`` ```) are skipped too: a prose line that starts with such
1961
+ a literal is not a signature, and treating it as one would rewrite the
1962
+ literal's content.
1907
1963
  """
1908
1964
  nesting = 0
1909
1965
  for idx, char in enumerate(line):
@@ -1911,7 +1967,11 @@ def _find_google_signature_colon(line: str) -> int:
1911
1967
  nesting += 1
1912
1968
  elif char in ')]}':
1913
1969
  nesting -= 1
1914
- elif char == ':' and nesting == 0:
1970
+ elif (
1971
+ char == ':'
1972
+ and nesting == 0
1973
+ and not is_inside_inline_literal(line, idx)
1974
+ ):
1915
1975
  return idx
1916
1976
 
1917
1977
  return -1