Skip to content

Commit

Permalink
Merge pull request #3556 from fonttools/check-rst-syntax-before-release
Browse files Browse the repository at this point in the history
Check for reStructuredText syntax errors in README+NEWS while running release command
  • Loading branch information
anthrotype committed Jun 3, 2024
2 parents 308b449 + 162cacb commit 5e6b12d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ How to make a new release
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
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``
or ``--minor`` to bump respectively the first or second digit.
This bumps the package version string, extracts the changes since the latest
Expand Down
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ tox>=2.5
bump2version>=0.5.6
sphinx>=1.5.5
mypy>=0.782
readme_renderer[md]>=43.0

# Pin black as each version could change formatting, breaking CI randomly.
black==24.4.2
15 changes: 14 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from glob import glob
from setuptools import setup, find_packages, Command, Extension
from setuptools.command.build_ext import build_ext as _build_ext
from setuptools.errors import SetupError
from distutils import log
from distutils.util import convert_path
import subprocess as sp
Expand All @@ -33,7 +34,7 @@ def doraise_py_compile(file, cfile=None, dfile=None, doraise=False):
setup_requires.append("wheel")

if {"release"}.intersection(sys.argv):
setup_requires.append("bump2version")
setup_requires.extend(["bump2version", "readme_renderer"])

try:
__import__("cython")
Expand Down Expand Up @@ -266,7 +267,19 @@ def finalize_options(self):
raise DistutilsOptionError("--major/--minor are mutually exclusive")
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):
self.check_long_description_syntax()

if self.part is not None:
log.info("bumping '%s' version" % self.part)
self.bumpversion(self.part, commit=False)
Expand Down

0 comments on commit 5e6b12d

Please sign in to comment.