Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add domain support for directives #101

Merged
merged 7 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,20 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ["sphinx.ext.intersphinx", "esbonio.tutorial"]
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
"esbonio.tutorial",
]

autodoc_default_options = {
"members": True,
"member-order": "bysource",
"undoc-members": True,
}
autodoc_typehints = "description"

intersphinx_mapping = {
"python": ("https://docs.python.org/3/", None),
Expand All @@ -52,7 +65,13 @@
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"

html_context = {
"conf_py_path": "/docs/",
"display_github": True,
"github_repo": "esbonio",
"github_user": "swyddfa",
"github_version": "release",
}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
Expand Down
11 changes: 11 additions & 0 deletions docs/contributing/lsp.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Language Server
===============

This section contains autogenerated implementation notes based on docstrings in
the codebase.

.. toctree::
:maxdepth: 2
:glob:

lsp/*
5 changes: 5 additions & 0 deletions docs/contributing/lsp/directives.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Directives
==========

.. automodule:: esbonio.lsp.directives
:members:
4 changes: 4 additions & 0 deletions docs/contributing/lsp/testing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Testing
=======

.. automodule:: esbonio.lsp.testing
1 change: 1 addition & 0 deletions lib/esbonio/changes/101.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Directive completions are now domain aware.
23 changes: 16 additions & 7 deletions lib/esbonio/esbonio/lsp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# from __future__ import annotations

import importlib
import logging

from typing import List
from typing import List, Optional

from pygls.features import COMPLETION, INITIALIZE, INITIALIZED, TEXT_DOCUMENT_DID_SAVE
from pygls.server import LanguageServer
Expand All @@ -13,23 +15,32 @@
Position,
)
from pygls.workspace import Document
from sphinx.application import Sphinx


BUILTIN_MODULES = [
"esbonio.lsp.sphinx",
"esbonio.lsp.completion.directives",
"esbonio.lsp.completion.roles",
"esbonio.lsp.directives",
"esbonio.lsp.roles",
]


class LanguageFeature:
"""Base class for language features."""

def __init__(self, rst: "RstLanguageServer"):
self.rst = rst
self.logger = rst.logger.getChild(self.__class__.__name__)


class RstLanguageServer(LanguageServer):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

self.logger = logging.getLogger(__name__)
"""The logger that should be used for all Language Server log entries"""

self.app = None
self.app: Optional[Sphinx] = None
"""Sphinx application instance configured for the current project."""

self.on_init_hooks = []
Expand Down Expand Up @@ -96,9 +107,7 @@ def create_language_server(modules: List[str]) -> RstLanguageServer:
modules:
The list of modules that should be loaded.
"""
import asyncio

server = RstLanguageServer(asyncio.new_event_loop())
server = RstLanguageServer()

for mod in modules:
server.load_module(mod)
Expand Down
1 change: 0 additions & 1 deletion lib/esbonio/esbonio/lsp/completion/__init__.py

This file was deleted.

154 changes: 0 additions & 154 deletions lib/esbonio/esbonio/lsp/completion/directives.py

This file was deleted.

Loading