vscode-restructuredtext / vscode-restructuredtext

reStructuredText Language Support in Visual Studio Code
https://marketplace.visualstudio.com/items/lextudio.restructuredtext
Other
344 stars 93 forks source link

[Bug]: HTML Preview based on confDir not srcDir #402

Closed mgrosvenor closed 8 months ago

mgrosvenor commented 2 years ago

Expected behavior

The configuration directory (confDir) is not always at the root of the document tree. This is why it is provided as a configuration option (and is distinct from srcDir). However, the preview generator still makes this assumption. The expected behaviour is that preview generation will depend on srcDir instead.

Actual behavior

If the confDir is not at the root of the document tree, incorrect paths are generated and previewer fails with an error.

Detailed steps

build a document tree as follows:

/index.rst
/docs/index.rst
/docs/example.rst
/docs/conf.py

Try to preview example.rst it will fail.

Extension information

189.1.0 (but also fails on 190)

Visual Studio Code information

1.70.2

Operating system information

macOS

Python information

3.8

Sphinx information

5.2

Contents of conf.py

N/A

Relevant log output

N/A
AlexanderLanin commented 1 year ago

Same here. By accident I can report, that there are some combinations that will work as well, something like confDir is ".." from buildDir and srcDir is ".." from confDir. But I'm not sure which conditions needs to be fulfilled exactly. It's best to fix this :-)

As already mentioned, what helps for now is: put conf.py into srcDir and set confDir = srcDir.

mgrosvenor commented 1 year ago

put conf.py into srcDir and set confDir = srcDir.

Unfortunately this is not an option for me. This is how I found the bug.

The team I'm working with has put the conf.py in a place different to the src folder. They have reasons for doing this. I cannot get them to change their reasons simply because my editor doesn't play nicely :-(

I've proposed a fix for this issue in PR #403.

As a work around, I have manually edited the plugin JS to replace confDir with srcDir. This has fixed the issue, though it's not ideal to have an out of tree fix.

lextm commented 8 months ago

Starting from version 190.1.17, this extension no longer performs live preview but recommends the Esbonio extension to be used instead. Close this issue now.