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

Replace deprecated recommonmark with MyST-Parser #1089

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 3 additions & 30 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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
Expand All @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.. mdinclude:: ../README.md
.. include:: ../README.md
:parser: myst_parser.sphinx_

Contents
--------
Expand Down
3 changes: 2 additions & 1 deletion docs/pages/changelog.rst
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.. mdinclude:: ../../CHANGELOG.md
.. include:: ../../CHANGELOG.md
:parser: myst_parser.sphinx_
3 changes: 1 addition & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
81 changes: 62 additions & 19 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"