From 4167d336392e4596549545eb6888dc0edab5ec55 Mon Sep 17 00:00:00 2001 From: Diego Miguel Date: Fri, 29 Nov 2024 17:33:01 +0100 Subject: [PATCH] Include all casing functions in `README.md` --- README.md | 102 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 63 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 1ed7f8b..d2f3962 100644 --- a/README.md +++ b/README.md @@ -12,28 +12,37 @@ ## Introduction -Casefy (/keɪsfaɪ/) is a lightweight Python package to convert the casing of strings. It has no third-party dependencies and supports Unicode. +Casefy (/keɪsfaɪ/) is a lightweight Python package to convert the casing of +strings. It has no third-party dependencies and supports Unicode.
## Installation -The latest release can be installed using [pip](https://pypi.org/project/casefy/): +The latest release can be installed using +[pip](https://pypi.org/project/casefy/): + ```shell pip install -U casefy ``` -Casefy is also [available](https://aur.archlinux.org/packages/python-casefy) as an Arch Linux AUR package. +Casefy is also [available](https://aur.archlinux.org/packages/python-casefy) as +an Arch Linux AUR package.
## Examples -Note: for more details, you can check the [API Reference](https://dmlls.github.io/python-casefy/api.html). +Note: for more details, you can check the [API +Reference](https://dmlls.github.io/python-casefy/api.html). ```python import casefy +# Alphanum3ric case (removes non-alphanumeric chars) +string = casefy.alphanumcase("foo - 123 ; bar!") +print(string) # foo123bar + # camelCase string = casefy.camelcase("foo_bar") print(string) # fooBar @@ -44,62 +53,61 @@ print(string) # fooBar string = casefy.camelcase("FOO BAR") print(string) # fooBar - -# PascalCase -string = casefy.pascalcase("foo_bar") -print(string) # FooBar - -string = casefy.pascalcase("fooBar") +# Capital Case +string = casefy.capitalcase("fooBar") print(string) # FooBar - -# snake_case -string = casefy.snakecase("fooBar") -print(string) # foo_bar - -string = casefy.snakecase("fooBARbaz", keep_together=["bar"]) -print(string) # foo_bar_baz - -string = casefy.snakecase("FOO BAR") -print(string) # foo_bar - - # CONST_CASE string = casefy.constcase("fooBar") print(string) # FOO_BAR - # kebab-case string = casefy.kebabcase("fooBar") print(string) # foo-bar +# lowercase +string = casefy.lowercase("fooBar") +print(string) # foobar -# UPPER-KEBAB-CASE -string = casefy.upperkebabcase("fooBar") -print(string) # FOO-BAR +# PascalCase +string = casefy.pascalcase("foo_bar") +print(string) # FooBar +string = casefy.pascalcase("fooBar") +print(string) # FooBar -# separator case +# Sentence case +string = casefy.sentencecase("fooBar") +print(string) # Foo bar + +# Separator case string = casefy.separatorcase("fooBar", separator="/") print(string) # foo/bar string = casefy.separatorcase("fooBARbaz", separator="%", keep_together=["bar"]) print(string) # foo%bar%baz +# snake_case +string = casefy.snakecase("fooBar") +print(string) # foo_bar -# Sentence case -string = casefy.sentencecase("fooBar") -print(string) # Foo bar +string = casefy.snakecase("fooBARbaz", keep_together=["bar"]) +print(string) # foo_bar_baz +string = casefy.snakecase("FOO BAR") +print(string) # foo_bar # Title Case -string = casefy.titlecase("fooBar") -print(string) # Foo Bar +string = casefy.titlecase("fooBarBaz") +print(string) # Foo Bar Baz +# UPPERCASE +string = casefy.uppercase("fooBar") +print(string) # FOOBAR -# Alphanum3ric case (removes non-alphanumeric chars) -string = casefy.alphanumcase("foo - 123 ; bar!") -print(string) # foo123bar +# UPPER-KEBAB-CASE +string = casefy.upperkebabcase("fooBar") +print(string) # FOO-BAR ```
@@ -111,17 +119,33 @@ If you find a bug, please open an issue. Pull Requests are also welcome! ## Acknowledgements -This project started when I saw that the package [`python-stringcase`](https://aur.archlinux.org/pkgbase/python-stringcase) was flagged-out-of-date in the Arch AUR Repository. The project [stringcase](https://github.com/okunishinishi/python-stringcase) seems not to be actively maintained anymore, so I decided to address its issues and pull requests and solve them in this new package. I kept the API as similar as possible, in order to facilitate any possible migration. I thank [Taka Okunishi](https://github.com/okunishinishi) (author of stringcase) and its contributors for their work. +This project started when I saw that the package +[`python-stringcase`](https://aur.archlinux.org/pkgbase/python-stringcase) was +flagged-out-of-date in the Arch AUR Repository. The project +[stringcase](https://github.com/okunishinishi/python-stringcase) seems not to be +actively maintained anymore, so I decided to address its issues and pull +requests and solve them in this new package. I kept the API as similar as +possible, in order to facilitate any possible migration. I thank [Taka +Okunishi](https://github.com/okunishinishi) (author of stringcase) and its +contributors for their work.
## Related projects -- [`case-conversion`](https://github.com/AlejandroFrias/case-conversion) offers a very similar functionality as this project. I probably wouldn't have written this package if I had known of it before. However, the code of Casefy is more lightweight and just enough for most cases. If you need more functionality, e.g., detecting the case of a string, go with `case-conversion`. +- [`case-conversion`](https://github.com/AlejandroFrias/case-conversion) offers + a very similar functionality as this project. I probably wouldn't have written + this package if I had known of it before. However, the code of Casefy is more + lightweight and just enough for most cases. If you need more functionality, + e.g., detecting the case of a string, go with `case-conversion`. -- [Inflection](https://github.com/jpvanhal/inflection) presents some overlap with this project as well, allowing the transformation of strings from CamelCase to underscored_string, but also singularizing and pluralizing English words. +- [Inflection](https://github.com/jpvanhal/inflection) presents some overlap + with this project as well, allowing the transformation of strings from + CamelCase to underscored_string, but also singularizing and pluralizing + English words.
## License -Casefy is distributed under the [MIT](https://github.com/dmlls/python-casefy/blob/main/LICENSE) license. +Casefy is distributed under the +[MIT](https://github.com/dmlls/python-casefy/blob/main/LICENSE) license.