From e609984f5b6089474c5c5b67ee10c94556e5cf02 Mon Sep 17 00:00:00 2001 From: CrossNox Date: Thu, 11 Aug 2022 12:22:38 -0300 Subject: [PATCH] Deploy: 0.3.3 (#54) * force mistune to version 0.8.4 (#43) closes #42 closes #40 * pin * Remove calls to ErrorString and SafeString removed in docutils 0.19 (#49) * remove python2 * fix pipelines * fix linter pipeline * set language for sphinx * fix tests pipeline * fix pipeline, set docutiles dependency * why did I change this * bump Co-authored-by: Ezequiel Rosas Co-authored-by: Ian Glen --- .bumpversion.cfg | 2 +- .github/workflows/linter.yml | 8 ++- .github/workflows/sphinx_building.yml | 4 +- .github/workflows/tests.yml | 2 +- .pre-commit-config.yaml | 20 ++----- CHANGES.md | 4 ++ docs/conf.py | 79 ++++++++++++++------------- m2r2.py | 28 +++++++--- mypy.ini | 4 ++ noxfile.py | 6 +- requirements-dev.txt | 2 +- setup.py | 9 +-- 12 files changed, 85 insertions(+), 83 deletions(-) create mode 100644 mypy.ini diff --git a/.bumpversion.cfg b/.bumpversion.cfg index cb82e18..ecc696f 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.3.2 +current_version = 0.3.3 commit = False tag = False diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 94ea044..dedd682 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -3,7 +3,7 @@ name: Run linters and formatters on: [push] jobs: - deploy: + lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -11,7 +11,9 @@ jobs: uses: actions/setup-python@v2 with: python-version: 3.7 - - name: Install dependencies + - name: Install nox run: pip install nox + - name: Install dependencies + run: pip install -r requirements-dev.txt - name: Run cop session - run: nox --sessions cop \ No newline at end of file + run: nox --sessions cop diff --git a/.github/workflows/sphinx_building.yml b/.github/workflows/sphinx_building.yml index 89767e1..d72b007 100644 --- a/.github/workflows/sphinx_building.yml +++ b/.github/workflows/sphinx_building.yml @@ -3,7 +3,7 @@ name: Check sphinx building on: [push] jobs: - deploy: + sphinx_building: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -16,4 +16,4 @@ jobs: - name: Build with an old sphinx version run: nox --sessions test_sphinx_old_build - name: Build with latest sphinx version - run: nox --sessions test_sphinx_build \ No newline at end of file + run: nox --sessions test_sphinx_build diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4fbe327..cdad138 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.5, 3.6, 3.7, 3.8, 3.9, '3.10.0-beta.4'] + python-version: [3.7, 3.8, 3.9, "3.10"] steps: - uses: actions/checkout@v2 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c25438e..1e55a3f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,9 +1,11 @@ repos: -- repo: git://github.com/pre-commit/pre-commit-hooks - rev: v2.5.0 - hooks: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: - id: trailing-whitespace - id: requirements-txt-fixer +- repo: local + hooks: - id: flake8 name: flake8 entry: flake8 @@ -11,9 +13,6 @@ repos: types: [python] args: [--max-line-length=88] exclude: (docs|tests)/* -- repo: https://github.com/pre-commit/mirrors-isort - rev: v5.0.6 - hooks: - id: isort name: isort entry: isort @@ -21,9 +20,6 @@ repos: types: [python] args: [--multi-line=3,--trailing-comma,--force-grid-wrap=0,--use-parentheses,--line-width=88] exclude: (docs|tests)/* -- repo: https://github.com/psf/black - rev: 19.10b0 - hooks: - id: black name: black entry: black @@ -32,18 +28,12 @@ repos: args: [] language_version: python3.7 exclude: (docs|tests)/* -- repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.770 - hooks: - id: mypy name: mypy entry: mypy language: system types: [python] exclude: (tests|docs)/* -- repo: https://github.com/pre-commit/mirrors-pylint - rev: v2.4.4 - hooks: - id: pylint name: pylint entry: pylint diff --git a/CHANGES.md b/CHANGES.md index 3278971..62f4ba0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +### Version 0.3.3 (2022-08-11) +* Drop support for all python versions prior to 3.7 +* Upgrade to docutils 0.19 + ### Version 0.3.2 (2021-12-10) * Pin mistune version diff --git a/docs/conf.py b/docs/conf.py index 7b5d031..708eb52 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -13,8 +13,10 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys import os +import sys + +from m2r2 import __version__ as __m2r2_version__ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) @@ -32,24 +34,23 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.mathjax', - 'sphinx.ext.viewcode', - 'sphinx.ext.githubpages', - 'm2r2', + "sphinx.ext.autodoc", + "sphinx.ext.mathjax", + "sphinx.ext.viewcode", + "sphinx.ext.githubpages", + "m2r2", ] -from m2r2 import __version__ as __m2r2_version__ -suppress_warnings = ['image.nonlocal_uri'] +suppress_warnings = ["image.nonlocal_uri"] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # source_suffix = ['.rst', '.md'] -source_suffix = '.md' +source_suffix = ".md" no_underscore_emphasis = True m2r_parse_relative_links = True m2r_anonymous_references = False @@ -59,12 +60,12 @@ # source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = 'M2R2' -copyright = '2016, Hiroyuki Takagi' -author = 'Hiroyuki Takagi' +project = "M2R2" +copyright = "2016, Hiroyuki Takagi" +author = "Hiroyuki Takagi" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -80,7 +81,7 @@ # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = "en" # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: @@ -91,7 +92,7 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] # The reST default role (used for this markup: `text`) to use for all # documents. @@ -109,7 +110,7 @@ # show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. # modindex_common_prefix = [] @@ -125,22 +126,22 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'alabaster' +html_theme = "alabaster" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. html_theme_options = { - 'description': 'Markdown mixed to reST', - 'github_user': 'CrossNox', - 'github_repo': 'm2r2', - 'github_banner': True, - 'github_type': 'mark', - 'github_count': False, - 'font_family': '"Charis SIL", "Noto Serif", serif', - 'head_font_family': 'Lato, sans-serif', - 'code_font_family': '"Code new roman", "Ubuntu Mono", monospace', - 'code_font_size': '1rem', + "description": "Markdown mixed to reST", + "github_user": "CrossNox", + "github_repo": "m2r2", + "github_banner": True, + "github_type": "mark", + "github_count": False, + "font_family": '"Charis SIL", "Noto Serif", serif', + "head_font_family": "Lato, sans-serif", + "code_font_family": '"Code new roman", "Ubuntu Mono", monospace', + "code_font_size": "1rem", } # Add any paths that contain custom themes here, relative to this directory. @@ -165,7 +166,7 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied @@ -183,7 +184,7 @@ # Custom sidebar templates, maps document names to template names. html_sidebars = { - '**': ['about.html', 'navigation.html', 'relations.html', 'searchbox.html',] + "**": ["about.html", "navigation.html", "relations.html", "searchbox.html",] } # Additional templates that should be rendered to pages, maps page names to @@ -232,7 +233,7 @@ # html_search_scorer = 'scorer.js' # Output file base name for HTML help builder. -htmlhelp_basename = 'M2Rdoc' +htmlhelp_basename = "M2Rdoc" # -- Options for LaTeX output --------------------------------------------- @@ -251,7 +252,7 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'M2R.tex', 'M2R Documentation', 'Hiroyuki Takagi', 'manual'), + (master_doc, "M2R.tex", "M2R Documentation", "Hiroyuki Takagi", "manual"), ] # The name of an image file (relative to this directory) to place at the top of @@ -279,7 +280,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [(master_doc, 'm2r', 'M2R Documentation', [author], 1)] +man_pages = [(master_doc, "m2r", "M2R Documentation", [author], 1)] # If true, show URL addresses after external links. # man_show_urls = False @@ -293,12 +294,12 @@ texinfo_documents = [ ( master_doc, - 'M2R', - 'M2R Documentation', + "M2R", + "M2R Documentation", author, - 'M2R', - 'One line description of project.', - 'Miscellaneous', + "M2R", + "One line description of project.", + "Miscellaneous", ), ] @@ -316,4 +317,4 @@ # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'https://docs.python.org/': None} +intersphinx_mapping = {"https://docs.python.org/": None} diff --git a/m2r2.py b/m2r2.py index 2e2eb22..e78d969 100644 --- a/m2r2.py +++ b/m2r2.py @@ -11,9 +11,8 @@ import mistune from docutils import io, nodes, statemachine, utils -from docutils.core import ErrorString from docutils.parsers import rst -from docutils.utils import SafeString, column_width +from docutils.utils import column_width from pkg_resources import get_distribution __version__ = get_distribution("m2r2").version @@ -81,9 +80,18 @@ def parse_options(): class RestBlockGrammar(mistune.BlockGrammar): - directive = re.compile(r"^( *\.\..*?)\n(?=\S)", re.DOTALL | re.MULTILINE,) - oneline_directive = re.compile(r"^( *\.\..*?)$", re.DOTALL | re.MULTILINE,) - rest_code_block = re.compile(r"^::\s*$", re.DOTALL | re.MULTILINE,) + directive = re.compile( + r"^( *\.\..*?)\n(?=\S)", + re.DOTALL | re.MULTILINE, + ) + oneline_directive = re.compile( + r"^( *\.\..*?)$", + re.DOTALL | re.MULTILINE, + ) + rest_code_block = re.compile( + r"^::\s*$", + re.DOTALL | re.MULTILINE, + ) class RestBlockLexer(mistune.BlockLexer): @@ -621,12 +629,12 @@ def run(self): raise self.severe( 'Problems with "%s" directive path:\n' 'Cannot encode input file path "%s" ' - "(wrong locale?)." % (self.name, SafeString(path)) + "(wrong locale?)." % (self.name, str(path)) ) except IOError as error: raise self.severe( 'Problems with "%s" directive path:\n%s.' - % (self.name, ErrorString(error)) + % (self.name, io.error_string(error)) ) # read from the file @@ -640,7 +648,7 @@ def run(self): rawtext = include_file.read() except UnicodeError as error: raise self.severe( - 'Problem with "%s" directive:\n%s' % (self.name, ErrorString(error)) + 'Problem with "%s" directive:\n%s' % (self.name, io.error_string(error)) ) config = self.state.document.settings.env.config @@ -676,7 +684,9 @@ def setup(app): app.add_source_parser(M2RParser) app.add_directive("mdinclude", MdInclude) metadata = dict( - version=__version__, parallel_read_safe=True, parallel_write_safe=True, + version=__version__, + parallel_read_safe=True, + parallel_write_safe=True, ) return metadata diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 0000000..461b55e --- /dev/null +++ b/mypy.ini @@ -0,0 +1,4 @@ +[mypy] + +ignore_missing_imports = True +follow_imports = skip diff --git a/noxfile.py b/noxfile.py index cd6bee8..f8acfff 100644 --- a/noxfile.py +++ b/noxfile.py @@ -8,15 +8,10 @@ @nox.session( reuse_venv=True, python=[ - "2.7", - "3.4", - "3.5", - "3.6", "3.7", "3.8", "3.9", "3.10", - "3.10.0-beta.4", "pypy", "pypy3", ], @@ -55,6 +50,7 @@ def test_sphinx_old_build(session): with tempfile.TemporaryDirectory() as tmpdirname: session.install(".") session.install("sphinx==1.7.0") + session.install("jinja2==3.0.0") session.run("sphinx-build", "-W", "-E", "-n", "-b", "html", "docs", tmpdirname) diff --git a/requirements-dev.txt b/requirements-dev.txt index 98f3b31..17c16a1 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,5 @@ -r requirements-test.txt -black==19.10b0 +black==22.3.0 bump2version==1.0.1 flake8==3.7.8 isort==4.3.21 diff --git a/setup.py b/setup.py index bb07b87..b0997ab 100644 --- a/setup.py +++ b/setup.py @@ -19,9 +19,9 @@ readme = f.read() -__version__ = "0.3.2" +__version__ = "0.3.3" -install_requires = ["mistune==0.8.4", "docutils"] +install_requires = ["mistune==0.8.4", "docutils>=0.19"] test_requirements = ["pygments"] if sys.version_info < (3, 3): test_requirements.append("mock") @@ -49,12 +49,7 @@ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9",