mgaitan/sphinxcontrib-mermaid

Modules not being mocked before calling

seanbyrne88 opened this issue · 1 comments

I'm trying to use autoclasstree at the top of a document to show the hierarchy. When I run make html I get an error saying

Mermaid error:
Could not import <my module> (exception: No module named 'pandas')

When I move the diagram to the bottom of the page, after calling automodule to generate references, the build completes successfully and the diagram will render. The references I'm generating refer to the same module i'm trying to build the diagram for, so it looks like pandas is getting mocked at some point, just not before the diagram is rendered.

was able to reproduce with the following

mermaid_test
-- __init__.py
-- parent.py
-- child.py

parent.py

import pandas

class A:
    pass

child.py

from .parent import A

class B(A):
    pass

rst file

UML
---
.. autoclasstree:: mermaid_test.parent mermaid_test.child
    :namespace:mermaid_test
    :strict:

Error:
Mermaid error:
Could not import mermaid_test.parent (exception: No module named 'pandas')