Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

Deprecation Warning: add_source_parser #51

Open
connectedblue opened this issue Dec 3, 2019 · 9 comments · May be fixed by #55
Open

Deprecation Warning: add_source_parser #51

connectedblue opened this issue Dec 3, 2019 · 9 comments · May be fixed by #55

Comments

@connectedblue
Copy link

connectedblue commented Dec 3, 2019

During the build process, the following warning is emitted:

/opt/conda/lib/python3.7/site-packages/m2r.py:652: RemovedInSphinx30Warning: app.add_source_parser() does not support suffix argument. Use app.add_source_suffix() instead.

Looks like some functionality will be removed in the next version of sphinx. I found this on version 2.2.1

@NumesSanguis
Copy link

When attempting to fix this, could adding of .md be put in a try ... except ... statement or some other check if already added?

Currently M2R fails if recommonmark is also included in Sphinx's conf.py under extensions with:

Extension error:
source_suffix '.md' is already registered

@chmreid
Copy link

chmreid commented Feb 13, 2020

Still seeing this warning with Sphinx 2.4.1:

$ make html
Running Sphinx v2.4.1
/Users/charles/codes/dbio/kharon/vp/lib/python3.6/site-packages/m2r.py:652: RemovedInSphinx30Warning: app.add_source_parser() does not support suffix argument. Use app.add_source_suffix() instead.
  app.add_source_parser('.md', M2RParser)
...

@eric-wieser
Copy link

As a workaround, add this to your conf.py:

def monkeypatch(cls):
    """ decorator to monkey-patch methods """
    def decorator(f):
        method = f.__name__
        old_method = getattr(cls, method)
        setattr(cls, method, lambda self, *args, **kwargs: f(old_method, self, *args, **kwargs))
    return decorator

# workaround until https://github.com/miyakogi/m2r/pull/55 is merged
@monkeypatch(sphinx.registry.SphinxComponentRegistry)
def add_source_parser(_old_add_source_parser, self, *args, **kwargs):
    # signature is (parser: Type[Parser], **kwargs), but m2r expects
    # the removed (str, parser: Type[Parser], **kwargs).
    if isinstance(args[0], str):
        args = args[1:]
    return _old_add_source_parser(self, *args, **kwargs)

@sobolevn
Copy link

@miyakogi any chance to get a new release? This component is the only reason we are still using sphinx 2.

DmytroLitvinov pushed a commit to wemake-services/wemake-django-template that referenced this issue Jun 20, 2020
Ignoring sphinx@2 security issue for now, see: miyakogi/m2r#51
DmytroLitvinov pushed a commit to wemake-services/wemake-django-template that referenced this issue Jun 20, 2020
Ignoring sphinx@2 security issue for now, see: miyakogi/m2r#51
DmytroLitvinov pushed a commit to wemake-services/wemake-django-template that referenced this issue Jun 20, 2020
* Fix typo at logging.py file

* Ignore sphinx@2 security issue for now

Ignoring sphinx@2 security issue for now, see: miyakogi/m2r#51
@CrossNox
Copy link

Since I'm still seeing lots of clones on my fork (which I created to solve this issue) here goes a quick update: I've released it as
m2r2 after changing some of the tooling for what I feel more comfortable with right now and building CD and testing pipelines.

@sbliven
Copy link

sbliven commented Jul 13, 2020

@CrossNox Thanks for the release!

I wonder if you could combine forces with @qhua948 (released as m2rr) to make a successor to m2r. It would be good to avoid too much proliferation (ideal would be if @miyakogi would add some additional maintainers).

If combining doesn't work out, you should rename your fork to 'm2r2'. It might be good to enable issues there too if it's going to diverge from this repo significantly. It's a little confusing to keep using this repo to discuss issues that might be fixed in one of the forks.

@CrossNox
Copy link

CrossNox commented Jul 13, 2020

@sbliven I sure hope we could work together on this. I didn't learn of that release until I commented somewhere about the update, my bad. I wouldn't count on @miyakogi adding collabs, they don't seem to have been active for a long time.

100% agree on that last bit! I am pretty sure github redirects clones if I change the repo's name, but i wanna test it just in case. I wouldn't wanna break the pipelines for people using it, but I guess it's still gonna happen.

Edit: I've enabled issues (no clue why they weren't already enabled) and renamed the repo to avoid any confusion.

@dazza-codes
Copy link

# Sphinx version: 3.1.2
# Python version: 3.6.11 (CPython)
# Docutils version: 0.15.2 release
# Jinja2 version: 2.11.2
# Last messages:

# Loaded extensions:
Traceback (most recent call last):
  File "/opt/conda/envs/my-proj/lib/python3.6/site-packages/sphinx/cmd/build.py", line 279, in build_main
    args.tags, args.verbosity, args.jobs, args.keep_going)
  File "/opt/conda/envs/my-proj/lib/python3.6/site-packages/sphinx/application.py", line 244, in __init__
    self.setup_extension(extension)
  File "/opt/conda/envs/my-proj/lib/python3.6/site-packages/sphinx/application.py", line 398, in setup_extension
    self.registry.load_extension(self, extname)
  File "/opt/conda/envs/my-proj/lib/python3.6/site-packages/sphinx/registry.py", line 419, in load_extension
    metadata = setup(app)
  File "/opt/conda/envs/my-proj/lib/python3.6/site-packages/m2r.py", line 652, in setup
    app.add_source_parser('.md', M2RParser)
  File "/opt/conda/envs/my-proj/lib/python3.6/site-packages/sphinx/application.py", line 1084, in add_source_parser
    self.registry.add_source_parser(*args, **kwargs)
TypeError: add_source_parser() takes 2 positional arguments but 3 were given

@dylan-thomas832
Copy link

@dazza-codes See the fork that was updated to fix this: https://github.com/CrossNox/m2r2

Thankfully they made it a different pip package officially, so it's a extremely nice fix.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants