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

[WIP] Add "Show Source" feature #710

Draft
wants to merge 11 commits into
base: develop
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/lsp-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- run: |
set -e

./scripts/make-release.sh lsp
./scripts/make_release.py lsp
name: Set Version
id: info

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/vscode-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:

jobs:
release:
name: vscode release
runs-on: ubuntu-latest
environment:
name: vscode-marketplace
Expand Down Expand Up @@ -49,7 +50,7 @@ jobs:
cd code

# Use version of esbonio on PyPi for release builds
ESBONIO_WHL=esbonio tox run -e bundle-deps
ESBONIO_WHL="--pre esbonio" tox run -e bundle-deps

npm ci --prefer-offline
npm run package
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ dist

# Demo tutorial is populated during the build.
lib/esbonio-extensions/esbonio/tutorial_demo
code/.python-version
80 changes: 80 additions & 0 deletions code/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,83 @@
## v0.92.1 - 2024-01-15


### Misc

- Fix release pipeline ([#720](https://github.com/swyddfa/esbonio/issues/720))


## v0.92.0 - 2024-01-15


### Breaking Changes

- The following server configuration options have been removed as they are no longer required.

- `esbonio.server.installBehavior`
- `esbonio.server.updateBehavior`
- `esbonio.server.updateFrequency`

The language server is now bundled as part of the VSCode extension itself, so a separate installation step is no longer necessary.

The following sphinx configuration options have been removed

- `esbonio.server.hideSphinxOutput`
- `esbonio.sphinx.buildDir`
- `esbonio.sphinx.builderName`
- `esbonio.sphinx.confDir`
- `esbonio.sphinx.doctreeDir`
- `esbonio.sphinx.forceFullBuild`
- `esbonio.sphinx.keepGoing`
- `esbonio.sphinx.makeMode`
- `esbonio.sphinx.numJobs`
- `esbonio.sphinx.quiet`
- `esbonio.sphinx.silent`
- `esbonio.sphinx.srcDir`
- `esbonio.sphinx.tags`
- `esbonio.sphinx.verbosity`
- `esbonio.sphinx.warningIsError`

The Sphinx application instance is now launched using a standard `sphinx-build` command line provided through the `esbonio.sphinx.buildCommand` option, so individual options are no longer necessary.
**Note:** The `esbonio.sphinx.configOverrides` option has been preserved as it can be easier to use than the equivalent command line options.

([#619](https://github.com/swyddfa/esbonio/issues/619))
- The minimum required VSCode version is now 1.82.0 ([#666](https://github.com/swyddfa/esbonio/issues/666))

### Enhancements

- The following server configuration values have been added

- `esbonio.server.enableDevTools`: Enable integration with [lsp-devtools](https://github.com/swyddfa/lsp-devtools) for the language server itself.

The following sphinx configuration values have been added

- `esbonio.sphinx.buildCommand`: Set the `sphinx-build` command to use when invoking the Sphinx subprocess

- `esbonio.sphinx.pythonCommand`: By default, the extension will attempt to reuse the Python environment you have configured in the Python extension when invoking Sphinx.
This option can be used to override this behavior.

- `esbonio.sphinx.cwd`: The working directory from which to launch the Sphinx process

- `esbonio.sphinx.envPassthrough`: A list of envrionment variables to pass through to the Sphinx process.

- `esbonio.sphinx.enableDevTools`: Enable integration with [lsp-devtools](https://github.com/swyddfa/lsp-devtools) for the sphinx process

- `esbonio.sphinx.pythonPath`: Used to override the Python packages (typically `esbonio.sphinx_agent`) that are injected into the Sphinx environment

The following preview related options have been added

- `esbonio.sphinx.enableSyncScrolling`: Enable support for syncronised scrolling between the editor and preview pane
- `esbonio.preview.bind`: Set the network interface that the preview server binds to
- `esbonio.preview.httpPort`: Set the port number the HTTP server binds to
- `esbonio.preview.wsPort`: Set the port number the WebSocket server binds to

([#626](https://github.com/swyddfa/esbonio/issues/626))

### Misc

- Updated the bundled version of `esbonio` to `1.0.0b1` ([#720](https://github.com/swyddfa/esbonio/issues/720))


# v0.11.0 - 2023-03-06

## Features
Expand Down
39 changes: 30 additions & 9 deletions code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@

The Esbonio extension integrates the [`esbonio`](https://pypi.org/project/esbonio/) language server into VSCode.

The `esbonio` language server aims to make it easier to work with [Sphinx](https://www.sphinx-doc.org/en/master/) documentation projects by bringing IDE-like features to your documentation experience.
The `esbonio` language server aims to make it easier to work with [Sphinx](https://www.sphinx-doc.org/en/master/) documentation projects by proving IDE-like features to your reStructuredText and Markdown files.

## Features

### Live Preview

The extension can show a live HTML preview of the documentation, so the preview contents change whenever the document is updated
The extension can show a live HTML preview of the documentation, so the preview contents change whenever the document is updated.
Syncronised scrolling between the source and preview is also supported.

![HTML Preview](../resources/images/vscode-preview-demo.gif)

Expand Down Expand Up @@ -43,18 +44,38 @@ Errors from a build are published to VSCode as diagnostics

### Hover

Documentation is provided for certain roles and directives when the cursor hovers over them in the editor
Documentation is provided for certain roles and directives.

![Hover](../resources/images/hover-demo.png)

### Outline
### Document & Workspace Symbols

Sections within a document are displayed in the "Outline" view
Section titles and directives within a document are recognised as symbols and displayed in the "Outline" view.
You can also search for symbols within the workspace using the `Ctrl+T` shortcut.

![Document Outline](../resources/images/document-symbols-demo.png)
![Document & Worspace Symbols](../resources/images/document-workspace-symbols-demo.png)

## Supplement Extensions
## Setup

The [reStructuredText](https://marketplace.visualstudio.com/items?itemName=lextudio.restructuredtext) extension as of [v190.1.17](https://github.com/vscode-restructuredtext/vscode-restructuredtext/releases/tag/190.1.17) integrates many other useful tools such as the traditional linters like [`doc8`](https://pypi.org/project/doc8/) and [`rstcheck`](https://pypi.org/project/rstcheck/). It also provides additional editor functionality for working with reStructuredText in general. More details can be found on the [extension's page](https://marketplace.visualstudio.com/items?itemName=lextudio.restructuredtext).
The `esbonio` language server is bundled with this extension, so there is no need to install it separately.
However, the server will need access the Python environment you use to build your documentation.

The [reStructuredText Syntax highlighting](https://marketplace.visualstudio.com/items?itemName=trond-snekvik.simple-rst) extension provides syntax highlighting for reStructuredText files. More details can be found on the [extension's page](https://marketplace.visualstudio.com/items?itemName=trond-snekvik.simple-rst).
1. Open the folder containing your documentation project in VSCode, (opening a single file without an active workspace is not currently supported and will lead to errors).

1. Using the `Python: Select Interpreter` command from the Python extension, choose the environment you use to build your documentation.
(You might be required to run the `Esbonio: Restart Language Server` command for it to take effect).

Alternatively, you can set the `esbonio.sphinx.pythonCommand` option to override the python interpreter used.

1. Open a reStructuredText or markdown file from your Sphinx project.

1. Sphinx build output will be available in Esbonio's `Output` view in VSCode's panel.

## Supplementry Extensions

The [reStructuredText](https://marketplace.visualstudio.com/items?itemName=lextudio.restructuredtext) extension as of [v190.1.17](https://github.com/vscode-restructuredtext/vscode-restructuredtext/releases/tag/190.1.17) integrates many other useful tools such as the traditional linters like [`doc8`](https://pypi.org/project/doc8/) and [`rstcheck`](https://pypi.org/project/rstcheck/).
It also provides additional editor functionality for working with reStructuredText in general.
More details can be found on the [extension's page](https://marketplace.visualstudio.com/items?itemName=lextudio.restructuredtext).

The [reStructuredText Syntax highlighting](https://marketplace.visualstudio.com/items?itemName=trond-snekvik.simple-rst) extension provides syntax highlighting for reStructuredText files.
More details can be found on the [extension's page](https://marketplace.visualstudio.com/items?itemName=trond-snekvik.simple-rst).
28 changes: 0 additions & 28 deletions code/changes/619.breaking.md

This file was deleted.

25 changes: 0 additions & 25 deletions code/changes/626.enhancement.md

This file was deleted.

1 change: 0 additions & 1 deletion code/changes/666.breaking.md

This file was deleted.

1 change: 0 additions & 1 deletion code/changes/720.misc.md

This file was deleted.

13 changes: 12 additions & 1 deletion code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"author": "Esbonio Developers",
"publisher": "swyddfa",
"license": "MIT",
"version": "0.91.0",
"version": "0.92.1",
"keywords": [
"sphinx",
"documentation"
Expand Down Expand Up @@ -72,6 +72,12 @@
"icon": "$(open-preview)",
"category": "Esbonio"
},
{
"command": "esbonio.preview.showSource",
"title": "Show Source",
"icon": "$(go-to-file)",
"category": "Esbonio"
},
{
"command": "esbonio.server.restart",
"title": "Restart Language Server",
Expand Down Expand Up @@ -324,6 +330,11 @@
"alt": "esbonio.preview.open",
"group": "navigation",
"when": "resourceLangId == restructuredtext"
},
{
"command": "esbonio.preview.showSource",
"group": "navigation",
"when": "restructuredtextPreviewFocus"
}
]
},
Expand Down
1 change: 1 addition & 0 deletions code/src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export namespace Server {
export namespace Commands {
export const OPEN_PREVIEW = "esbonio.preview.open"
export const OPEN_PREVIEW_TO_SIDE = "esbonio.preview.openSide"
export const SHOW_SOURCE = "esbonio.preview.showSource"
export const PREVIEW_FILE = "esbonio.server.previewFile"

export const RESTART_SERVER = "esbonio.server.restart"
Expand Down
30 changes: 29 additions & 1 deletion code/src/node/preview.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as vscode from 'vscode'
import { OutputChannelLogger } from '../common/log'
import { EsbonioClient } from './client'
import { Commands, Events, Notifications, Server } from '../common/constants'
import { Commands, Events, Notifications } from '../common/constants'

interface PreviewFileParams {
uri: string
Expand All @@ -14,6 +14,8 @@ interface PreviewFileResult {

export class PreviewManager {

private static readonly rstPreviewActiveContextKey =
'restructuredtextPreviewFocus';
private panel?: vscode.WebviewPanel

// The uri of the document currently shown in the preview pane
Expand All @@ -30,6 +32,9 @@ export class PreviewManager {
context.subscriptions.push(
vscode.commands.registerTextEditorCommand(Commands.OPEN_PREVIEW_TO_SIDE, this.openPreviewToSide, this)
)
context.subscriptions.push(
vscode.commands.registerTextEditorCommand(Commands.SHOW_SOURCE, this.showSource, this)
)
context.subscriptions.push(
vscode.window.onDidChangeActiveTextEditor(this.onDidChangeEditor, this)
)
Expand Down Expand Up @@ -74,6 +79,19 @@ export class PreviewManager {
return await this.previewEditor(editor, vscode.ViewColumn.Beside)
}

async showSource() {
if (!this.currentUri) {
return
}

let editor = findEditorFor(this.currentUri)
if (!editor) {
return
}

await vscode.window.showTextDocument(editor.document, { preview: false })
}

private scrollEditor(params: { line: number }) {
let editor = findEditorFor(this.currentUri)
if (!editor) {
Expand Down Expand Up @@ -133,6 +151,7 @@ export class PreviewManager {

this.currentUri = editor.document.uri
panel.webview.postMessage({ 'show': result.uri })
this.setPreviewActiveContext(true)
}

private getPanel(placement: vscode.ViewColumn): vscode.WebviewPanel {
Expand Down Expand Up @@ -267,10 +286,19 @@ export class PreviewManager {
this.panel.onDidDispose(() => {
this.panel = undefined
this.currentUri = undefined
this.setPreviewActiveContext(false)
})

return this.panel
}

private setPreviewActiveContext(value: boolean) {
vscode.commands.executeCommand(
'setContext',
PreviewManager.rstPreviewActiveContextKey,
value
)
}
}


Expand Down
27 changes: 27 additions & 0 deletions lib/esbonio/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
## v1.0.0b1 - 2024-01-15


### Breaking Changes

- Removed `esbonio.lsp.spelling` module, though it will be available as `esbonio.ext.spelling` via the `esbonio-extensions` package. ([#583](https://github.com/swyddfa/esbonio/issues/583))
- Drop Python 3.7 support ([#584](https://github.com/swyddfa/esbonio/issues/584))
- Drop Sphinx 4.x support ([#585](https://github.com/swyddfa/esbonio/issues/585))

### Features

- The language server now supports reading configuration values from `workspace/configuration` requests and `pyproject.toml` files.
When supported by the client, the server can detect and respond to changes in (most) configuration automatically - no more manually restarting the server! ([#527](https://github.com/swyddfa/esbonio/issues/527))
- The language server now supports `workspace/symbol` requests ([#611](https://github.com/swyddfa/esbonio/issues/611))
- Sphinx build progress is now reported using the `window/workDoneProgress/create` API ([#659](https://github.com/swyddfa/esbonio/issues/659))
- For the clients that support the pull diagnostics model, the server now supports the `textDocument/diagnostic` and `workspace/diagnostic` methods. ([#689](https://github.com/swyddfa/esbonio/issues/689))
- The language server can now provide completion suggestions for MyST directives. ([#706](https://github.com/swyddfa/esbonio/issues/706))

### Enhancements

- When providing completion suggestions for directives, `esbonio` now takes the `.. default-domain::` directive into account ([#105](https://github.com/swyddfa/esbonio/issues/105))

### Fixes

- Fix path separator character on Windows by @ExaneServerTeam ([#719](https://github.com/swyddfa/esbonio/issues/719))


## v0.16.2 - 2023-10-07

This somewhat quiet release marks the end of the `0.x` series as development has now shifted to focus on what will ultimately become the `1.0` release.
Expand Down
Loading