format-docstring 0.1.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.1.0/.github/workflows/python-package.yml +28 -0
- format_docstring-0.1.0/.github/workflows/python-publish.yml +28 -0
- format_docstring-0.1.0/.gitignore +210 -0
- format_docstring-0.1.0/.pre-commit-config.yaml +42 -0
- format_docstring-0.1.0/.pre-commit-hooks.yaml +13 -0
- format_docstring-0.1.0/CHANGELOG.md +14 -0
- format_docstring-0.1.0/CLAUDE.md +151 -0
- format_docstring-0.1.0/LICENSE +21 -0
- format_docstring-0.1.0/PKG-INFO +311 -0
- format_docstring-0.1.0/README.md +278 -0
- format_docstring-0.1.0/format_docstring/__init__.py +5 -0
- format_docstring-0.1.0/format_docstring/base_fixer.py +70 -0
- format_docstring-0.1.0/format_docstring/config.py +211 -0
- format_docstring-0.1.0/format_docstring/docstring_rewriter.py +314 -0
- format_docstring-0.1.0/format_docstring/line_wrap_google.py +7 -0
- format_docstring-0.1.0/format_docstring/line_wrap_numpy.py +387 -0
- format_docstring-0.1.0/format_docstring/line_wrap_utils.py +781 -0
- format_docstring-0.1.0/format_docstring/main_jupyter.py +165 -0
- format_docstring-0.1.0/format_docstring/main_py.py +125 -0
- format_docstring-0.1.0/format_docstring.egg-info/PKG-INFO +311 -0
- format_docstring-0.1.0/format_docstring.egg-info/SOURCES.txt +91 -0
- format_docstring-0.1.0/format_docstring.egg-info/dependency_links.txt +1 -0
- format_docstring-0.1.0/format_docstring.egg-info/entry_points.txt +3 -0
- format_docstring-0.1.0/format_docstring.egg-info/requires.txt +6 -0
- format_docstring-0.1.0/format_docstring.egg-info/top_level.txt +2 -0
- format_docstring-0.1.0/muff.toml +48 -0
- format_docstring-0.1.0/pyproject.toml +61 -0
- format_docstring-0.1.0/requirements.dev +3 -0
- format_docstring-0.1.0/setup.cfg +4 -0
- format_docstring-0.1.0/tests/__init__.py +0 -0
- format_docstring-0.1.0/tests/helpers.py +54 -0
- format_docstring-0.1.0/tests/test_config.py +252 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/README.md +2 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/colon_spacing_fix.txt +58 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/contents_that_are_not_wrapped.txt +105 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/default_value_standardization.txt +103 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/empty_lines_are_respected.txt +85 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/existing_linebreaks_should_not_be_respected.txt +31 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/four_level_nested_classes.txt +101 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/indent_four_levels_16_spaces_width_10.txt +56 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/indent_misaligned_all.txt +69 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/indent_two_levels_8_spaces.txt +22 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/line_length_2.txt +57 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/mismatched_underlines.txt +43 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/mismatched_underlines_one_dash.txt +37 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/mismatched_underlines_two_dashes.txt +47 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/module_level_docstring.txt +19 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/new_lines_before_and_after.txt +135 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/param_signature_without_type.txt +35 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/parameters_returns_raises_wrapping.txt +77 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/returns_signature_and_description.txt +25 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/section_title_fixed.txt +68 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/sections_notes_examples.txt +79 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/signature_line_is_not_wrapped.txt +25 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/single_line_docstring.txt +55 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/texts_are_rewrapped.txt +131 -0
- format_docstring-0.1.0/tests/test_data/end_to_end/numpy/very_long_unbreakable_word.txt +22 -0
- format_docstring-0.1.0/tests/test_data/integration_test/numpy/after.ipynb +95 -0
- format_docstring-0.1.0/tests/test_data/integration_test/numpy/after.py +38 -0
- format_docstring-0.1.0/tests/test_data/integration_test/numpy/after_50.ipynb +103 -0
- format_docstring-0.1.0/tests/test_data/integration_test/numpy/after_50.py +46 -0
- format_docstring-0.1.0/tests/test_data/integration_test/numpy/before.ipynb +78 -0
- format_docstring-0.1.0/tests/test_data/integration_test/numpy/before.py +24 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/README.md +1 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/colon_spacing_fix.txt +30 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/contents_that_are_not_wrapped.txt +91 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/default_value_standardization.txt +42 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/empty_lines_are_respected.txt +64 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/existing_linebreaks_should_not_be_respected.txt +23 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/indent_four_levels_16_spaces_width_10.txt +46 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/indent_two_levels_8_spaces.txt +12 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/line_length_2.txt +49 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/mismatched_underlines.txt +28 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/mismatched_underlines_one_dash.txt +22 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/mismatched_underlines_two_dashes.txt +27 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/module_level_docstring.txt +11 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/param_signature_without_type.txt +26 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/parameters_returns_raises_wrapping.txt +65 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/returns_signature_and_description.txt +16 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/section_title_fixed.txt +60 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/sections_notes_examples.txt +66 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/signature_line_is_not_wrapped.txt +17 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/texts_are_rewrapped.txt +119 -0
- format_docstring-0.1.0/tests/test_data/line_wrap/numpy/very_long_unbreakable_word.txt +14 -0
- format_docstring-0.1.0/tests/test_data/playground.py +0 -0
- format_docstring-0.1.0/tests/test_docstring_rewriter.py +345 -0
- format_docstring-0.1.0/tests/test_line_wrap_google.py +0 -0
- format_docstring-0.1.0/tests/test_line_wrap_numpy.py +238 -0
- format_docstring-0.1.0/tests/test_line_wrap_utils.py +1472 -0
- format_docstring-0.1.0/tests/test_main_jupyter.py +45 -0
- format_docstring-0.1.0/tests/test_main_py.py +42 -0
- format_docstring-0.1.0/tests/test_playground.py +19 -0
- format_docstring-0.1.0/tox.ini +79 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Python package
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
name: Test Python ${{ matrix.python-version }} (${{ matrix.os }})
|
|
11
|
+
runs-on: ${{ matrix.os }}
|
|
12
|
+
strategy:
|
|
13
|
+
fail-fast: false
|
|
14
|
+
matrix:
|
|
15
|
+
os: [ubuntu-latest, windows-latest, macOS-latest]
|
|
16
|
+
python-version: ['3.10', '3.11', '3.12', '3.13']
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
20
|
+
uses: actions/setup-python@v4
|
|
21
|
+
with:
|
|
22
|
+
python-version: ${{ matrix.python-version }}
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: |
|
|
25
|
+
python -m pip install --upgrade pip
|
|
26
|
+
python -m pip install tox tox-gh-actions
|
|
27
|
+
- name: Test with tox
|
|
28
|
+
run: tox
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Upload Python Package
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
jobs:
|
|
10
|
+
deploy:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- name: Set up Python
|
|
15
|
+
uses: actions/setup-python@v4
|
|
16
|
+
with:
|
|
17
|
+
python-version: 3.x
|
|
18
|
+
- name: Install dependencies
|
|
19
|
+
run: |
|
|
20
|
+
python -m pip install --upgrade pip
|
|
21
|
+
pip install build
|
|
22
|
+
- name: Build package
|
|
23
|
+
run: python -m build
|
|
24
|
+
- name: Publish package
|
|
25
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
26
|
+
with:
|
|
27
|
+
user: __token__
|
|
28
|
+
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
208
|
+
|
|
209
|
+
# JetBrains IDEs
|
|
210
|
+
.idea/
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
repos:
|
|
3
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
4
|
+
rev: v6.0.0
|
|
5
|
+
hooks:
|
|
6
|
+
- id: trailing-whitespace
|
|
7
|
+
- id: end-of-file-fixer
|
|
8
|
+
- id: debug-statements
|
|
9
|
+
- id: double-quote-string-fixer
|
|
10
|
+
- id: requirements-txt-fixer
|
|
11
|
+
- id: pretty-format-json
|
|
12
|
+
args: [--no-ensure-ascii, --indent=4, --no-sort-keys]
|
|
13
|
+
exclude: \.ipynb$
|
|
14
|
+
- repo: https://github.com/asottile/pyupgrade
|
|
15
|
+
rev: v3.20.0
|
|
16
|
+
hooks:
|
|
17
|
+
- id: pyupgrade
|
|
18
|
+
args: [--py310-plus]
|
|
19
|
+
- repo: https://github.com/jsh9/muff-pre-commit
|
|
20
|
+
rev: 0.13.2
|
|
21
|
+
hooks:
|
|
22
|
+
- id: muff-format
|
|
23
|
+
args: [--config, muff.toml]
|
|
24
|
+
- repo: https://github.com/jsh9/blank-line-after-blocks
|
|
25
|
+
rev: 0.1.4
|
|
26
|
+
hooks:
|
|
27
|
+
- id: blank-line-after-blocks
|
|
28
|
+
- id: blank-line-after-blocks-jupyter
|
|
29
|
+
- repo: https://github.com/lyz-code/yamlfix
|
|
30
|
+
rev: 1.18.0
|
|
31
|
+
hooks:
|
|
32
|
+
- id: yamlfix
|
|
33
|
+
- repo: https://github.com/hukkin/mdformat
|
|
34
|
+
rev: 0.7.22
|
|
35
|
+
hooks:
|
|
36
|
+
- id: mdformat
|
|
37
|
+
args: [--wrap, '79', --number]
|
|
38
|
+
additional_dependencies: [mdformat-tables]
|
|
39
|
+
- repo: https://github.com/jsh9/markdown-toc-creator
|
|
40
|
+
rev: 0.0.10
|
|
41
|
+
hooks:
|
|
42
|
+
- id: markdown-toc-creator
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
- id: format-docstring
|
|
3
|
+
name: Wrap long docstring lines (in .py files)
|
|
4
|
+
description: Python formatter CLI for docstring line wrapping in Python files.
|
|
5
|
+
entry: format-docstring
|
|
6
|
+
language: python
|
|
7
|
+
types: [python]
|
|
8
|
+
- id: format-docstring-jupyter
|
|
9
|
+
name: Wrap long docstring lines (in .ipynb files)
|
|
10
|
+
description: Python formatter for docstring line wrapping in Jupyter notebooks.
|
|
11
|
+
entry: format-docstring-jupyter
|
|
12
|
+
language: python
|
|
13
|
+
files: ^.*\.ipynb$
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on
|
|
6
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
|
|
7
|
+
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
|
+
|
|
9
|
+
## [0.1.0] - 2025-09-07
|
|
10
|
+
|
|
11
|
+
- Added
|
|
12
|
+
- Initial release
|
|
13
|
+
- Full diff
|
|
14
|
+
- N/A
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with
|
|
4
|
+
code in this repository.
|
|
5
|
+
|
|
6
|
+
## Commands
|
|
7
|
+
|
|
8
|
+
### Development Commands
|
|
9
|
+
|
|
10
|
+
- `pytest --tb=long` - Run all tests with detailed traceback
|
|
11
|
+
- `pytest tests/test_specific_file.py` - Run a specific test file
|
|
12
|
+
- `pytest tests/test_specific_file.py::test_function_name` - Run a specific
|
|
13
|
+
test function
|
|
14
|
+
|
|
15
|
+
### Linting and Formatting
|
|
16
|
+
|
|
17
|
+
- `mypy format_docstring/` - Type checking
|
|
18
|
+
- `muff check --fix --config=muff.toml format_docstring tests` - Lint and
|
|
19
|
+
auto-fix with muff
|
|
20
|
+
- `muff format --diff --config=muff.toml format_docstring tests` - Show
|
|
21
|
+
formatting differences (use `--diff` to preview)
|
|
22
|
+
- `flake8 --select CLB,PAR,N400 .` - Additional linting checks
|
|
23
|
+
- `pre-commit run -a` - Run all pre-commit hooks
|
|
24
|
+
|
|
25
|
+
### Tox Commands
|
|
26
|
+
|
|
27
|
+
- `tox` - Run all tox environments (Python 3.10-3.13, mypy, linting)
|
|
28
|
+
- `tox -e py311` - Run tests on Python 3.11
|
|
29
|
+
- `tox -e mypy` - Run type checking
|
|
30
|
+
- `tox -e muff-lint` - Run muff linting
|
|
31
|
+
- `tox -e muff-format` - Run muff formatting check
|
|
32
|
+
|
|
33
|
+
### Building and Installation
|
|
34
|
+
|
|
35
|
+
- `pip install -e .` - Install in development mode
|
|
36
|
+
- `format-docstring --help` - Run the CLI tool
|
|
37
|
+
- `format-docstring-jupyter --help` - Run the Jupyter notebook version
|
|
38
|
+
|
|
39
|
+
## Code Architecture
|
|
40
|
+
|
|
41
|
+
### Core Components
|
|
42
|
+
|
|
43
|
+
1. **Entry Points**: Two main CLI tools defined in `pyproject.toml`:
|
|
44
|
+
|
|
45
|
+
- `format-docstring` → `format_docstring.main_py:main` - For Python files
|
|
46
|
+
- `format-docstring-jupyter` → `format_docstring.main_jupyter:main` - For
|
|
47
|
+
Jupyter notebooks
|
|
48
|
+
|
|
49
|
+
2. **Base Architecture**:
|
|
50
|
+
|
|
51
|
+
- `base_fixer.py` - Abstract base class `BaseFixer` for file processing
|
|
52
|
+
- Implements file discovery, exclusion patterns, and batch processing logic
|
|
53
|
+
- Subclasses implement `fix_one_file()` method for specific file types
|
|
54
|
+
|
|
55
|
+
3. **Docstring Processing**:
|
|
56
|
+
|
|
57
|
+
- `docstring_rewriter.py` - Core docstring parsing and rewriting logic
|
|
58
|
+
- `line_wrap_numpy.py` - NumPy style docstring formatting
|
|
59
|
+
- `line_wrap_google.py` - Google style docstring formatting (limited
|
|
60
|
+
support)
|
|
61
|
+
- `line_wrap_utils.py` - Shared utilities for line wrapping
|
|
62
|
+
|
|
63
|
+
4. **Configuration System**:
|
|
64
|
+
|
|
65
|
+
- `config.py` - Configuration file parsing and management
|
|
66
|
+
- Loads settings from `pyproject.toml` ([tool.format_docstring] section)
|
|
67
|
+
- Auto-discovers config file by walking up directory tree from target paths
|
|
68
|
+
- CLI options override config file settings
|
|
69
|
+
- Uses `tomllib` (Python 3.11+) or `tomli` (Python 3.10) for TOML parsing
|
|
70
|
+
|
|
71
|
+
5. **Style Support**:
|
|
72
|
+
|
|
73
|
+
- Primary support: NumPy docstring style
|
|
74
|
+
- Limited support: Google docstring style
|
|
75
|
+
- Uses `docstring_parser_fork` library for parsing
|
|
76
|
+
|
|
77
|
+
### Key Dependencies
|
|
78
|
+
|
|
79
|
+
- `click>=8.0` - CLI framework
|
|
80
|
+
- `docstring_parser_fork>=0.0.14` - Docstring parsing
|
|
81
|
+
- `jupyter-notebook-parser>=0.1.4` - Jupyter notebook support
|
|
82
|
+
- `tomli>=1.1.0` (Python < 3.11) - TOML file parsing
|
|
83
|
+
|
|
84
|
+
### Configuration
|
|
85
|
+
|
|
86
|
+
- **Config File**: `pyproject.toml` with `[tool.format_docstring]` section
|
|
87
|
+
- `line_length` (int): Maximum line length for wrapping (default: 79)
|
|
88
|
+
- `docstring_style` (str): `"numpy"` or `"google"` (default: `"numpy"`)
|
|
89
|
+
- `exclude` (str): Regex pattern to exclude files/directories
|
|
90
|
+
- **CLI Options**: `--line-length`, `--docstring-style`, `--exclude`,
|
|
91
|
+
`--config`
|
|
92
|
+
- **Priority**: CLI arguments override config file settings
|
|
93
|
+
- **Auto-discovery**: Searches for `pyproject.toml` in parent directories
|
|
94
|
+
- Muff configuration in `muff.toml` with 79 character line length and single
|
|
95
|
+
quotes
|
|
96
|
+
|
|
97
|
+
### Test Structure
|
|
98
|
+
|
|
99
|
+
- `tests/` directory with comprehensive test coverage
|
|
100
|
+
- `test_data/` subdirectory contains test fixtures
|
|
101
|
+
- Tests cover all main modules: line wrapping, docstring rewriting, CLI tools,
|
|
102
|
+
config parsing
|
|
103
|
+
- Use pytest framework with detailed tracebacks
|
|
104
|
+
- Test case format in `test_data/`: `LINE_LENGTH: <int>` header, then
|
|
105
|
+
BEFORE/AFTER sections separated by `**********`
|
|
106
|
+
- Config tests in `tests/test_config.py` verify TOML parsing, auto-discovery,
|
|
107
|
+
and CLI override behavior
|
|
108
|
+
|
|
109
|
+
## Important Development Patterns
|
|
110
|
+
|
|
111
|
+
### Code Preservation Philosophy
|
|
112
|
+
|
|
113
|
+
- **Direct String Replacement**: The tool uses precise AST-to-source mapping to
|
|
114
|
+
replace only docstrings, preserving all other code formatting, comments, and
|
|
115
|
+
whitespace exactly
|
|
116
|
+
- **Line-Aware Processing**: Uses `calc_line_starts()` to maintain exact line
|
|
117
|
+
positioning without using `ast.unparse()`
|
|
118
|
+
- **Conservative Approach**: Only modifies docstring content, never touches
|
|
119
|
+
surrounding code structure
|
|
120
|
+
|
|
121
|
+
### NumPy Style Processing Rules
|
|
122
|
+
|
|
123
|
+
- **Section Recognition**: Automatically detects section headers (Parameters,
|
|
124
|
+
Returns, etc.) and their underlines
|
|
125
|
+
- **Signature vs Description**: Distinguishes parameter signature lines (e.g.,
|
|
126
|
+
`arg : type`) from indented description text
|
|
127
|
+
- **Special Case Handling**: Preserves without wrapping:
|
|
128
|
+
- Examples sections with `>>>` prompts
|
|
129
|
+
- rST tables (lines with `===` or `---` separators)
|
|
130
|
+
- Content following `::` (literal blocks)
|
|
131
|
+
- Bullet lists (lines starting with `-`)
|
|
132
|
+
- Fenced code blocks (\`\`\`\` ... \`\`\`\`\`)
|
|
133
|
+
- **Colon Spacing**: Automatically fixes spacing around colons in parameter
|
|
134
|
+
signatures to use `:` format (e.g., `arg: int` → `arg : int`, `arg : int`
|
|
135
|
+
→ `arg : int`)
|
|
136
|
+
- **Section Title Fixes**: Corrects common typos (e.g., `Parameter` →
|
|
137
|
+
`Parameters`, `ReTurn` → `Returns`) and underline lengths
|
|
138
|
+
|
|
139
|
+
### File-Based Test Pattern
|
|
140
|
+
|
|
141
|
+
- Test cases use structured text files with BEFORE/AFTER sections
|
|
142
|
+
- Helper function `load_cases_from_dir()` automatically discovers and loads
|
|
143
|
+
test cases
|
|
144
|
+
- Use `pytest.mark.parametrize` with test data files for comprehensive coverage
|
|
145
|
+
|
|
146
|
+
### Pre-commit Hook
|
|
147
|
+
|
|
148
|
+
Available as pre-commit hooks (see `.pre-commit-hooks.yaml`):
|
|
149
|
+
|
|
150
|
+
- `format-docstring` - For `.py` files
|
|
151
|
+
- `format-docstring-jupyter` - For `.ipynb` files
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 jsh9
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|