Docs: Don't wrap the markdown for GitHub releases#6621
Merged
nicoddemus merged 1 commit intopytest-dev:masterfrom Jan 29, 2020
hugovk:no-wrap-markdown-for-gh-release
Merged
Docs: Don't wrap the markdown for GitHub releases#6621nicoddemus merged 1 commit intopytest-dev:masterfrom hugovk:no-wrap-markdown-for-gh-release
nicoddemus merged 1 commit intopytest-dev:masterfrom
hugovk:no-wrap-markdown-for-gh-release
Conversation
Member
|
Hi @hugovk, I've tried with a more complex example and it looks good: import pypandoc
def convert_rst_to_md_before(text):
return pypandoc.convert_text(text, "md", format="rst")
def convert_rst_to_md_after(text):
return pypandoc.convert_text(text, "md", format="rst", extra_args=["--wrap=preserve"])
text = """
pytest 5.3.5 (2020-01-29)
=========================
Bug Fixes
---------
- `#6517 <https://github.com/pytest-dev/pytest/issues/6517>`_: Fix regression in pytest 5.3.4 causing an INTERNALERROR due to a wrong assertion.
- `#6517 <https://github.com/pytest-dev/pytest/issues/6517>`_: Fix regression in pytest 5.3.4
causing an INTERNALERROR due to a wrong assertion.
This also checks something else.
Also see this:
.. code-block:: python
def test():
pass
Another example.
"""
print("AFTER")
print(convert_rst_to_md_after(text))
"""
print("AFTER")
print(convert_rst_to_md_after(text))Render: https://gist.github.com/nicoddemus/83a3ef2c6548f481a1d9fe7787be396c So thanks a lot for looking into this. 👍 |
nicoddemus
approved these changes
Jan 29, 2020
Contributor
|
@nicoddemus this was waiting for an update AFAICT. |
Member
Author
|
Sorry, I forgot to push that last change. I can do it tomorrow or it's a simple thing if you'd like to do it. Thanks! |
Contributor
|
@hugovk doesn't matter that much/enough I guess. |
Member
Ouch my bad! 🤦♂ Will open a new PR. |
nicoddemus
added a commit
to nicoddemus/pytest
that referenced
this pull request
Jan 29, 2020
Follow up to pytest-dev#6621 after premature merge
Member
|
Done in #6624. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for submitting a PR, your contribution is really appreciated!
Here is a quick checklist that should be present in PRs.
masterbranch for bug fixes, documentation updates and trivial changes.featuresbranch for new features, improvements, and removals/deprecations.Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:
[n/a?] Create a new changelog file in the
changelogfolder, with a name like<ISSUE NUMBER>.<TYPE>.rst. See changelog/README.rst for details.Write sentences in the past or present tense, examples:
Also make sure to end the sentence with a
..Add yourself to
AUTHORSin alphabetical order.What happens
Releases on GitHub look like this, with oddly-wrapped text (eg. https://github.com/pytest-dev/pytest/releases/tag/5.3.5):
In edit mode, it wraps like this, but of course a lot of that link markdown isn't visible to the end user, and GitHub is respecting the newlines here:
https://github.com/pytest-dev/pytest/releases/edit/5.3.5
Why
I understand
scripts/publish-gh-release-notes.pyis run to convert reStructuredText into Markdown, and post it in the GitHub release. It takes RST from the changelog:https://github.com/pytest-dev/pytest/blob/master/doc/en/changelog.rst#pytest-535-2020-01-29
Here there's no newlines, in the plain RST, nor the rendered output.
The conversion is made using pypandoc:
The fix
pypandoc.convert_textdoesn't have any explicit line wrapping arguments, but you can useextra_argsto pass to the underlying pandoc tool:https://pandoc.org/MANUAL.html
And so:
Demo
I've not tested this using
scripts/publish-gh-release-notes.pyand I don't think there's tests for these helper scripts, so here's a short demo:Output:
A preview of this unwrapped text: