useblocks / sphinx-needs

Adds needs/requirements to sphinx
https://sphinx-needs.readthedocs.io/en/latest/index.html
MIT License
193 stars 58 forks source link

IDE: Extension raises error with 1.0.2 #706

Open twodrops opened 1 year ago

twodrops commented 1 year ago

With Sphinx-Needs 1.0.1 the IDE support worked pretty well. With 1.0.2 it raises the following exception for any action.

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/pygls/protocol.py", line 332, in _handle_request self._execute_request(msg_id, handler, params) File "/usr/local/lib/python3.10/site-packages/pygls/protocol.py", line 261, in _execute_request method_name, method_type, msg_id, handler(params)) File "/usr/local/lib/python3.10/site-packages/esbonio/lsp/init.py", line 220, in on_hover hover_value = feature.hover(context) File "/usr/local/lib/python3.10/site-packages/sphinx_needs/lsp/esbonio.py", line 124, in hover self.needs_store.load_needs(needs_json) File "/usr/local/lib/python3.10/site-packages/sphinx_needs/lsp/needs_store.py", line 97, in load_needs docname = need["docname"] + need["doctype"] KeyError: 'doctype' [Error - 07:22:24] Request textDocument/hover failed. Message: KeyError: 'doctype' Code: -32602

No change with any of these options.

source_suffix = ['.rst', '.md']
source_suffix = '.rst'

NOTE: The problem is within VS Code Devcontainer where Sphinx-Needs 1.0.1 has no issues.

danwos commented 1 year ago

Thanks for reporting this :+1: Unfortunately, I can not reproduce it, but I get many other errors from RST-plugins directly.

I'm unsure what the reason is, maybe some API changes and inconsistent versions by RestructuredText, esbonio and Sphinx-Needs.

We will set up a .vscode folder, which contains a common configuration for all the relevant extensions. So we can be sure to work on the same IDE setup and it can be used as a reference.

We are on it :)

haiyangToAI commented 1 year ago

Hi @twodrops,

Can you please try rebuild needs.json? In this new release 1.0.2, we introduced "doctype" into "needs_info" for IDE feature, I think this breaks the old needs.json.

In my conf.py, I always have needs_build_json = True, this is maybe why I can't reproduce the bug you reported.

I am sorry for the inconvenience, I forgot document this.

twodrops commented 1 year ago

Thats interesting because I have needs_build_json = True set already since Sphinx-Needs 1.0.1 and the generated needs.json has a doctype with Sphinx-Needs 1.0.2 "doctype": ".rst",

Any other clue?

haiyangToAI commented 1 year ago

Hi @twodrops,

That's getting interesting. From the error message above, it clearly suggest that, that need doesn't have "doctype".

Could you please check the need-id you performed hover feature with? Is this need exits in the generated needs.json? Does this need has doctype?

I just got a feeling, maybe somehow external needs are involved.

twodrops commented 1 year ago

@haiyangToAI Sorry, everything with rST works as expected. I don't know what it was. I setup my workspace again and everything started working fine,

The markdown support is still not working for me although :(

Is anything other than these two steps needed to get it working?

extensions = ["sphinx_needs", "myst_parser"] source_suffix = [".rst", ".md"]

For the markdown files, the need.json has the following entry.

"doctype": ".md"

I do not see any autocompleton for example, when I use "Role need completion"