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

Write changelog in markdown using MyST #941

Merged
merged 8 commits into from
Feb 22, 2021
Merged

Write changelog in markdown using MyST #941

merged 8 commits into from
Feb 22, 2021

Conversation

weiji14
Copy link
Member

@weiji14 weiji14 commented Feb 20, 2021

Description of proposed changes

MyST (Markedly Structured Text) allows us to write Sphinx documentation entirely in markdown (technically using Commonmark). I.e. think ReST (Restructured Text) but in Markdown! MyST is a fairly young project (first published PyPI release on 6 Mar 2020), but it looks pretty awesome already!

This MyST parser should address @seisman's comment at #885 (comment) on the pain of having to convert the markdown changelog generated by Release Drafter into ReST syntax. In other words, we should be able to just copy and paste things directly from https://github.com/GenericMappingTools/pygmt/releases, all in markdown!

Documentation preview is at https://pygmt-git-myst-changelog.gmt.vercel.app/changes.html. This should look pretty much the same as https://www.pygmt.org/v0.3.0/changes.html (point out any inconsistencies if you spot any).

TODO:

Fixes #885, companion PR to #907.

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If adding new functionality, add an example to docstrings or tutorials.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash commands are:

  • /format: automatically format and lint the code
  • /test-gmt-dev: run full tests on the latest GMT development version

