Merge pull request #3556 from fonttools/check-rst-syntax-before-release

Check for reStructuredText syntax errors in README+NEWS while running release command
This commit is contained in:
Cosimo Lupo 2024-06-03 12:18:23 +01:00 committed by GitHub
commit 5e6b12d12f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 2 deletions

View File

@ -232,7 +232,8 @@ How to make a new release
2) Use semantic versioning to decide whether the new release will be a 'major', 2) Use semantic versioning to decide whether the new release will be a 'major',
'minor' or 'patch' release. It's usually one of the latter two, depending on 'minor' or 'patch' release. It's usually one of the latter two, depending on
whether new backward compatible APIs were added, or simply some bugs were fixed. whether new backward compatible APIs were added, or simply some bugs were fixed.
3) Run ``python setup.py release`` command from the tip of the ``main`` branch. 3) From inside a venv, first do ``pip install -r dev-requirements.txt``, then run
the ``python setup.py release`` command from the tip of the ``main`` branch.
By default this bumps the third or 'patch' digit only, unless you pass ``--major`` By default this bumps the third or 'patch' digit only, unless you pass ``--major``
or ``--minor`` to bump respectively the first or second digit. or ``--minor`` to bump respectively the first or second digit.
This bumps the package version string, extracts the changes since the latest This bumps the package version string, extracts the changes since the latest

View File

@ -3,6 +3,7 @@ tox>=2.5
bump2version>=0.5.6 bump2version>=0.5.6
sphinx>=1.5.5 sphinx>=1.5.5
mypy>=0.782 mypy>=0.782
readme_renderer[md]>=43.0
# Pin black as each version could change formatting, breaking CI randomly. # Pin black as each version could change formatting, breaking CI randomly.
black==24.4.2 black==24.4.2

View File

@ -8,6 +8,7 @@ from os.path import isfile, join as pjoin
from glob import glob from glob import glob
from setuptools import setup, find_packages, Command, Extension from setuptools import setup, find_packages, Command, Extension
from setuptools.command.build_ext import build_ext as _build_ext from setuptools.command.build_ext import build_ext as _build_ext
from setuptools.errors import SetupError
from distutils import log from distutils import log
from distutils.util import convert_path from distutils.util import convert_path
import subprocess as sp import subprocess as sp
@ -33,7 +34,7 @@ if {"bdist_wheel"}.intersection(sys.argv):
setup_requires.append("wheel") setup_requires.append("wheel")
if {"release"}.intersection(sys.argv): if {"release"}.intersection(sys.argv):
setup_requires.append("bump2version") setup_requires.extend(["bump2version", "readme_renderer"])
try: try:
__import__("cython") __import__("cython")
@ -266,7 +267,19 @@ class release(Command):
raise DistutilsOptionError("--major/--minor are mutually exclusive") raise DistutilsOptionError("--major/--minor are mutually exclusive")
self.part = "major" if self.major else "minor" if self.minor else None self.part = "major" if self.major else "minor" if self.minor else None
def check_long_description_syntax(self):
import readme_renderer.rst
result = readme_renderer.rst.render(long_description, stream=sys.stderr)
if result is None:
raise SetupError(
"`long_description` has syntax errors in markup"
" and would not be rendered on PyPI."
)
def run(self): def run(self):
self.check_long_description_syntax()
if self.part is not None: if self.part is not None:
log.info("bumping '%s' version" % self.part) log.info("bumping '%s' version" % self.part)
self.bumpversion(self.part, commit=False) self.bumpversion(self.part, commit=False)