def test_get_feature_by_cls(): """Ensure that a language feature can be retrieved via its class definition.""" rst = RstLanguageServer() expected = Roles(rst) rst.add_feature(expected) actual = rst.get_feature(Roles) assert actual is expected
def test_get_setup_arguments_feature_only(): """It should be possible to request just language features.""" def setup(roles: Roles): ... server = RstLanguageServer() roles = Roles(server) server.add_feature(roles) args = _get_setup_arguments(server, setup, "modname") assert args == {"roles": roles}
def test_get_setup_arguments_server_and_feature(): """We should also be able to automatically pass the correct language features""" def setup(rst: RstLanguageServer, rs: Roles): ... server = RstLanguageServer() roles = Roles(server) server.add_feature(roles) args = _get_setup_arguments(server, setup, "modname") assert args == {"rst": server, "rs": roles}
def test_get_feature_by_string(): """Ensure that a language feature can be retrieved by a string, but raises a deprecation warning.""" rst = RstLanguageServer() expected = Roles(rst) rst.add_feature(expected) key = f"{expected.__module__}.{expected.__class__.__name__}" with pytest.deprecated_call(): actual = rst.get_feature(key) assert actual is expected
def esbonio_setup(rst: RstLanguageServer, roles: Roles): docutils_docs = pkg_resources.resource_string("esbonio.lsp.rst", "roles.json") roles.add_documentation(json.loads(docutils_docs.decode("utf8")))
def esbonio_setup(rst: SphinxLanguageServer, roles: Roles): sphinx_docs = pkg_resources.resource_string("esbonio.lsp.sphinx", "roles.json") roles.add_documentation(json.loads(sphinx_docs.decode("utf8"))) roles.add_target_completion_provider(Downloads(rst))
def esbonio_setup(rst: SphinxLanguageServer, roles: Roles): domains = DomainFeatures(rst) roles.add_target_definition_provider(domains) roles.add_target_completion_provider(domains) roles.add_target_link_provider(domains)