swyddfa / esbonio

A language server for working with Sphinx projects.

Home Page:https://docs.esbon.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Include prefix part in primary domain

stsewd opened this issue · comments

Currently, esbonio will list/return only the domain part when listing domains from the primary domain

# Items from the standard and primary domains don't require the namespace prefix
if name == "std" or name == primary_domain:
prefix = ""

But using the prefixed form is still valid and authors may use that form outside python docstrings to disambiguate from other domains.

This also makes the hover feature not work when used in a :py:fun: role, but it only works when used in :fun:.

I was about to make a PR making this an option, but I think maybe this should be the default behavior?

The same could be said about the std prefix, but I haven't that form being used in the wild.

I think you're right from an API perspective, that method should definitely be returning the prefix regardless.

Making that change however, will require refactoring the consumers of that method, otherwise completion suggestions for :fun: won't be generated anymore.

Making that change however, will require refactoring the consumers of that method, otherwise completion suggestions for :fun: won't be generated anymore.

Sorry I wasn't clear, I think esbonio should return both forms with and without prefix, that way hover and completion will keep working with both formats, as both are valid.

Sorry, I don't think I was clear either :)

I've just been thinking a lot about the internal API recently and it probably makes sense to adjust get_domains to return the prefix for all domains regardless of whether they're the primary one or not. Then generating completions for both :py:fun: and :fun: should be handled by the code that actually produces completion suggestions as directives like .. default-domain:: can change this on a per file basis anyway.