okunishinishi / python-stringcase

String case converter for python.
https://pypi.python.org/pypi/stringcase
MIT License
206 stars 36 forks source link

Docs don't match implementation #9

Open mgoodhand opened 7 years ago

mgoodhand commented 7 years ago

The documentation in the README and on pypi is out of sync with the implementation (1.2.0):

>>> stringcase.constcase('FooBarBaz') # => "_FOO_BAR_BAZ"
'FOO_BAR_BAZ'
>>> stringcase.pathcase('FooBarBaz') # => "/foo/bar/baz"
'foo/bar/baz'
>>> stringcase.snakecase('FooBarBaz') # => "_foo_bar_baz"
'foo_bar_baz'
>>> stringcase.spinalcase('FooBarBaz') # => "-foo-bar-baz"
'foo-bar-baz'
>>> stringcase.titlecase('FooBarBaz') # => " Foo Bar Baz"
'Foo Bar Baz'
>>> stringcase.alphanumcase('_Foo., Bar') # =>'FooBar'
'_FooBar'

For all except the last one, I think the code is doing the right thing and the docs are wrong.

I presume alphanumcase is meant to drop all non-alphanumeric characters, so the fact that it currently retains '_' seems problematic.

ShivaShankerReddy commented 4 years ago

@mgoodhand the current docs are showing correctly. stringcase.alphanumcase('_Foo., Bar') # =>'FooBar'

mgoodhand commented 4 years ago

Yes, the docs for alphanumcase are correct, but the implementation seems wrong:

(env) eden:tmp mrg$ pip install stringcase
Collecting stringcase
Installing collected packages: stringcase
Successfully installed stringcase-1.2.0
You are using pip version 19.0.3, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(env) eden:tmp mrg$ python
Python 3.7.4 (default, Jul  9 2019, 18:13:23)
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import stringcase
>>> stringcase.alphanumcase('_Foo., Bar') # =>'FooBar'
'_FooBar'
>>> stringcase.alphanumcase('Foo_123 Bar!')
'Foo_123Bar'
mgoodhand commented 4 years ago

For the other ones mentioned, it's the documentation that's wrong, e.g.

>>> stringcase.constcase('FooBarBaz') # => "_FOO_BAR_BAZ"
'FOO_BAR_BAZ'

The implementation matches what I'd expect (FOO_BAR_BAZ), but the documentation includes a leading underscore (_FOO_BAR_BAZ).