lukasturcani / moldoc

Make better chemistry documentation!
MIT License
14 stars 0 forks source link

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

Closed TimoSommer closed 1 month ago

TimoSommer commented 2 months ago

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 commented 2 months ago

Thank you for the kind words and the reproducible example!

The issue is here https://github.com/lukasturcani/moldoc/blob/d78de72181ddead699a56c19b99120b4af266bca/src/moldoc/_internal/moldoc.py#L61-L65

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 commented 2 months ago

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 commented 1 month ago

Fixed and released a new version (v3.0.1)