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

Unknown directive type "mdinclude" #15

Open
cglacet opened this issue Nov 12, 2020 · 5 comments
Open

Unknown directive type "mdinclude" #15

cglacet opened this issue Nov 12, 2020 · 5 comments

Comments

@cglacet
Copy link

cglacet commented Nov 12, 2020

Version 0.2.5

I'm not too sure what I've done, this package used to work but now I get this error:

WARNING: Unknown directive type "mdinclude".

I can still convert files without any problem, but when I run sphinx (3.3.1) I get this error when using the mdinclude directive.

Details about my install

$ poetry show m2r2
name         : m2r2
version      : 0.2.5
description  : Markdown and reStructuredText in a single file.

dependencies
 - docutils *
 - mistune *

I tried removing and adding m2r2 back but nothing seems to work.

How does m2r2 normally registers this new directive?

@cglacet
Copy link
Author

cglacet commented Nov 12, 2020

I managed to solve the issue by downgrading sphinx to 3.2.1:

[tool.poetry.dev-dependencies]
-sphinx = "^3.3.1"
+sphinx = "3.2.1"

The error also appears on sphinx 3.3.0.

@NumesSanguis
Copy link

Related to?: #13

@cglacet
Copy link
Author

cglacet commented Nov 13, 2020

No, it's a different problem, I had #13 too but I solved it by adding this to my 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

Also note that #13 has been patched, but the PR hasn't been merged yet. This mimics the patch that will (hopefully) been soon merged.

@chrizzFTD
Copy link

chrizzFTD commented Nov 15, 2020

Hi @cglacet!

I was having similar errors from #13, then I saw this issue and I took your patch from conf.py and added it to my project here: thegrill/grill@2fc61de.

I noticed the missing mdinclude directive was fixed by adding the app.add_directive("mdinclude", m2r2.MdInclude) call after catching the AttributeError: thegrill/grill@79cbb7b, like so:

    ...
    except (AttributeError):
        app.add_source_suffix(".md", "markdown")
        app.add_source_parser(m2r2.M2RParser)
+       app.add_directive("mdinclude", m2r2.MdInclude)
    return dict(
    ...

With that, my docs built properly again.

Since it was fixed directly on the patch, I feel this is related to #13

I hope this helps!

@CrossNox
Copy link
Owner

IIUC, this can be closed, since the fix for #13 has already been merged, right?

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

No branches or pull requests

4 participants