format-docstring 0.2.6__tar.gz → 0.3.0__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.
- {format_docstring-0.2.6 → format_docstring-0.3.0}/.gitignore +2 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/CHANGELOG.md +31 -0
- format_docstring-0.3.0/PKG-INFO +671 -0
- format_docstring-0.3.0/README.md +639 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/format_docstring/config.py +115 -5
- {format_docstring-0.2.6 → format_docstring-0.3.0}/format_docstring/docstring_rewriter.py +138 -19
- format_docstring-0.3.0/format_docstring/line_wrap_google.py +2060 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/format_docstring/line_wrap_numpy.py +287 -66
- {format_docstring-0.2.6 → format_docstring-0.3.0}/format_docstring/line_wrap_utils.py +565 -14
- {format_docstring-0.2.6 → format_docstring-0.3.0}/format_docstring/main_jupyter.py +6 -9
- {format_docstring-0.2.6 → format_docstring-0.3.0}/format_docstring/main_py.py +8 -12
- format_docstring-0.3.0/format_docstring/section_utils.py +177 -0
- format_docstring-0.3.0/format_docstring.egg-info/PKG-INFO +671 -0
- format_docstring-0.3.0/format_docstring.egg-info/SOURCES.txt +262 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/pyproject.toml +7 -11
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/helpers.py +1 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_config.py +4 -3
- format_docstring-0.3.0/tests/test_data/end_to_end/google/README.md +10 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/arg_name_is_default.txt +37 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/class_attribute_type_comment_defaults.txt +34 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/colon_spacing_fix.txt +52 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/contents_that_are_not_wrapped.txt +99 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/custom_section_after_args.txt +27 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/custom_section_after_doctest.txt +25 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/custom_section_before_args.txt +26 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/default_value_standardization.txt +75 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/doctest_output_lines_are_preserved.txt +26 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/empty_lines_are_respected.txt +79 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/examples_plain_code_after_doctest.txt +25 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/examples_section.txt +93 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/existing_linebreaks_should_not_be_respected.txt +26 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/fix_rst_backticks.txt +152 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/four_level_nested_classes.txt +95 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/indent_four_levels_16_spaces_width_10.txt +55 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/indent_misaligned_all.txt +68 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/indent_two_levels_8_spaces.txt +20 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/keyword_args_section.txt +22 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/line_length_2.txt +56 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/literal_block_backticks_are_preserved.txt +18 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/literal_block_blank_lines_backticks_are_preserved.txt +26 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/module_docstring_indent_zero_is_not_inferred.txt +14 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/module_level_docstring.txt +18 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/new_lines_before_and_after.txt +142 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/no_format_docstring_comment.txt +52 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/no_terminal_whitespace_only_line.txt +19 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/non_ascii_docstrings.txt +89 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/non_ascii_single_line_length_boundary.txt +11 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/param_signature_without_type.txt +29 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/parameters_returns_raises_wrapping.txt +58 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/plain_examples_code_is_preserved.txt +24 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/rST_cross_reference.txt +77 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/returns_bare_type_with_description_sync.txt +22 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/returns_colon_description_sync.txt +62 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/returns_description_without_type_sync.txt +20 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/returns_signature_and_description.txt +22 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/returns_yields_type_like_description_sync.txt +45 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/rst_code_block_backticks_are_preserved.txt +27 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/section_headings_with_colons.txt +48 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/section_title_fixed.txt +48 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/sections_notes_examples.txt +64 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/signature_dont_sync_raises.txt +38 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/signature_line_is_not_wrapped.txt +22 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/signature_sync_class_docstrings.txt +168 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/signature_sync_parameters.txt +204 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/signature_sync_returns.txt +170 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/signature_sync_yields.txt +126 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/single_line_backtick_expansion_respects_line_length.txt +13 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/single_line_docstring.txt +76 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/texts_are_rewrapped.txt +126 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/tilde_code_fence_is_preserved.txt +28 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/variadic_signature_without_colon.txt +50 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/very_long_unbreakable_word.txt +19 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/google/yields_iterator_item_type_sync.txt +30 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/README.md +9 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/class_attribute_type_comment_defaults.txt +43 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/custom_section_after_args.txt +34 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/custom_section_after_doctest.txt +31 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/custom_section_before_args.txt +33 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/doctest_output_lines_are_preserved.txt +29 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/examples_plain_code_after_doctest.txt +27 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/keyword_args_section.txt +29 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/literal_block_backticks_are_preserved.txt +19 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/literal_block_blank_lines_backticks_are_preserved.txt +27 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/module_docstring_indent_zero_is_not_inferred.txt +14 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/no_terminal_whitespace_only_line.txt +21 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/non_ascii_docstrings.txt +89 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/non_ascii_single_line_length_boundary.txt +11 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/plain_examples_code_is_preserved.txt +27 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/returns_bare_type_with_description_sync.txt +26 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/returns_colon_description_sync.txt +28 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/returns_description_without_type_sync.txt +24 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/returns_yields_type_like_description_sync.txt +53 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/rst_code_block_backticks_are_preserved.txt +27 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/sections_notes_examples.txt +1 -2
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/signature_sync_class_docstrings.txt +5 -1
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/signature_sync_yields.txt +5 -3
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/single_line_backtick_expansion_respects_line_length.txt +13 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/tilde_code_fence_is_preserved.txt +35 -0
- format_docstring-0.3.0/tests/test_data/end_to_end/numpy/yields_iterator_item_type_sync.txt +35 -0
- format_docstring-0.3.0/tests/test_data/integration_test/google/after.ipynb +91 -0
- format_docstring-0.3.0/tests/test_data/integration_test/google/after.py +34 -0
- format_docstring-0.3.0/tests/test_data/integration_test/google/after_50.ipynb +99 -0
- format_docstring-0.3.0/tests/test_data/integration_test/google/after_50.py +42 -0
- format_docstring-0.3.0/tests/test_data/integration_test/google/before.ipynb +78 -0
- format_docstring-0.3.0/tests/test_data/integration_test/numpy/before.py +24 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/README.md +24 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/arg_description_starts_with_bulleted_list.txt +14 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/arg_description_starts_with_table.txt +20 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/colon_spacing_fix.txt +21 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/contents_that_are_not_wrapped.txt +88 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/custom_section_after_args.txt +20 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/custom_section_after_doctest.txt +17 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/custom_section_before_args.txt +19 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/default_value_standardization.txt +26 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/doctest_output_backticks_are_preserved.txt +15 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/doctest_output_lines_are_preserved.txt +15 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/doctest_output_section_headers_are_preserved.txt +41 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/doctest_plain_output_is_preserved.txt +15 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/empty_lines_are_respected.txt +62 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/examples_leading_comment_is_preserved.txt +11 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/examples_plain_code_after_doctest.txt +17 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/examples_plain_output_after_code_is_preserved.txt +11 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/examples_section.txt +44 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/existing_linebreaks_should_not_be_respected.txt +19 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/fenced_code_backticks_are_preserved.txt +13 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/fix_rst_backticks.txt +83 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/indent_two_levels_8_spaces.txt +13 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/label_like_prose_in_notes.txt +11 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/literal_block_backticks_are_preserved.txt +11 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/literal_block_blank_lines_backticks_are_preserved.txt +19 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/literal_block_marker_double_colon_preserved.txt +11 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/module_level_docstring.txt +12 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/no_terminal_whitespace_only_line.txt +11 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/non_ascii_docstrings.txt +69 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/param_signature_without_type.txt +21 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/parameters_returns_raises_wrapping.txt +45 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/plain_examples_code_is_preserved.txt +14 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/returns_signature_and_description.txt +20 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/rst_code_block_backticks_are_preserved.txt +19 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/section_headings_with_colons.txt +40 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/section_title_fixed.txt +40 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/sections_notes_examples.txt +53 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/signature_line_is_not_wrapped.txt +14 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/texts_are_rewrapped.txt +113 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/tilde_code_fence_is_preserved.txt +17 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/variadic_signature_without_colon.txt +27 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/google/very_long_unbreakable_word.txt +11 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/README.md +19 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/arg_description_starts_with_bulleted_list.txt +16 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/arg_description_starts_with_table.txt +22 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/custom_section_after_args.txt +26 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/custom_section_after_doctest.txt +23 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/custom_section_before_args.txt +25 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/doctest_output_backticks_are_preserved.txt +17 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/doctest_output_lines_are_preserved.txt +17 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/doctest_output_section_headers_are_preserved.txt +31 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/doctest_plain_output_is_preserved.txt +17 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/examples_leading_comment_is_preserved.txt +13 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/examples_plain_code_after_doctest.txt +19 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/examples_plain_output_after_code_is_preserved.txt +13 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/fenced_code_backticks_are_preserved.txt +15 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/indent_four_levels_16_spaces_width_10.txt +46 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/label_like_prose_in_notes.txt +13 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/line_length_2.txt +49 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/literal_block_backticks_are_preserved.txt +11 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/literal_block_blank_lines_backticks_are_preserved.txt +19 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/literal_block_marker_double_colon_preserved.txt +11 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/no_terminal_whitespace_only_line.txt +11 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/non_ascii_docstrings.txt +89 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/plain_examples_code_is_preserved.txt +16 -0
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/rst_code_block_backticks_are_preserved.txt +19 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/sections_notes_examples.txt +1 -2
- format_docstring-0.3.0/tests/test_data/line_wrap/numpy/tilde_code_fence_is_preserved.txt +23 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_docstring_rewriter.py +57 -11
- format_docstring-0.3.0/tests/test_google_fixture_inventory.py +49 -0
- format_docstring-0.3.0/tests/test_line_wrap_google.py +222 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_line_wrap_numpy.py +77 -14
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_line_wrap_utils.py +593 -26
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_main_jupyter.py +27 -6
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_main_py.py +30 -7
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_playground.py +2 -2
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tox.ini +8 -8
- format_docstring-0.2.6/PKG-INFO +0 -494
- format_docstring-0.2.6/README.md +0 -462
- format_docstring-0.2.6/format_docstring/line_wrap_google.py +0 -15
- format_docstring-0.2.6/format_docstring.egg-info/PKG-INFO +0 -494
- format_docstring-0.2.6/format_docstring.egg-info/SOURCES.txt +0 -110
- format_docstring-0.2.6/tests/test_data/end_to_end/numpy/README.md +0 -2
- format_docstring-0.2.6/tests/test_data/line_wrap/numpy/README.md +0 -1
- format_docstring-0.2.6/tests/test_line_wrap_google.py +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/.github/workflows/python-package.yml +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/.github/workflows/python-publish.yml +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/.pre-commit-config.yaml +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/.pre-commit-hooks.yaml +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/AGENTS.md +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/LICENSE +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/format_docstring/__init__.py +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/format_docstring/base_fixer.py +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/format_docstring.egg-info/dependency_links.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/format_docstring.egg-info/entry_points.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/format_docstring.egg-info/requires.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/format_docstring.egg-info/top_level.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/muff.toml +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/requirements.dev +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/setup.cfg +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/__init__.py +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_base_fixer.py +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/arg_name_is_default.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/colon_spacing_fix.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/contents_that_are_not_wrapped.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/default_value_standardization.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/empty_lines_are_respected.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/examples_section.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/existing_linebreaks_should_not_be_respected.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/fix_rst_backticks.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/four_level_nested_classes.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/indent_four_levels_16_spaces_width_10.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/indent_misaligned_all.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/indent_two_levels_8_spaces.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/line_length_2.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/mismatched_underlines.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/mismatched_underlines_one_dash.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/mismatched_underlines_two_dashes.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/module_level_docstring.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/new_lines_before_and_after.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/no_format_docstring_comment.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/param_signature_without_type.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/parameters_returns_raises_wrapping.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/rST_cross_reference.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/returns_signature_and_description.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/section_headings_with_colons.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/section_title_fixed.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/signature_dont_sync_raises.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/signature_line_is_not_wrapped.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/signature_sync_parameters.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/signature_sync_returns.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/single_line_docstring.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/texts_are_rewrapped.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/variadic_signature_without_colon.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/end_to_end/numpy/very_long_unbreakable_word.txt +0 -0
- {format_docstring-0.2.6/tests/test_data/integration_test/numpy → format_docstring-0.3.0/tests/test_data/integration_test/google}/before.py +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/integration_test/numpy/after.ipynb +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/integration_test/numpy/after.py +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/integration_test/numpy/after_50.ipynb +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/integration_test/numpy/after_50.py +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/integration_test/numpy/before.ipynb +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/jupyter/before.ipynb +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/jupyter/verbose_before.ipynb +0 -0
- {format_docstring-0.2.6/tests/test_data/line_wrap/numpy → format_docstring-0.3.0/tests/test_data/line_wrap/google}/indent_four_levels_16_spaces_width_10.txt +0 -0
- {format_docstring-0.2.6/tests/test_data/line_wrap/numpy → format_docstring-0.3.0/tests/test_data/line_wrap/google}/line_length_2.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/colon_spacing_fix.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/contents_that_are_not_wrapped.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/default_value_standardization.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/empty_lines_are_respected.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/examples_section.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/existing_linebreaks_should_not_be_respected.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/fix_rst_backticks.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/indent_two_levels_8_spaces.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/mismatched_underlines.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/mismatched_underlines_one_dash.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/mismatched_underlines_two_dashes.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/module_level_docstring.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/param_signature_without_type.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/parameters_returns_raises_wrapping.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/returns_signature_and_description.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/section_headings_with_colons.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/section_title_fixed.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/signature_line_is_not_wrapped.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/texts_are_rewrapped.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/variadic_signature_without_colon.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/line_wrap/numpy/very_long_unbreakable_word.txt +0 -0
- {format_docstring-0.2.6 → format_docstring-0.3.0}/tests/test_data/playground.py +0 -0
|
@@ -6,6 +6,37 @@ 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.3.0] - 2026-06-19
|
|
10
|
+
|
|
11
|
+
- Added
|
|
12
|
+
- Google-style docstring formatting for Python files and Jupyter notebooks
|
|
13
|
+
via `--docstring-style google` or `docstring_style = "google"` under
|
|
14
|
+
`[tool.format_docstring]`
|
|
15
|
+
- Google `Args:`, `Attributes:`, `Returns:`, and `Yields:` signature
|
|
16
|
+
synchronization from source annotations, defaults, class attributes, and
|
|
17
|
+
generator yield annotations
|
|
18
|
+
- Fixture coverage for Google line wrapping, end-to-end rewrites, notebook
|
|
19
|
+
rewrites, protected blocks, custom sections, and signature synchronization
|
|
20
|
+
- Changed
|
|
21
|
+
- Shared section and protected-block parsing so NumPy and Google formatting
|
|
22
|
+
preserve doctests, Python example code, fenced code, rST code blocks,
|
|
23
|
+
literal blocks, tables, and bullet lists more consistently
|
|
24
|
+
- README examples and configuration docs now describe NumPy and Google
|
|
25
|
+
behavior separately
|
|
26
|
+
- Development type checking now uses `ty` instead of `mypy`
|
|
27
|
+
- Fixed
|
|
28
|
+
- CLI config discovery now applies `pyproject.toml` settings found by walking
|
|
29
|
+
up from the target file or directory
|
|
30
|
+
- Full diff
|
|
31
|
+
- https://github.com/jsh9/format-docstring/compare/0.2.7...0.3.0
|
|
32
|
+
|
|
33
|
+
## [0.2.7] - 2025-12-04
|
|
34
|
+
|
|
35
|
+
- Fixed
|
|
36
|
+
- Bug where non-ASCII characters would mess up auto formatting
|
|
37
|
+
- Full diff
|
|
38
|
+
- https://github.com/jsh9/format-docstring/compare/0.2.6...0.2.7
|
|
39
|
+
|
|
9
40
|
## [0.2.6] - 2025-11-21
|
|
10
41
|
|
|
11
42
|
- Fixed
|
|
@@ -0,0 +1,671 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: format-docstring
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: A Python formatter to wrap/adjust docstring lines
|
|
5
|
+
Author-email: jsh9 <25124332+jsh9@users.noreply.github.com>
|
|
6
|
+
Maintainer-email: jsh9 <25124332+jsh9@users.noreply.github.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/jsh9/format-docstring
|
|
9
|
+
Project-URL: Issues, https://github.com/jsh9/format-docstring/issues
|
|
10
|
+
Project-URL: Repository, https://github.com/jsh9/format-docstring.git
|
|
11
|
+
Keywords: code-style,docstring,formatter,python
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: click>=8.0
|
|
29
|
+
Requires-Dist: jupyter-notebook-parser>=0.1.4
|
|
30
|
+
Requires-Dist: tomli>=1.1.0; python_version < "3.11"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# format-docstring
|
|
34
|
+
|
|
35
|
+
A Python formatter to automatically format NumPy-style and Google-style
|
|
36
|
+
docstrings.
|
|
37
|
+
|
|
38
|
+
<!--TOC-->
|
|
39
|
+
|
|
40
|
+
______________________________________________________________________
|
|
41
|
+
|
|
42
|
+
**Table of Contents**
|
|
43
|
+
|
|
44
|
+
- [1. Overview](#1-overview)
|
|
45
|
+
- [2. Before vs After Examples](#2-before-vs-after-examples)
|
|
46
|
+
- [2.1. NumPy-style docstrings](#21-numpy-style-docstrings)
|
|
47
|
+
- [2.2. Google-style docstrings](#22-google-style-docstrings)
|
|
48
|
+
- [3. Special Formatting Rules](#3-special-formatting-rules)
|
|
49
|
+
- [3.1. NumPy-style docstrings](#31-numpy-style-docstrings)
|
|
50
|
+
- [3.2. Google-style docstrings](#32-google-style-docstrings)
|
|
51
|
+
- [4. Installation](#4-installation)
|
|
52
|
+
- [5. Usage](#5-usage)
|
|
53
|
+
- [5.1. Command Line Interface](#51-command-line-interface)
|
|
54
|
+
- [5.2. Pre-commit Hook](#52-pre-commit-hook)
|
|
55
|
+
- [5.3. Opting Out of Formatting](#53-opting-out-of-formatting)
|
|
56
|
+
- [6. Configuration](#6-configuration)
|
|
57
|
+
- [6.1. Command-Line Options](#61-command-line-options)
|
|
58
|
+
- [6.2. Usage Examples](#62-usage-examples)
|
|
59
|
+
- [6.3. `pyproject.toml` Configuration](#63-pyprojecttoml-configuration)
|
|
60
|
+
- [7. Caveat](#7-caveat)
|
|
61
|
+
|
|
62
|
+
______________________________________________________________________
|
|
63
|
+
|
|
64
|
+
<!--TOC-->
|
|
65
|
+
|
|
66
|
+
## 1. Overview
|
|
67
|
+
|
|
68
|
+
`format-docstring` is a tool that automatically formats and wraps docstring
|
|
69
|
+
content in Python files and Jupyter notebooks.
|
|
70
|
+
|
|
71
|
+
Baseline reflow corresponds to the common docstring cleanups offered by
|
|
72
|
+
general-purpose formatters: splitting one-line docstrings into the canonical
|
|
73
|
+
multi-line layout (triple quotes, blank line, summary), normalizing
|
|
74
|
+
indentation, and wrapping text at a fixed column width without applying extra
|
|
75
|
+
heuristics.
|
|
76
|
+
|
|
77
|
+
| Feature | `format-docstring` | [docformatter] | [pydocstringformatter] | [Ruff] | [Black] |
|
|
78
|
+
| ----------------------------------------- | ------------------ | -------------- | ---------------------- | ------ | ------- |
|
|
79
|
+
| Docstring wrapping | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
80
|
+
| Compatible with line length linter (E501) | ✅ | ❌ | ❌ | N/A | N/A |
|
|
81
|
+
| Fixes common docstring typos | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
82
|
+
|
|
83
|
+
## 2. Before vs After Examples
|
|
84
|
+
|
|
85
|
+
These examples show the same kinds of cleanup in the two supported docstring
|
|
86
|
+
styles. Use `--docstring-style numpy` for NumPy-style docstrings and
|
|
87
|
+
`--docstring-style google` for Google-style docstrings.
|
|
88
|
+
|
|
89
|
+
### 2.1. NumPy-style docstrings
|
|
90
|
+
|
|
91
|
+
NumPy-style docstrings use section titles followed by underline rows. Signature
|
|
92
|
+
lines are written as `name : type`, and descriptions are indented under the
|
|
93
|
+
signature line.
|
|
94
|
+
|
|
95
|
+
**Long summaries and descriptions are wrapped.**
|
|
96
|
+
|
|
97
|
+
```diff
|
|
98
|
+
def load_records(path, limit=100):
|
|
99
|
+
- """Load records from disk and normalize every field before returning the resulting table.
|
|
100
|
+
+ """
|
|
101
|
+
+ Load records from disk and normalize every field before returning the
|
|
102
|
+
+ resulting table.
|
|
103
|
+
|
|
104
|
+
Parameters
|
|
105
|
+
----------
|
|
106
|
+
- path : str
|
|
107
|
+
- Path to a CSV file that may be local or remote and may include query parameters that make the line too long.
|
|
108
|
+
- limit : int
|
|
109
|
+
- Maximum number of rows to read before validation and normalization run.
|
|
110
|
+
+ path : str
|
|
111
|
+
+ Path to a CSV file that may be local or remote and may include query
|
|
112
|
+
+ parameters that make the line too long.
|
|
113
|
+
+ limit : int
|
|
114
|
+
+ Maximum number of rows to read before validation and normalization
|
|
115
|
+
+ run.
|
|
116
|
+
|
|
117
|
+
Returns
|
|
118
|
+
-------
|
|
119
|
+
list[dict[str, str]]
|
|
120
|
+
- Normalized rows ready for downstream processing or serialization.
|
|
121
|
+
+ Normalized rows ready for downstream processing or serialization.
|
|
122
|
+
"""
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Known section names and signature spacing are canonicalized.**
|
|
126
|
+
|
|
127
|
+
```diff
|
|
128
|
+
def resize(image):
|
|
129
|
+
"""
|
|
130
|
+
Resize an image.
|
|
131
|
+
|
|
132
|
+
- ParaMEter
|
|
133
|
+
- ---
|
|
134
|
+
+ Parameters
|
|
135
|
+
+ ----------
|
|
136
|
+
image : ArrayLike
|
|
137
|
+
Input image.
|
|
138
|
+
|
|
139
|
+
- ReTurn
|
|
140
|
+
- ----------
|
|
141
|
+
+ Returns
|
|
142
|
+
+ -------
|
|
143
|
+
ArrayLike
|
|
144
|
+
Resized image.
|
|
145
|
+
"""
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Default value declarations are standardized.**
|
|
149
|
+
|
|
150
|
+
```diff
|
|
151
|
+
def connect():
|
|
152
|
+
"""
|
|
153
|
+
Parameters
|
|
154
|
+
----------
|
|
155
|
+
- retries : int default 3
|
|
156
|
+
+ retries : int, default=3
|
|
157
|
+
Number of attempts.
|
|
158
|
+
- timeout : float, default is 1.5
|
|
159
|
+
+ timeout : float, default=1.5
|
|
160
|
+
Timeout in seconds.
|
|
161
|
+
"""
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
**Single backticks in prose are converted to rST inline literals.**
|
|
165
|
+
|
|
166
|
+
```diff
|
|
167
|
+
def parse(payload):
|
|
168
|
+
"""
|
|
169
|
+
- Parse `payload` into a normalized mapping.
|
|
170
|
+
+ Parse ``payload`` into a normalized mapping.
|
|
171
|
+
|
|
172
|
+
Parameters
|
|
173
|
+
----------
|
|
174
|
+
payload : dict
|
|
175
|
+
- Input with `id` and `value` keys.
|
|
176
|
+
+ Input with ``id`` and ``value`` keys.
|
|
177
|
+
"""
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Parameters and returns are synchronized from the real signature.**
|
|
181
|
+
|
|
182
|
+
```diff
|
|
183
|
+
def summarize(name: str, retries: int = 3) -> tuple[int, str]:
|
|
184
|
+
"""
|
|
185
|
+
Summarize a job.
|
|
186
|
+
|
|
187
|
+
Parameters
|
|
188
|
+
----------
|
|
189
|
+
- name : object
|
|
190
|
+
+ name : str
|
|
191
|
+
Job name.
|
|
192
|
+
- retries : int, optional
|
|
193
|
+
+ retries : int, default=3
|
|
194
|
+
Retry count.
|
|
195
|
+
|
|
196
|
+
Returns
|
|
197
|
+
-------
|
|
198
|
+
- float
|
|
199
|
+
+ int
|
|
200
|
+
Number of processed rows.
|
|
201
|
+
str
|
|
202
|
+
Human-readable status.
|
|
203
|
+
"""
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### 2.2. Google-style docstrings
|
|
207
|
+
|
|
208
|
+
Google-style docstrings use colon-ended section headers. Signature lines keep
|
|
209
|
+
the first description sentence inline as `name (type): description`, and
|
|
210
|
+
continuation lines are indented below the description.
|
|
211
|
+
|
|
212
|
+
**Long summaries and descriptions are wrapped.**
|
|
213
|
+
|
|
214
|
+
```diff
|
|
215
|
+
def load_records(path, limit=100):
|
|
216
|
+
- """Load records from disk and normalize every field before returning the resulting table.
|
|
217
|
+
+ """Load records from disk and normalize every field before returning the
|
|
218
|
+
+ resulting table.
|
|
219
|
+
|
|
220
|
+
Args:
|
|
221
|
+
- path (str): Path to a CSV file that may be local or remote and may include query parameters that make the line too long.
|
|
222
|
+
- limit (int): Maximum number of rows to read before validation and normalization run.
|
|
223
|
+
+ path (str): Path to a CSV file that may be local or remote and may
|
|
224
|
+
+ include query parameters that make the line too long.
|
|
225
|
+
+ limit (int): Maximum number of rows to read before validation and
|
|
226
|
+
+ normalization run.
|
|
227
|
+
|
|
228
|
+
Returns:
|
|
229
|
+
- list[dict[str, str]]: Normalized rows ready for downstream processing or serialization.
|
|
230
|
+
+ list[dict[str, str]]: Normalized rows ready for downstream processing
|
|
231
|
+
+ or serialization.
|
|
232
|
+
"""
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**Known section names and signature spacing are canonicalized.**
|
|
236
|
+
|
|
237
|
+
```diff
|
|
238
|
+
def resize(image):
|
|
239
|
+
"""
|
|
240
|
+
Resize an image.
|
|
241
|
+
|
|
242
|
+
- ParaMEter:
|
|
243
|
+
- image(ArrayLike):Input image.
|
|
244
|
+
+ Args:
|
|
245
|
+
+ image (ArrayLike): Input image.
|
|
246
|
+
|
|
247
|
+
- ReTurn:
|
|
248
|
+
- ArrayLike: Resized image.
|
|
249
|
+
+ Returns:
|
|
250
|
+
+ ArrayLike: Resized image.
|
|
251
|
+
"""
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**Default value declarations are standardized.**
|
|
255
|
+
|
|
256
|
+
```diff
|
|
257
|
+
def connect():
|
|
258
|
+
"""
|
|
259
|
+
Args:
|
|
260
|
+
- retries (int, default 3): Number of attempts.
|
|
261
|
+
- timeout (float, default is 1.5): Timeout in seconds.
|
|
262
|
+
+ retries (int, default=3): Number of attempts.
|
|
263
|
+
+ timeout (float, default=1.5): Timeout in seconds.
|
|
264
|
+
"""
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
**Single backticks in prose are converted to rST inline literals.**
|
|
268
|
+
|
|
269
|
+
```diff
|
|
270
|
+
def parse(payload):
|
|
271
|
+
"""
|
|
272
|
+
- Parse `payload` into a normalized mapping.
|
|
273
|
+
+ Parse ``payload`` into a normalized mapping.
|
|
274
|
+
|
|
275
|
+
Args:
|
|
276
|
+
- payload (dict): Input with `id` and `value` keys.
|
|
277
|
+
+ payload (dict): Input with ``id`` and ``value`` keys.
|
|
278
|
+
- Use `strict` mode for validation.
|
|
279
|
+
+ Use ``strict`` mode for validation.
|
|
280
|
+
"""
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
**Parameters and returns are synchronized from the real signature.**
|
|
284
|
+
|
|
285
|
+
```diff
|
|
286
|
+
def summarize(name: str, retries: int = 3) -> tuple[int, str]:
|
|
287
|
+
"""Summarize a job.
|
|
288
|
+
|
|
289
|
+
Args:
|
|
290
|
+
- name (object): Job name.
|
|
291
|
+
+ name (str): Job name.
|
|
292
|
+
- retries (int, optional): Retry count.
|
|
293
|
+
+ retries (int, default=3): Retry count.
|
|
294
|
+
|
|
295
|
+
Returns:
|
|
296
|
+
- status (float): Number of processed rows.
|
|
297
|
+
- label (str): Human-readable status.
|
|
298
|
+
+ tuple[int, str]: Number of processed rows. label (str):
|
|
299
|
+
+ Human-readable status.
|
|
300
|
+
"""
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## 3. Special Formatting Rules
|
|
304
|
+
|
|
305
|
+
`format-docstring` assumes docstrings are already close to NumPy or Google
|
|
306
|
+
style. These examples show the extra rules applied around structure, protected
|
|
307
|
+
content, and source-signature sync.
|
|
308
|
+
|
|
309
|
+
### 3.1. NumPy-style docstrings
|
|
310
|
+
|
|
311
|
+
**Protected content keeps its shape.** Tables, doctest prompts, fenced code,
|
|
312
|
+
literal blocks introduced by `::`, and bullet lists are not reflowed. Prose
|
|
313
|
+
around those blocks still wraps normally.
|
|
314
|
+
|
|
315
|
+
```diff
|
|
316
|
+
"""
|
|
317
|
+
-Use this formula before processing the records because the surrounding prose is long enough to wrap::
|
|
318
|
+
+Use this formula before processing the records because the surrounding prose
|
|
319
|
+
+is long enough to wrap::
|
|
320
|
+
|
|
321
|
+
total = alpha + beta
|
|
322
|
+
ratio = total / count
|
|
323
|
+
|
|
324
|
+
Parameters
|
|
325
|
+
----------
|
|
326
|
+
records : list[dict[str, str]]
|
|
327
|
+
Input records.
|
|
328
|
+
"""
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
**Known sections are parsed, and custom sections are kept.** Recognized section
|
|
332
|
+
titles such as `Parameters`, `Returns`, `Yields`, `Raises`, `Examples`, and
|
|
333
|
+
`Notes` are canonicalized. Unknown underlined sections remain custom sections,
|
|
334
|
+
and their prose is wrapped instead of being parsed as parameter signatures.
|
|
335
|
+
|
|
336
|
+
```diff
|
|
337
|
+
def work():
|
|
338
|
+
"""
|
|
339
|
+
- argument
|
|
340
|
+
- --------
|
|
341
|
+
+ Parameters
|
|
342
|
+
+ ----------
|
|
343
|
+
value : int
|
|
344
|
+
Value to process.
|
|
345
|
+
|
|
346
|
+
- Todo
|
|
347
|
+
- ----
|
|
348
|
+
- Keep this custom section, but wrap its prose normally when it exceeds the configured line length.
|
|
349
|
+
+ Todo
|
|
350
|
+
+ ----
|
|
351
|
+
+ Keep this custom section, but wrap its prose normally when it exceeds the
|
|
352
|
+
+ configured line length.
|
|
353
|
+
"""
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
**Tuple returns can stay split across multiple signature lines.** When the
|
|
357
|
+
docstring already documents tuple elements as separate return entries, NumPy
|
|
358
|
+
formatting syncs each element from the real return annotation.
|
|
359
|
+
|
|
360
|
+
```diff
|
|
361
|
+
def compute() -> tuple[int, str]:
|
|
362
|
+
"""
|
|
363
|
+
Returns
|
|
364
|
+
-------
|
|
365
|
+
- float
|
|
366
|
+
+ int
|
|
367
|
+
Row count.
|
|
368
|
+
str
|
|
369
|
+
Status message.
|
|
370
|
+
"""
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
**`Raises` entries are treated as signatures.** Exception names stay untouched;
|
|
374
|
+
only their descriptions wrap.
|
|
375
|
+
|
|
376
|
+
```diff
|
|
377
|
+
"""
|
|
378
|
+
Raises
|
|
379
|
+
------
|
|
380
|
+
ValueError
|
|
381
|
+
- Raised when the payload is missing a required key and the caller asked for strict validation.
|
|
382
|
+
+ Raised when the payload is missing a required key and the caller asked for
|
|
383
|
+
+ strict validation.
|
|
384
|
+
"""
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
**Class attributes can be synchronized too.** Class docstrings can use
|
|
388
|
+
annotated assignments and type comments as the source of truth for
|
|
389
|
+
`Attributes`.
|
|
390
|
+
|
|
391
|
+
```diff
|
|
392
|
+
class Config:
|
|
393
|
+
"""
|
|
394
|
+
Attributes
|
|
395
|
+
----------
|
|
396
|
+
- retries : int, optional
|
|
397
|
+
+ retries : int, default=3
|
|
398
|
+
Retry count.
|
|
399
|
+
"""
|
|
400
|
+
|
|
401
|
+
retries = 3 # type: int
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
### 3.2. Google-style docstrings
|
|
405
|
+
|
|
406
|
+
**Protected content keeps its shape.** Tables, doctest prompts, fenced code,
|
|
407
|
+
literal blocks introduced by `::`, and Python-like code in `Examples:` are not
|
|
408
|
+
reflowed. Prose around those blocks still wraps normally.
|
|
409
|
+
|
|
410
|
+
```diff
|
|
411
|
+
"""
|
|
412
|
+
-Use this formula before processing the records because the surrounding prose is long enough to wrap::
|
|
413
|
+
+Use this formula before processing the records because the surrounding prose
|
|
414
|
+
+is long enough to wrap::
|
|
415
|
+
|
|
416
|
+
total = alpha + beta
|
|
417
|
+
ratio = total / count
|
|
418
|
+
|
|
419
|
+
Args:
|
|
420
|
+
records (list[dict[str, str]]): Input records.
|
|
421
|
+
"""
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
**Custom section boundaries are indentation-sensitive.** Known headers such as
|
|
425
|
+
`Args:`, `Returns:`, `Raises:`, and `Examples:` are canonicalized. Unknown
|
|
426
|
+
peer-level headers after summary content are treated as custom sections, so
|
|
427
|
+
their body wraps as prose instead of as argument descriptions.
|
|
428
|
+
|
|
429
|
+
```diff
|
|
430
|
+
def work():
|
|
431
|
+
"""
|
|
432
|
+
Do work.
|
|
433
|
+
|
|
434
|
+
- Arguments:
|
|
435
|
+
+ Args:
|
|
436
|
+
value: Value to process.
|
|
437
|
+
|
|
438
|
+
Todo:
|
|
439
|
+
- Keep this custom section, but wrap its prose normally when it exceeds the configured line length.
|
|
440
|
+
+ Keep this custom section, but wrap its prose normally when it exceeds
|
|
441
|
+
+ the configured line length.
|
|
442
|
+
"""
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
If the first content line is an unknown `Name:` header, it is treated as
|
|
446
|
+
summary text rather than promoted to a custom section. That protects compact
|
|
447
|
+
Google summaries from being misclassified.
|
|
448
|
+
|
|
449
|
+
**`Examples:` has special boundary rules.** Indented text that looks like a
|
|
450
|
+
section header can be doctest output. A real section boundary must return to
|
|
451
|
+
the same or lower indentation as the active `Examples:` header.
|
|
452
|
+
|
|
453
|
+
```python
|
|
454
|
+
"""
|
|
455
|
+
Examples:
|
|
456
|
+
>>> print("Args:")
|
|
457
|
+
Args:
|
|
458
|
+
>>> print("done")
|
|
459
|
+
done
|
|
460
|
+
|
|
461
|
+
Args:
|
|
462
|
+
value: Real argument description.
|
|
463
|
+
"""
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
**Returns and yields describe one value.** Google style does not split tuple
|
|
467
|
+
returns into separate return-variable rows. If a tuple annotation is present,
|
|
468
|
+
the formatter syncs the tuple type into one `Returns:` entry and keeps the old
|
|
469
|
+
text as description.
|
|
470
|
+
|
|
471
|
+
```diff
|
|
472
|
+
def compute() -> tuple[int, str]:
|
|
473
|
+
"""
|
|
474
|
+
Returns:
|
|
475
|
+
- count (float): Row count.
|
|
476
|
+
- status (str): Status message.
|
|
477
|
+
+ tuple[int, str]: Row count. status (str): Status message.
|
|
478
|
+
"""
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
**Class attributes can be synchronized too.** Google `Attributes:` entries use
|
|
482
|
+
the same source-signature policy as `Args:`.
|
|
483
|
+
|
|
484
|
+
```diff
|
|
485
|
+
class Config:
|
|
486
|
+
"""
|
|
487
|
+
Attributes:
|
|
488
|
+
- retries (int, optional): Retry count.
|
|
489
|
+
+ retries (int, default=3): Retry count.
|
|
490
|
+
"""
|
|
491
|
+
|
|
492
|
+
retries = 3 # type: int
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
## 4. Installation
|
|
496
|
+
|
|
497
|
+
```bash
|
|
498
|
+
pip install format-docstring
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
## 5. Usage
|
|
502
|
+
|
|
503
|
+
### 5.1. Command Line Interface
|
|
504
|
+
|
|
505
|
+
**For Python files:**
|
|
506
|
+
|
|
507
|
+
```bash
|
|
508
|
+
format-docstring path/to/file.py
|
|
509
|
+
format-docstring path/to/directory/
|
|
510
|
+
|
|
511
|
+
# Format Google-style docstrings
|
|
512
|
+
format-docstring --docstring-style google path/to/file.py
|
|
513
|
+
format-docstring --docstring-style google path/to/directory/
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
**For Jupyter notebooks:**
|
|
517
|
+
|
|
518
|
+
```bash
|
|
519
|
+
format-docstring-jupyter path/to/notebook.ipynb
|
|
520
|
+
format-docstring-jupyter path/to/directory/
|
|
521
|
+
|
|
522
|
+
# Format Google-style docstrings in notebooks
|
|
523
|
+
format-docstring-jupyter --docstring-style google path/to/notebook.ipynb
|
|
524
|
+
format-docstring-jupyter --docstring-style google path/to/directory/
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
### 5.2. Pre-commit Hook
|
|
528
|
+
|
|
529
|
+
To use `format-docstring` as a pre-commit hook, add this to your
|
|
530
|
+
`.pre-commit-config.yaml`:
|
|
531
|
+
|
|
532
|
+
```yaml
|
|
533
|
+
repos:
|
|
534
|
+
- repo: https://github.com/jsh9/format-docstring
|
|
535
|
+
rev: <LATEST_VERSION>
|
|
536
|
+
hooks:
|
|
537
|
+
- id: format-docstring
|
|
538
|
+
name: Format docstrings in .py files
|
|
539
|
+
args: [--docstring-style=numpy, --line-length=79]
|
|
540
|
+
- id: format-docstring-jupyter
|
|
541
|
+
name: Format docstrings in .ipynb files
|
|
542
|
+
args: [--docstring-style=numpy, --line-length=79]
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
For Google-style docstrings, use `--docstring-style=google` in the hook args.
|
|
546
|
+
|
|
547
|
+
Then install the pre-commit hook:
|
|
548
|
+
|
|
549
|
+
```bash
|
|
550
|
+
pre-commit install
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
### 5.3. Opting Out of Formatting
|
|
554
|
+
|
|
555
|
+
Add a comment containing `no-format-docstring` on the same line as the closing
|
|
556
|
+
triple quotes to prevent the formatter from touching that docstring:
|
|
557
|
+
`""" ... """ # no-format-docstring`.
|
|
558
|
+
|
|
559
|
+
You can combine this "no-format-docstring" with other directives like "noqa".
|
|
560
|
+
|
|
561
|
+
Tip: If you only want to keep specific formatter changes inside a docstring,
|
|
562
|
+
first run `format-docstring`, accept the parts you like, revert the edits you
|
|
563
|
+
dislike, and then add an inline `# no-format-docstring` comment so future runs
|
|
564
|
+
leave that docstring untouched.
|
|
565
|
+
|
|
566
|
+
## 6. Configuration
|
|
567
|
+
|
|
568
|
+
### 6.1. Command-Line Options
|
|
569
|
+
|
|
570
|
+
- `--line-length INTEGER`: Maximum line length for wrapping docstrings
|
|
571
|
+
(default: 79)
|
|
572
|
+
- `--docstring-style CHOICE`: Docstring style to target (`numpy` or `google`,
|
|
573
|
+
default: `numpy`). This selects the style to format, not a converter between
|
|
574
|
+
styles.
|
|
575
|
+
- `--fix-rst-backticks BOOL`: Automatically fix single backticks to double
|
|
576
|
+
backticks per rST syntax (default: `True`). Pass `False` to disable this.
|
|
577
|
+
- `--verbose CHOICE`: Logging detail level (`default` keeps the existing
|
|
578
|
+
behaviour, `diff` prints unified diffs when rewrites happen)
|
|
579
|
+
- `--exclude TEXT`: Regex pattern to exclude files/directories (default:
|
|
580
|
+
`\.git|\.tox|\.pytest_cache`)
|
|
581
|
+
- `--config PATH`: Path to a `pyproject.toml` config file. If not specified,
|
|
582
|
+
the tool automatically searches for `pyproject.toml` in parent directories.
|
|
583
|
+
Command-line options take precedence over config file settings.
|
|
584
|
+
- `--version`: Show version information
|
|
585
|
+
- `--help`: Show help message
|
|
586
|
+
|
|
587
|
+
### 6.2. Usage Examples
|
|
588
|
+
|
|
589
|
+
```bash
|
|
590
|
+
# Format a single file with default settings
|
|
591
|
+
format-docstring my_module.py
|
|
592
|
+
|
|
593
|
+
# Format all Python files in a directory with custom line length
|
|
594
|
+
format-docstring --line-length 72 src/
|
|
595
|
+
|
|
596
|
+
# Format Google-style docstrings
|
|
597
|
+
format-docstring --docstring-style google src/
|
|
598
|
+
|
|
599
|
+
# Format Jupyter notebooks excluding certain directories
|
|
600
|
+
format-docstring-jupyter --exclude "\.git|\.venv|__pycache__" notebooks/
|
|
601
|
+
|
|
602
|
+
# Format Google-style docstrings in notebooks
|
|
603
|
+
format-docstring-jupyter --docstring-style google notebooks/
|
|
604
|
+
|
|
605
|
+
# Preview changes with unified diffs
|
|
606
|
+
format-docstring --verbose diff src/
|
|
607
|
+
|
|
608
|
+
# Use a specific config file
|
|
609
|
+
format-docstring --config path/to/pyproject.toml src/
|
|
610
|
+
|
|
611
|
+
# CLI options override config file settings
|
|
612
|
+
format-docstring --config pyproject.toml --line-length 100 src/
|
|
613
|
+
|
|
614
|
+
# Disable backtick fixing
|
|
615
|
+
format-docstring --fix-rst-backticks=False my_module.py
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
### 6.3. `pyproject.toml` Configuration
|
|
619
|
+
|
|
620
|
+
You can configure default values under `[tool.format_docstring]` in
|
|
621
|
+
`pyproject.toml`. CLI arguments override these settings. The config loader
|
|
622
|
+
accepts either underscore keys, such as `line_length`, or hyphenated keys, such
|
|
623
|
+
as `line-length`.
|
|
624
|
+
|
|
625
|
+
```toml
|
|
626
|
+
[tool.format_docstring]
|
|
627
|
+
line_length = 79
|
|
628
|
+
docstring_style = "numpy"
|
|
629
|
+
fix_rst_backticks = true
|
|
630
|
+
exclude = "\\.git|\\.venv|__pycache__"
|
|
631
|
+
verbose = "default" # or "diff" to print unified diffs
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
For Google-style docstrings:
|
|
635
|
+
|
|
636
|
+
```toml
|
|
637
|
+
[tool.format_docstring]
|
|
638
|
+
docstring_style = "google"
|
|
639
|
+
line_length = 79
|
|
640
|
+
fix_rst_backticks = true
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
**Available options:**
|
|
644
|
+
|
|
645
|
+
- `line_length` / `line-length` (int): maximum line length for wrapping
|
|
646
|
+
docstrings. Default: `79`.
|
|
647
|
+
- `docstring_style` / `docstring-style` (str): target docstring style, either
|
|
648
|
+
`"numpy"` or `"google"`. Default: `"numpy"`.
|
|
649
|
+
- `fix_rst_backticks` / `fix-rst-backticks` (bool): whether to convert single
|
|
650
|
+
backticks in prose to double backticks per rST syntax. Default: `true`.
|
|
651
|
+
- `exclude` (str): regex pattern used to skip files or directories. Default:
|
|
652
|
+
`"\\.git|\\.tox|\\.pytest_cache"`.
|
|
653
|
+
- `verbose` (str): logging detail level, either `"default"` or `"diff"`. Use
|
|
654
|
+
`"diff"` to print unified diffs when rewrites happen.
|
|
655
|
+
|
|
656
|
+
The tool searches for `pyproject.toml` starting from the target file/directory
|
|
657
|
+
and walking up the parent directories until one is found.
|
|
658
|
+
|
|
659
|
+
## 7. Caveat
|
|
660
|
+
|
|
661
|
+
This tool assumes the docstrings are written in **mostly** the correct format,
|
|
662
|
+
because it needs those formatting cues (such as section headers and `------`)
|
|
663
|
+
to parse docstrings.
|
|
664
|
+
|
|
665
|
+
If the docstrings are far from perfectly formatted, it's recommended that you
|
|
666
|
+
use AI coding assistants to rewrite the docstrings first.
|
|
667
|
+
|
|
668
|
+
[black]: https://github.com/psf/black
|
|
669
|
+
[docformatter]: https://github.com/PyCQA/docformatter
|
|
670
|
+
[pydocstringformatter]: https://github.com/DanielNoord/pydocstringformatter
|
|
671
|
+
[ruff]: https://github.com/astral-sh/ruff
|