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

'str' object has no attribute 'supported' when building documentation using m2r2 #8395

Closed
brsc2909 opened this issue Nov 8, 2020 · 10 comments
Labels

Comments

@brsc2909
Copy link

brsc2909 commented Nov 8, 2020

Describe the bug
when i add the m2r2 extension to my project is get the error below

To Reproduce

$ pip install m2r2
$ mkdir testdoc && cd testdoc

Add m2r2 to extensions in conf.py

# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- Project information -----------------------------------------------------

project = 'test'
copyright = '2020, bs'
author = 'bs'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['m2r2']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'

# 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']

Make docs

$ make html

Error:

$ make html
Running Sphinx v3.3.0

Exception occurred:
  File "/home/username/PycharmProjects/project/venv/lib/python3.8/site-packages/sphinx/registry.py", line 266, in add_source_parser
    for filetype in parser.supported:
AttributeError: 'str' object has no attribute 'supported'
The full traceback has been saved in /tmp/sphinx-err-bk5vovm_.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
make: *** [Makefile:20: html] Error 2

Expected behavior
A clear and concise description of what you expected to happen.

Environment info

  • OS: Linux manjaro 20.1 KDE plasma
  • Python version: 3.8.6
  • Sphinx version: 3.3.0
  • Sphinx extensions: m2r2
@brsc2909
Copy link
Author

brsc2909 commented Nov 8, 2020

This can be closed it's fixed in
CrossNox/m2r2@484b792

@brsc2909 brsc2909 closed this as completed Nov 8, 2020
@cglacet
Copy link

cglacet commented Nov 11, 2020

I'm still getting this error with the latest version of m2r2 0.2.5 (and sphinx 3.3.0).

@cglacet
Copy link

cglacet commented Nov 11, 2020

On the other hand the proposed patch does work.

@brsc2909
Copy link
Author

I'm still getting this error with the latest version of m2r2 0.2.5 (and sphinx 3.3.0).

The fix hasn't been merged yet, it's still waiting on this pull request CrossNox/m2r2#14.

cglacet referenced this issue in CrossNox/m2r2 Nov 11, 2020
@cglacet
Copy link

cglacet commented Nov 11, 2020

"8 days ago" ok. Is there a single person with merge rights on m2r2? It's a bit strange to spend 8 days approving this kind of edit. Anyway, thanks for the issue you saved me quite a bit of time :D

@cglacet
Copy link

cglacet commented Nov 11, 2020

In the mean time, conf.py:

"""Patching m2r2"""
import m2r2

current_m2r2_setup = m2r2.setup

def patched_m2r2_setup(app):
    try:
        return current_m2r2_setup(app)
    except (AttributeError):
        app.add_source_suffix(".md", "markdown")
        app.add_source_parser(m2r2.M2RParser)
    return dict(
        version=m2r2.__version__, parallel_read_safe=True, parallel_write_safe=True,
    )

m2r2.setup = patched_m2r2_setup

muammar added a commit to muammar/ml4chem that referenced this issue Jan 7, 2021
I should get rid of this dependency if the problem is not solved.
muammar added a commit to muammar/ml4chem that referenced this issue Jan 19, 2021
* master:
  Changes to Gaussian class and handler.
  Fix m2r2 issue. See sphinx-doc/sphinx#8395
  Added version requirement of msgpack>=0.6.0 in requirement.txt
  m2r fix.
  neuralnetwork module compatible with new pytorch versions.
@Sherryzhang2
Copy link

I also met this problem. Has this issue been fixed and merged into any release version?

@KaiSchwarz-cnic
Copy link

I am also running into this problem. But will try to get the above workaround applied.

@KaiSchwarz-cnic
Copy link

KaiSchwarz-cnic commented Jan 22, 2021

fyi I am reading somewhere else about a plugin m2r2 - looks like m2r is abandoned. replacing m2r might fix it.
CrossNox/m2r2#13

I'll give that a try and will post the result. -> Yes, fixed.

martinm82 added a commit to tomtom-international/ebr-connector that referenced this issue Apr 7, 2021
@martinm82
Copy link

@Papakai using m2r2 fixes indeed the problem. Thanks for the workaround

martinm82 added a commit to tomtom-international/ebr-connector that referenced this issue Apr 7, 2021
* fix(toml): fix unterminated string error in black configuration

* fix formatting

* fix pyup.io security errors

* fix lint error

* fix: replace m2r with m2r2 due to an issue that hasn't been fixed yet.

see sphinx-doc/sphinx#8395 (comment).

* update changelog
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants