diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8489e774d..d6ac0ebeb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -10,6 +10,7 @@ v0.18.1 (on deck) - [ENH] add camelCase conversion to snake_case on ``clean_names`` by @ericmjl, h/t @jtaylor for sharing original - [ENH] add engineering submodule with unit conversion method by @rahosbach +- [DOC] add PyPI project description For changes that happened prior to v0.18.1, please consult the closed PRs, diff --git a/README.rst b/README.rst index d3ca4c74b..d3e65f665 100644 --- a/README.rst +++ b/README.rst @@ -8,6 +8,8 @@ pyjanitor .. image:: https://mybinder.org/badge_logo.svg :target: https://mybinder.org/v2/gh/ericmjl/pyjanitor/dev +.. pypi-doc + ``pyjanitor`` is a Python implementation of the R package `janitor`_, and provides a clean API for cleaning data. @@ -46,6 +48,8 @@ Inspired by the ease-of-use and expressiveness of the ``dplyr`` package of the R statistical language ecosystem, we have evolved ``pyjanitor`` into a language for expressing the data processing DAG for ``pandas`` users. +.. pypi-doc + To accomplish this, actions for which we would need to invoke imperative-style statements, can be replaced with method chains that allow one to read off the logical order of actions taken. @@ -145,6 +149,8 @@ Installation ``pyjanitor`` requires Python 3.6+. +.. pypi-doc + Functionality ------------- @@ -164,6 +170,8 @@ Current functionality includes: - Syntactic sugar for filtering the dataframe based on queries on a column - Experimental submodules for finance, biology, chemistry, and engineering +.. pypi-doc + API --- diff --git a/setup.py b/setup.py index e7f2c1e84..606f051ff 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,6 @@ +import re +from pathlib import Path + from setuptools import setup @@ -6,6 +9,36 @@ def requirements(): return f.read() +def generate_long_description() -> str: + """ + Extra chunks from README for PyPI description. + + Target chunks must be contained within `.. pypi-doc` pair comments, + so there must be an even number of comments in README. + + :returns: Extracted description from README + + """ + # Read the contents of README file + this_directory = Path(__file__).parent + with open(this_directory / "README.rst", encoding="utf-8") as f: + readme = f.read() + + # Find pypi-doc comments in README + indices = [m.start() for m in re.finditer(".. pypi-doc", readme)] + assert ( + len(indices) % 2 == 0 + ), "Odd number of `.. pypi-doc` comments in README" + + # Loop through pairs of comments and save text between pairs + long_description = "" + for i in range(0, len(indices), 2): + start_index = indices[i] + 11 + end_index = indices[i + 1] + long_description += readme[start_index:end_index] + return long_description + + setup( name="pyjanitor", version="0.18.0", @@ -16,4 +49,6 @@ def requirements(): packages=["janitor"], install_requires=requirements(), python_requires=">=3.6", + long_description=generate_long_description(), + long_description_content_type="text/x-rst", )