diff --git a/docs/conf.py b/docs/conf.py index 35d913465..e2fc94b82 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -13,36 +13,9 @@ import os import sys -import sphinx - sys.path.insert(0, os.path.abspath('..')) -# -- Monkeypatches ----------------------------------------------------------- - -def _monkeypatch(cls): - """Decorator to monkey-patch methods.""" - def decorator(func): - method = func.__name__ - old = getattr(cls, method) - setattr( - cls, - method, - lambda inst, *args, **kwargs: func(inst, old, *args, **kwargs), - ) - return decorator - - -# workaround until https://github.com/miyakogi/m2r/pull/55 is merged -@_monkeypatch(sphinx.registry.SphinxComponentRegistry) -def add_source_parser(self, _old_add_source_parser, *args, **kwargs): - """This function changed in sphinx v3.0, we need to fix it back.""" - # signature is (parser: "Type[Parser]", override: bool = False), - # but m2r expects the removed (str, parser: Type[Parser], **kwargs). - if not isinstance(args[0], str): - return _old_add_source_parser(self, *args, **kwargs) - - # -- Project information ----------------------------------------------------- def _get_project_meta(): @@ -56,7 +29,7 @@ def _get_project_meta(): pkg_meta = _get_project_meta() project = str(pkg_meta['name']) -copyright = '2019, dry-python team' # noqa: WPS125 +copyright = '2021, dry-python team' # noqa: WPS125 author = 'dry-python team' # The short X.Y version @@ -79,8 +52,8 @@ def _get_project_meta(): 'sphinx.ext.autosummary', 'sphinx.ext.napoleon', - # Used to include .md files: - 'm2r', + # Used to parse .md files: + 'myst_parser', # Used to insert typehints into the final docs: 'sphinx_autodoc_typehints', diff --git a/docs/index.rst b/docs/index.rst index 241c12057..e2e315890 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,4 +1,5 @@ -.. mdinclude:: ../README.md +.. include:: ../README.md + :parser: myst_parser.sphinx_ Contents -------- diff --git a/docs/pages/changelog.rst b/docs/pages/changelog.rst index ab37940f4..997469615 100644 --- a/docs/pages/changelog.rst +++ b/docs/pages/changelog.rst @@ -1 +1,2 @@ -.. mdinclude:: ../../CHANGELOG.md +.. include:: ../../CHANGELOG.md + :parser: myst_parser.sphinx_ diff --git a/docs/requirements.txt b/docs/requirements.txt index bf7b832b8..990f87d57 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -6,8 +6,7 @@ sphinx_autodoc_typehints==1.12.0 sphinxcontrib-mermaid==0.7.1 sphinx-typlog-theme==0.8.0 sphinx-hoverxref==0.7b1 -recommonmark==0.7.1 -m2r==0.2.1 +myst-parser==0.15.2 tomlkit==0.7.2 pygments==2.10.0 diff --git a/poetry.lock b/poetry.lock index 05369c3ee..bd8be1c74 100644 --- a/poetry.lock +++ b/poetry.lock @@ -273,7 +273,7 @@ stevedore = "*" [[package]] name = "docutils" -version = "0.16" +version = "0.17.1" description = "Docutils -- Python Documentation Utilities" category = "dev" optional = false @@ -721,16 +721,24 @@ win32-setctime = {version = ">=1.0.0", markers = "sys_platform == \"win32\""} dev = ["codecov (>=2.0.15)", "colorama (>=0.3.4)", "flake8 (>=3.7.7)", "tox (>=3.9.0)", "tox-travis (>=0.12)", "pytest (>=4.6.2)", "pytest-cov (>=2.7.1)", "Sphinx (>=2.2.1)", "sphinx-autobuild (>=0.7.1)", "sphinx-rtd-theme (>=0.4.3)", "black (>=19.10b0)", "isort (>=5.1.1)"] [[package]] -name = "m2r" -version = "0.2.1" -description = "Markdown and reStructuredText in a single file." +name = "markdown-it-py" +version = "1.1.0" +description = "Python port of markdown-it. Markdown parsing, done right!" category = "dev" optional = false -python-versions = "*" +python-versions = "~=3.6" [package.dependencies] -docutils = "*" -mistune = "*" +attrs = ">=19,<22" +typing-extensions = {version = ">=3.7.4", markers = "python_version < \"3.8\""} + +[package.extras] +code_style = ["pre-commit (==2.6)"] +compare = ["commonmark (>=0.9.1,<0.10.0)", "markdown (>=3.2.2,<3.3.0)", "mistletoe-ebp (>=0.10.0,<0.11.0)", "mistune (>=0.8.4,<0.9.0)", "panflute (>=1.12,<2.0)"] +linkify = ["linkify-it-py (>=1.0,<2.0)"] +plugins = ["mdit-py-plugins"] +rtd = ["myst-nb (==0.13.0a1)", "pyyaml", "sphinx (>=2,<4)", "sphinx-copybutton", "sphinx-panels (>=0.4.0,<0.5.0)", "sphinx-book-theme"] +testing = ["coverage", "psutil", "pytest (>=3.6,<4)", "pytest-benchmark (>=3.2,<4.0)", "pytest-cov", "pytest-regressions"] [[package]] name = "markupsafe" @@ -774,12 +782,20 @@ optional = false python-versions = "*" [[package]] -name = "mistune" -version = "0.8.4" -description = "The fastest markdown parser in pure Python" +name = "mdit-py-plugins" +version = "0.2.8" +description = "Collection of plugins for markdown-it-py" category = "dev" optional = false -python-versions = "*" +python-versions = "~=3.6" + +[package.dependencies] +markdown-it-py = ">=1.0,<2.0" + +[package.extras] +code_style = ["pre-commit (==2.6)"] +rtd = ["myst-parser (==0.14.0a3)", "sphinx-book-theme (>=0.1.0,<0.2.0)"] +testing = ["coverage", "pytest (>=3.6,<4)", "pytest-cov", "pytest-regressions"] [[package]] name = "more-itertools" @@ -815,6 +831,28 @@ category = "dev" optional = false python-versions = "*" +[[package]] +name = "myst-parser" +version = "0.15.2" +description = "An extended commonmark compliant parser, with bridges to docutils & sphinx." +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +docutils = ">=0.15,<0.18" +jinja2 = "*" +markdown-it-py = ">=1.0.0,<2.0.0" +mdit-py-plugins = ">=0.2.8,<0.3.0" +pyyaml = "*" +sphinx = ">=3.1,<5" + +[package.extras] +code_style = ["pre-commit (>=2.12,<3.0)"] +linkify = ["linkify-it-py (>=1.0,<2.0)"] +rtd = ["ipython", "sphinx-book-theme (>=0.1.0,<0.2.0)", "sphinx-panels (>=0.5.2,<0.6.0)", "sphinxcontrib-bibtex (>=2.1,<3.0)", "sphinxext-rediraffe (>=0.2,<1.0)", "sphinxcontrib.mermaid (>=0.6.3,<0.7.0)", "sphinxext-opengraph (>=0.4.2,<0.5.0)"] +testing = ["beautifulsoup4", "coverage", "docutils (>=0.17.0,<0.18.0)", "pytest (>=3.6,<4)", "pytest-cov", "pytest-regressions"] + [[package]] name = "nitpick" version = "0.27.0" @@ -1540,7 +1578,7 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=1.2.3)", "pytest-flake8", "pyt [metadata] lock-version = "1.1" python-versions = "^3.7" -content-hash = "9215a55e3b0aa4836d96bf6325c403a9890d53eeb8512adc9eaf35cb2b8c0034" +content-hash = "327d482cab4a9dc93e6e1d746ed553ccc30d15e4594f5c0379c1591f75e0b20d" [metadata.files] alabaster = [ @@ -1745,8 +1783,8 @@ doc8 = [ {file = "doc8-0.9.1.tar.gz", hash = "sha256:0e967db31ea10699667dd07790f98cf9d612ee6864df162c64e4954a8e30f90d"}, ] docutils = [ - {file = "docutils-0.16-py2.py3-none-any.whl", hash = "sha256:0c5b78adfbf7762415433f5515cd5c9e762339e23369dbe8000d84a4bf4ab3af"}, - {file = "docutils-0.16.tar.gz", hash = "sha256:c2de3a60e9e7d07be26b7f2b00ca0309c207e06c100f9cc2a94931fc75a478fc"}, + {file = "docutils-0.17.1-py2.py3-none-any.whl", hash = "sha256:cf316c8370a737a022b72b56874f6602acf974a37a9fba42ec2876387549fc61"}, + {file = "docutils-0.17.1.tar.gz", hash = "sha256:686577d2e4c32380bb50cbb22f575ed742d58168cee37e99117a854bcd88f125"}, ] dparse = [ {file = "dparse-0.5.1-py3-none-any.whl", hash = "sha256:e953a25e44ebb60a5c6efc2add4420c177f1d8404509da88da9729202f306994"}, @@ -1885,8 +1923,9 @@ loguru = [ {file = "loguru-0.5.3-py3-none-any.whl", hash = "sha256:f8087ac396b5ee5f67c963b495d615ebbceac2796379599820e324419d53667c"}, {file = "loguru-0.5.3.tar.gz", hash = "sha256:b28e72ac7a98be3d28ad28570299a393dfcd32e5e3f6a353dec94675767b6319"}, ] -m2r = [ - {file = "m2r-0.2.1.tar.gz", hash = "sha256:bf90bad66cda1164b17e5ba4a037806d2443f2a4d5ddc9f6a5554a0322aaed99"}, +markdown-it-py = [ + {file = "markdown-it-py-1.1.0.tar.gz", hash = "sha256:36be6bb3ad987bfdb839f5ba78ddf094552ca38ccbd784ae4f74a4e1419fc6e3"}, + {file = "markdown_it_py-1.1.0-py3-none-any.whl", hash = "sha256:98080fc0bc34c4f2bcf0846a096a9429acbd9d5d8e67ed34026c03c61c464389"}, ] markupsafe = [ {file = "MarkupSafe-1.1.1-cp27-cp27m-macosx_10_6_intel.whl", hash = "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161"}, @@ -1954,9 +1993,9 @@ mccabe = [ {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, ] -mistune = [ - {file = "mistune-0.8.4-py2.py3-none-any.whl", hash = "sha256:88a1051873018da288eee8538d476dffe1262495144b33ecb586c4ab266bb8d4"}, - {file = "mistune-0.8.4.tar.gz", hash = "sha256:59a3429db53c50b5c6bcc8a07f8848cb00d7dc8bdb431a4ab41920d201d4756e"}, +mdit-py-plugins = [ + {file = "mdit-py-plugins-0.2.8.tar.gz", hash = "sha256:5991cef645502e80a5388ec4fc20885d2313d4871e8b8e320ca2de14ac0c015f"}, + {file = "mdit_py_plugins-0.2.8-py3-none-any.whl", hash = "sha256:1833bf738e038e35d89cb3a07eb0d227ed647ce7dd357579b65343740c6d249c"}, ] more-itertools = [ {file = "more-itertools-8.7.0.tar.gz", hash = "sha256:c5d6da9ca3ff65220c3bfd2a8db06d698f05d4d2b9be57e1deb2be5a45019713"}, @@ -1991,6 +2030,10 @@ mypy-extensions = [ {file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"}, {file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"}, ] +myst-parser = [ + {file = "myst-parser-0.15.2.tar.gz", hash = "sha256:f7f3b2d62db7655cde658eb5d62b2ec2a4631308137bd8d10f296a40d57bbbeb"}, + {file = "myst_parser-0.15.2-py3-none-any.whl", hash = "sha256:40124b6f27a4c42ac7f06b385e23a9dcd03d84801e9c7130b59b3729a554b1f9"}, +] nitpick = [ {file = "nitpick-0.27.0-py3-none-any.whl", hash = "sha256:bc8a92b004099cef4f35db4f986b76bd1425a364afc5cd0fc38fce13365cf81f"}, {file = "nitpick-0.27.0.tar.gz", hash = "sha256:4424a2a374c76173fd6cc1b637b9ab79f1f487cb892e7e9db4458de072082f07"}, diff --git a/pyproject.toml b/pyproject.toml index 5bad4e279..e1f7cde38 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,5 +90,5 @@ sphinxcontrib-mermaid = "0.7.1" sphinx-typlog-theme = "^0.8" sphinx-hoverxref = "^0.7b1" doc8 = "^0.9" -m2r = "^0.2" +myst_parser = "^0.15" tomlkit = "^0.7"