Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-41872: Parse docstrings with ast instead of string manipulation #127520

Merged
merged 29 commits into from
Jan 8, 2025

Conversation

srinivasreddy
Copy link
Contributor

@srinivasreddy srinivasreddy commented Dec 2, 2024

gh-41872: Instead of manual parsing of docstrings, use ast to parse both single quote docstrings and double quote docstrings

@srinivasreddy srinivasreddy changed the title gh-41872: Instead of manual parsing of doc strongs, use ast.literal_eval to parse both single quote doc strings, and double quote doc strings gh-41872: Instead of manual parsing of doc strings, use ast.literal_eval to parse both single quote doc strings, and double quote doc strings Dec 2, 2024
@srinivasreddy srinivasreddy marked this pull request as ready for review December 2, 2024 16:29
Lib/pydoc.py Show resolved Hide resolved
Lib/pydoc.py Outdated Show resolved Hide resolved
@srinivasreddy srinivasreddy changed the title gh-41872: Instead of manual parsing of doc strings, use ast.literal_eval to parse both single quote doc strings, and double quote doc strings gh-41872: Instead of manual parsing of doc strings, use ast to parse both single quote doc strings, and double quote doc strings Dec 3, 2024
@srinivasreddy srinivasreddy requested a review from merwok December 3, 2024 13:50
@srinivasreddy
Copy link
Contributor Author

I have changed the solution, please let me know your thoughts on it? @merwok

@merwok
Copy link
Member

merwok commented Dec 4, 2024

Please avoid force pushes, as indicated in the devguide 🙂

Lib/pydoc.py Outdated Show resolved Hide resolved
Lib/pydoc.py Outdated Show resolved Hide resolved
@merwok merwok changed the title gh-41872: Instead of manual parsing of doc strings, use ast to parse both single quote doc strings, and double quote doc strings gh-41872: Parse docstrings with ast instead of string manipulation Dec 4, 2024
Lib/pydoc.py Outdated Show resolved Hide resolved
Lib/pydoc.py Outdated Show resolved Hide resolved
Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a blurb entry, by the way.

srinivasreddy and others added 3 commits December 18, 2024 22:56
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@srinivasreddy
Copy link
Contributor Author

@serhiy-storchaka Thanks for the suggestions I was in a hurry , left for the day without fixing them .

@srinivasreddy srinivasreddy marked this pull request as draft January 6, 2025 14:31
@srinivasreddy srinivasreddy marked this pull request as ready for review January 8, 2025 06:32
@srinivasreddy
Copy link
Contributor Author

@serhiy-storchaka Thanks for the commit.

@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) January 8, 2025 10:12
@serhiy-storchaka serhiy-storchaka merged commit 474e419 into python:main Jan 8, 2025
38 checks passed
@miss-islington-app
Copy link

Thanks @srinivasreddy for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 8, 2025
… in pydoc (pythonGH-127520)

It now supports docstrings with single quotes, escape sequences,
raw string literals, and other Python syntax.

(cherry picked from commit 474e419)

Co-authored-by: Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్  రెడ్డి) <thatiparthysreenivas@gmail.com>
Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Jan 8, 2025

GH-128620 is a backport of this pull request to the 3.13 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 8, 2025
… in pydoc (pythonGH-127520)

It now supports docstrings with single quotes, escape sequences,
raw string literals, and other Python syntax.

(cherry picked from commit 474e419)

Co-authored-by: Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్  రెడ్డి) <thatiparthysreenivas@gmail.com>
Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Jan 8, 2025
@bedevere-app
Copy link

bedevere-app bot commented Jan 8, 2025

GH-128621 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Jan 8, 2025
@srinivasreddy srinivasreddy deleted the gh-41872 branch January 8, 2025 11:03
serhiy-storchaka added a commit that referenced this pull request Jan 8, 2025
…e in pydoc (GH-127520) (GH-128620)

It now supports docstrings with single quotes, escape sequences,
raw string literals, and other Python syntax.

(cherry picked from commit 474e419)

Co-authored-by: Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్  రెడ్డి) <thatiparthysreenivas@gmail.com>
Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this pull request Jan 8, 2025
…e in pydoc (GH-127520) (GH-128621)

It now supports docstrings with single quotes, escape sequences,
raw string literals, and other Python syntax.

(cherry picked from commit 474e419)

Co-authored-by: Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్  రెడ్డి) <thatiparthysreenivas@gmail.com>
Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants