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

Molecules not displayed if .rst file is located more than one directory deep #9

Closed
TimoSommer opened this issue Sep 5, 2024 · 3 comments

Comments

@TimoSommer
Copy link

First of all, thank you very much for this amazing package that makes chemistry documentations so much more beautiful!

I have found one little issue when I wanted to use it for myself: It works great in all .rst files that are saved in the same folder as index.rst or one folder below, but not if the .rst file is located two directories deep. In this case, the molecule is simply not displayed.

I have created a minimal working example in which you can see this effect. Just download and extract the directory and open _build/html/index.html to see the issue or run make clean && make html; open _build/html/index.html to make new html files. I tested it with both Chrome and Safari.

The issue is not critical and really hard to test for. As a workaround, one can simply flatten the folder structure so that all files are in maximum one subdirectory below the index.rst and everything should work.

My software:
Mac Sonoma 14.5
Python 3.12.4
moldoc 3.0.0
sphinx 7.4.7

@lukasturcani
Copy link
Owner

Thank you for the kind words and the reproducible example!

The issue is here

self.body.append(
'<script src="./_static/three.min.js"></script>'
'<script src="./_static/molDraw.js"></script>'
'<script src="../_static/three.min.js"></script>'
'<script src="../_static/molDraw.js"></script>'

Basically, the javascript dependencies are located in the folder _static and the html files include them as relative dependencies. this gets injected into every html file which has moldoc in it. unfortunately this currently supports only a limited amount of nesting

I'll have to check the sphinx api to see if there is a nice way around it. I assume I didn't find a way to get around this before but maybe a fresh look is what it takes.

In the worst case I can just add more relative imports and that should fix your issue, how deep is your nesting?

@TimoSommer
Copy link
Author

My nesting was 4 directories deep, but I actually already refactored and flattened the directory structure so that it all works for me now. Since this issue seems difficult to solve but has a very easy workaround, maybe just mention it prominently in the docs?

lukasturcani added a commit that referenced this issue Sep 21, 2024
Fixes issue #9. rst files can now have any amount of nesting they want.
@lukasturcani
Copy link
Owner

Fixed and released a new version (v3.0.1)

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

2 participants