MyST (Markedly Structured Text) for writing Sphinx docs in markdown!
Following the installation guide of
[myst-parser](https://github.com/executablebooks/myst-parser) at
https://myst-parser.readthedocs.io/en/v0.13.5/using/intro.html.
Convert ReST syntax `doc/changes.rst` to MyST syntax `doc/changes.md`.
Mostly changing the GitHub URLs from into the nicer markdown format
Modified template at release-drafter.yml such that:

- A h2 title (##) is used for each Release vX.Y.Z header.
- Alt text for DOI button is more descriptive with version info
@weiji14 weiji14 added the documentation Improvements or additions to documentation label Feb 20, 2021
@weiji14 weiji14 added this to the 0.3.1 milestone Feb 20, 2021
.github/release-drafter.yml Outdated Show resolved Hide resolved
@@ -15,16 +15,19 @@ categories:
label: 'deprecation'
exclude-labels:
- 'skip-changelog'
category-template: '### $TITLE'
Copy link
Member Author

@weiji14 weiji14 Feb 21, 2021

Choose a reason for hiding this comment

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

Need help to find a way to make the subheaders (e.g. for v0.2.1 enhancements) a proper permalink. I.e. something like https://pygmt-git-myst-changelog.gmt.vercel.app/changes.html#v0-2-1-enhancements instead of https://pygmt-git-myst-changelog.gmt.vercel.app/changes.html#id3

Copy link
Member

Choose a reason for hiding this comment

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

It seems commonmark still doesn't support anchors for headers, so maybe we can do nothing here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

The autosectionlabel_prefix_document configuration variable can be used to make headings which appear multiple times but in different documents unique.

Useful for avoiding ambiguity when the same section heading appears in different documents.

I don't think it works for us.

Copy link
Member

Choose a reason for hiding this comment

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

@weiji14 As we have no solution for the custom anchors, do you think we should not use h3 headers, but just use bold headings, i.e., use **Documentation**, not ### Documentation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Would stick with h3 headers. Even without the permalink anchors, it'll still be easier for users to navigate quickly to the subsection on the sidebar:

Changelog subsections in navbar

And people could still point to the v0.3.0 highlights using https://www.pygmt.org/v0.3.0/changes.html#highlights, and so on for v0.4.0 and beyond.

@seisman
Copy link
Member

seisman commented Feb 21, 2021

Why not using recommonmark (https://www.sphinx-doc.org/en/master/usage/markdown.html)?

@weiji14
Copy link
Member Author

weiji14 commented Feb 21, 2021

Why not using recommonmark (https://www.sphinx-doc.org/en/master/usage/markdown.html)?

The markdown-it parser used in MyST is about two times faster than the commonmark_py parser used in recommonmark (see https://markdown-it-py.readthedocs.io/en/latest/other.html#performance). Also because I didn't know about Recommonmark, though MyST does seem better documented and actively maintained?

See also https://stackoverflow.com/questions/2471804/using-sphinx-with-markdown-instead-of-rst

@seisman
Copy link
Member

seisman commented Feb 21, 2021

Why not using recommonmark (sphinx-doc.org/en/master/usage/markdown.html)?

The markdown-it parser used in MyST is about two times faster than the commonmark_py parser used in recommonmark (see markdown-it-py.readthedocs.io/en/latest/other.html#performance). Also because I didn't know about Recommonmark, though MyST does seem better documented and actively maintained?

See also stackoverflow.com/questions/2471804/using-sphinx-with-markdown-instead-of-rst

Fair enough.

.github/release-drafter.yml Show resolved Hide resolved
.github/release-drafter.yml Outdated Show resolved Hide resolved
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Order is now "Highlights", "New Features",
"Enhancements", "Deprecations", "Bug Fixes",
"Documentation", and "Maintenance".
Copy link
Member Author

@weiji14 weiji14 left a comment

Choose a reason for hiding this comment

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

The autosectionlabel_prefix_document configuration variable can be used to make headings which appear multiple times but in different documents unique.

Useful for avoiding ambiguity when the same section heading appears in different documents.

I don't think it works for us.

Ok, this PR is ready for final review @GenericMappingTools/python-maintainers. Sorry that the changes.rst to changes.md rename doesn't have a nice diff, but you can preview things at https://pygmt-git-myst-changelog.gmt.vercel.app/changes.html. The permalink/anchor issue mentioned at #941 (comment) is fairly minor so I'll just let it be.

Comment on lines -8 to -15
- title: 'Documentation'
label: 'documentation'
- title: 'Deprecations'
label: 'deprecation'
- title: 'Bug Fixes'
label: 'bug'
- title: 'Documentation'
label: 'documentation'
- title: 'Maintenance'
label: 'maintenance'
- title: 'Deprecations'
label: 'deprecation'
Copy link
Member Author

Choose a reason for hiding this comment

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

Categories have been reordered following #885 (comment). Do we want to reorder things in the previous release changelogs (i.e. v0.1.0 to v0.3.0) or just keep them as they were?

Copy link
Member

Choose a reason for hiding this comment

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

Categories have been reordered following #885 (comment).

Looks good to me.

Do we want to reorder things in the previous release changelogs (i.e. v0.1.0 to v0.3.0) or just keep them as they were?

No need to reorder the old entries.

@weiji14 weiji14 marked this pull request as ready for review February 22, 2021 08:46
@weiji14 weiji14 requested a review from a team February 22, 2021 08:46
@seisman
Copy link
Member

seisman commented Feb 22, 2021

It seems that recent release-drafter releases have more features, for example version-resolver probably can determine if the next version is v0.3.1 or v0.4.0.

@seisman
Copy link
Member

seisman commented Feb 22, 2021

It seems that recent release-drafter releases have more features, for example version-resolver probably can determine if the next version is v0.3.1 or v0.4.0.

If I understand it correctly, the following setting means that if any PR labeled with "feature" or "enhancement" is merged into master branch, the next version will be a minor release (i.e., v0.4.0), otherwise it's a patch release (i.e., v0.3.1). However, sometimes we merge PRs with "enhancement" but may don't want to bump the minor version (e.g., #952).

version-resolver:
  minor:
    labels:
      - 'feature'
      - 'enhancement'
  default: patch

@weiji14
Copy link
Member Author

weiji14 commented Feb 22, 2021

It seems that recent release-drafter releases have more features, for example version-resolver probably can determine if the next version is v0.3.1 or v0.4.0.

Oo, that does look fancy! But let's leave that to a separate Pull Request as we'll need to document that '$RESOLVED_VERSION` feature in MAINTENANCE.md too. Or I can include it in #907.

Copy link
Member

@seisman seisman left a comment

Choose a reason for hiding this comment

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

This PR is good to merge. We can change any settings in future PRs.

@weiji14 weiji14 merged commit c93517a into master Feb 22, 2021
@weiji14 weiji14 deleted the myst-changelog branch February 22, 2021 23:09
sixy6e pushed a commit to sixy6e/pygmt that referenced this pull request Dec 21, 2022
* Install myst-parser and add it to sphinx extension list

MyST (Markedly Structured Text) for writing Sphinx docs in markdown!
Following the installation guide of
[myst-parser](https://github.com/executablebooks/myst-parser) at
https://myst-parser.readthedocs.io/en/v0.13.5/using/intro.html.

* Rename doc/changes.rst to doc/changes.md and convert to markdown

Convert ReST syntax `doc/changes.rst` to MyST syntax `doc/changes.md`.
Mostly changing the GitHub URLs from into the nicer markdown format
Modified template at release-drafter.yml such that:

- A h2 title (##) is used for each Release vX.Y.Z header.
- Alt text for DOI button is more descriptive with version info

* Use h3 html titles for sub-headings
* Let release drafter automatically produce markdown URLs to Pull Requests
* Reorder categories in release note

Order is now "Highlights", "New Features",
"Enhancements", "Deprecations", "Bug Fixes",
"Documentation", and "Maintenance".

Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update the release drafter workflow and configurations
2 participants