-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add CLI option to render package README. #271
Conversation
@tillahoffmann Thanks! We removed the documented example of using the CLI in #197 - since the interface doesn't currently render Markdown. Before introducing a CLI that we'd expect to support, would you consider adding that behavior? Please also update your branch from |
if not content_format: | ||
content_type = message.get("Description-Content-Type", "text/x-rst") | ||
if content_type == "text/x-rst": | ||
content_format = "rst" | ||
elif content_type == "text/markdown": | ||
content_format = "md" | ||
elif content_type == "text/plain": | ||
content_format = "txt" | ||
else: | ||
raise ValueError(f"invalid content type {content_type} for package " | ||
"`long_description`") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part isn't particularly well tested because we'd have to install a bunch of dummy packages for the tests to run. Or we could mock out get_distribution
to return the right data (not quite as reliable a test if we get the mocking wrong).
Hm, interesting, any idea why pypy might fail while the others succeed? I can also mock out writing to the file rather than using a temporary directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working through this!
Thanks for the speedy review! |
This PR adds an option
--package
to the CLI such that theREADME
of a package can be rendered as it would onpypi.org
. Using this option, package authors can previewREADME
s in addition to checking their validity usingtwine check
. Rendering theREADME
based on the package metadata is important because a number of packages strip out roles and directives that are not supported bypypi.org
in theirsetup.py
. Publishing totest.pypi.org
, as discussed in pypa/twine#875, is an alternative, but having a local preview would be desirable (at least for myself). This PR also adds tests for the existing CLI.