Skip to content

Commit

Permalink
Merge pull request #117 from swyddfa/develop
Browse files Browse the repository at this point in the history
New Release
  • Loading branch information
alcarney authored Feb 25, 2021
2 parents 2b117f8 + 72fbbf3 commit 9f008f9
Show file tree
Hide file tree
Showing 41 changed files with 2,342 additions and 1,259 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/automation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Automation

on:
issues:
types:
- assigned
- labeled
- unassigned
- unlabeled

jobs:
issues:
runs-on: ubuntu-latest
name: Issue Automation
steps:
- uses: 'actions/checkout@v2'

- name: Run Script
env:
EVENT: ${{ toJSON(github.event) }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Event Name: ${{ github.event_name }}"
# echo "${EVENT}"
./scripts/project-management.sh
7 changes: 7 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
"cwd": "${workspaceRoot}/docs"
}
},
{
"label": "pytest file",
"type": "shell",
"command": "source ${workspaceRoot}/.env/bin/activate && pytest ${file}",
"group": "test",
"problemMatcher": [],
},
{
"label": "Grammar Tests",
"type": "shell",
Expand Down
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/*
4 changes: 4 additions & 0 deletions docs/contributing/lsp/directives.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Directives
==========

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

.. automodule:: esbonio.lsp.roles
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/100.bug.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Language Server now correctly offers completions for ``autoxxx`` directive options
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.
1 change: 1 addition & 0 deletions lib/esbonio/changes/102.fix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure ``:doc:`` completions are specified relative to the project root.
1 change: 1 addition & 0 deletions lib/esbonio/changes/104.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Role and role target completions are now domain aware.
1 change: 1 addition & 0 deletions lib/esbonio/changes/106.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Intersphinx completions are now domain aware
4 changes: 4 additions & 0 deletions lib/esbonio/changes/113.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Add ``log-filter`` cli argument that allows Language Clients to choose
which loggers they want to recieve messages from. Also add
``--hide-sphinx-output`` cli argument that can suppress Sphinx's build
log as it it handled separately.
2 changes: 2 additions & 0 deletions lib/esbonio/changes/114.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add ``-p``, ``--port`` cli arguments that start the Language Server in
TCP mode while specifying the port number to listen on.
2 changes: 2 additions & 0 deletions lib/esbonio/changes/115.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add ``--cache-dir`` cli argument that allows Language Clients to
specify where cached data should be stored e.g. Sphinx's build output.
1 change: 1 addition & 0 deletions lib/esbonio/changes/57.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The language server now reports invalid references as diagnostics
1 change: 1 addition & 0 deletions lib/esbonio/changes/83.fix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The language server now reloads when the project's ``conf.py`` is modified
2 changes: 2 additions & 0 deletions lib/esbonio/changes/87.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add ``--log-level`` cli argument that allows Language Clients to
control the verbosity of the Language Server's log output.
2 changes: 2 additions & 0 deletions lib/esbonio/changes/91.fix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
``$/setTraceNotification`` notifications from VSCode no longer cause exceptions to be thrown
in the Language Server.
1 change: 1 addition & 0 deletions lib/esbonio/changes/94.fix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Consistency errors are now included in reported diagnostics.
96 changes: 72 additions & 24 deletions lib/esbonio/esbonio/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,112 @@
import esbonio.lsp as lsp

from esbonio import __version__
from esbonio.lsp import RstLanguageServer
from esbonio.lsp.logger import LspHandler

LOG_LEVELS = [logging.ERROR, logging.INFO, logging.DEBUG]
LOG_LEVELS = {
"debug": logging.DEBUG,
"error": logging.ERROR,
"info": logging.INFO,
}


def configure_logging(verbose, server):
class LogFilter:
"""A log filter that accepts message from any of the listed logger names."""

try:
level = LOG_LEVELS[-1]
except IndexError:
level = LOG_LEVELS[-1]
def __init__(self, names):
self.names = names

def filter(self, record):
return any(record.name == name for name in self.names)


def configure_logging(args, server: RstLanguageServer):

level = LOG_LEVELS[args.log_level]

lsp_logger = logging.getLogger("esbonio.lsp")
lsp_logger.setLevel(level)

lsp_handler = LspHandler(server)
lsp_handler.setLevel(level)

if args.log_filter is not None:
lsp_handler.addFilter(LogFilter(args.log_filter))

formatter = logging.Formatter("[%(name)s] %(message)s")
lsp_handler.setFormatter(formatter)
lsp_logger.addHandler(lsp_handler)

sphinx_logger = logging.getLogger("esbonio.sphinx")
sphinx_logger.setLevel(level)
if not args.hide_sphinx_output:
sphinx_logger = logging.getLogger("esbonio.sphinx")
sphinx_logger.setLevel(logging.INFO)

sphinx_handler = LspHandler(server)
sphinx_handler.setLevel(level)
sphinx_handler = LspHandler(server)
sphinx_handler.setLevel(logging.INFO)

formatter = logging.Formatter("%(message)s")
sphinx_handler.setFormatter(formatter)
sphinx_logger.addHandler(sphinx_handler)
formatter = logging.Formatter("%(message)s")
sphinx_handler.setFormatter(formatter)
sphinx_logger.addHandler(sphinx_handler)


def start_server(verbose):
def start_server(args):
"""Start the language server."""

server = lsp.create_language_server(lsp.BUILTIN_MODULES)
configure_logging(verbose, server)
server.start_io()
server = lsp.create_language_server(lsp.BUILTIN_MODULES, cache_dir=args.cache_dir)
configure_logging(args, server)

if args.port:
server.start_tcp("localhost", args.port)
else:
server.start_io()


cli = argparse.ArgumentParser(prog="esbonio", description="The Esbonio language server")

cli.add_argument(
"--version", action="store_true", help="print the current version and exit"
"--cache-dir",
default=None,
type=str,
help="the directory where cached data should be stored, e.g. Sphinx build output ",
)

cli.add_argument(
"-v",
"--verbose",
action="count",
default=0,
help="increase output verbosity, repeatable e.g. -v, -vv, -vvv, ...",
"--hide-sphinx-output",
action="store_true",
help="hide sphinx build output from the log",
)

cli.add_argument(
"--log-filter",
action="append",
help="only include log messages from loggers with the given name,"
+ "can be set multiple times.",
)

cli.add_argument(
"--log-level",
choices=["error", "info", "debug"],
default="error",
help="set the level of log message to show from the language server",
)

cli.add_argument(
"-p",
"--port",
type=int,
default=None,
help="start a TCP instance of the language server listening on the given port ",
)

cli.add_argument(
"--version", action="store_true", help="print the current version and exit"
)

args = cli.parse_args()

if args.version:
print("v{}".format(__version__))
sys.exit(0)

start_server(args.verbose)
start_server(args)
Loading

0 comments on commit 9f008f9

Please sign in to comment.