[!IMPORTANT]
Doctools is not an official product of Analog Devices Inc. It is a collection
of open-source tools bundled as an extension and is provided without support
or warranty.
Overview
A Visual Studio Code (VSCode/VSCodium) extension that provides language support
for reStructuredText (RST) documentation, powered by tree-sitter. This
extension offers intelligent editing capabilities for Sphinx documentation
projects, with support for custom roles and directives by interfacing with the
Sphinx Python object directly.
Key Features
- Tree-sitter Syntax Highlighting: Fast, accurate syntax highlighting for reStructuredText files using tree-sitter parsing
- Smart Hover Information: Display detailed information about roles and directives on mouse or keyboard cursor hover
- Intelligent Auto-completion:
- Roles (
:ref:, :doc:, ...)
- Directives (
.. note::, .. figure::, ...)
- Local and external references (
:doc:, :external+inv:ref:, ...)
- Live Server: Automatically build changes on save, and see the changes highlighted in the browser.
- Synchronized Preview: The preview panel follows the active editor and locks its scroll position with the editor, in both directions.
- Sparse Build: Build only the folders you are working on.
- Spell Check: LanguageTool grammar and spell check, local by default.
- Format Toolbar: Word-like toolbar for headings, bold, italic, lists, links, references, images, tables, code blocks and admonitions, for reStructuredText and MyST Markdown.
- Diagnostics: Display build warnings and errors as diagnostics in the editor
- Language Injection: Syntax highlighting for embedded languages blocks (bash, YAML)
Requirements
- Python 3 with virtual environments.
- OpenJDK (Java): Optional, for local grammar correction.
For grammar correction with the Language Tool API, Java is not required.
Grammar correction is local by default, the text never leaves the machine.
The cloud mode sends the text of the documents to api.languagetool.org and
must be allowed once per workspace.
Linux/Mac:
For local grammar correction, install OpenJDK from you package manager.
# Ubuntu
apt install openjdk-25-jdk
# Fedora
dnf install java-25-openjdk
# OpenSuse
zypper install java-25-openjdk
Windows
It is highly recommended to install under WSL2 and use the store your files in the WSL file system.
With VSCodium, Open Remote - WSL allows to connect to WSL2.
If for unknown reasons you still want to use on native Windows, follow the guide below.
For grammar correction, install OpenJDK from the
Microsoft distribution
(direct link).
Must re-open the IDE (not just reload the window).
Python environment
The Python environment that provides adi-doctools is resolved in this order:
- The
adi-doctools.pythonPath setting: a Python interpreter, a virtual environment folder or the adoc executable.
./.venv (current workspace/open folder).
adoc, then python3, from PATH.
If none is found, sphinx and adi-doctools are installed (with user confirmation) at ./.venv.
Do not open the sphinx source folder as the workspace folder, it may consider the venv files as source files.
Quick start
Install the extension.
Open a repository with documentation.
Open a .rst file to activate the extension.
Click yes in the prompt to install the virtual enviroment, if adi-doctools is not already available.
Use the Explorer > Sparse build to select just some pages to build.
- Drastically improves first time build time.
Use the bottom panel Docs and Spell Check to configure the features.
Docs: Start/stop server, open preview.
Spell Check: Switch between local, cloud and off grammar correction.
The Format text pane in the Explorer (or Doctools: Show Format Toolbar)
writes the markup for the selection in the last active .rst or .md editor.
The same actions are available in the editor context menu (Format),
in the command palette, and with Ctrl+B / Ctrl+I for bold and italic in
reStructuredText files. Buttons toggle: applying bold to bold text removes it.
The reference buttons insert a :ref: / :doc: role and open the list of
targets (requires the server to be running).
Settings
| Setting |
Default |
Description |
adi-doctools.pythonPath |
|
Python interpreter, virtual environment folder or adoc executable |
adi-doctools.port |
8080 |
Port of the documentation server, the next free port is used when busy |
adi-doctools.preview.scrollSync |
true |
Lock the scroll position of the preview and the editor |
adi-doctools.preview.followEditor |
true |
Show the page of the active editor in the preview |
adi-doctools.grammar.mode |
local |
local, api (cloud) or off |
adi-doctools.grammar.language |
en-US |
LanguageTool language code |
adi-doctools.grammar.disabledRules |
[] |
LanguageTool rule IDs to disable |
Development
npm install
npm run build # bundle to dist/
npm test # unit tests
npm run test:e2e # end-to-end tests in VSCodium/VSCode (headless with Xvfb)
The end-to-end tests use adoc from PATH, or the Python set in ADOC_PYTHON.
Set ADOC_E2E_LANGUAGETOOL=0 to skip the local spell check test (requires Java and language_tool_python).
Alternative
Esbonio is an extensively developed Language Server Protocol and Visual Studio Code extension for sphinx.
The Doctools cli is generates Estobio pyproject.toml entry with (including Sparse builds):
adoc serve --esbonio --sparse docs/learning | tee pyproject.toml
Third Party Sources
This extension proudly integrates the following open source projects:
Documentation
For comprehensive documentation on the Doctools project, visit:
analogdevicesinc.github.io/doctools