Skip to content

Commit c474114

Browse files
authored
Merge pull request #422 from swyddfa/develop
New Release
2 parents b5505d7 + 74affc9 commit c474114

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1109
-702
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ exclude: '.bumpversion.cfg$'
22
repos:
33

44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.2.0
5+
rev: v4.3.0
66
hooks:
77
- id: end-of-file-fixer
88
- id: trailing-whitespace

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@
5151
"sphinx.ext.viewcode",
5252
"sphinxcontrib.autodoc_pydantic",
5353
"sphinx_panels",
54+
"esbonio.relevant_to",
5455
"esbonio.tutorial",
5556
"cli_help",
5657
"collection_items",
57-
"relevant_to",
5858
]
5959

6060
autodoc_member_order = "groupwise"
@@ -126,7 +126,7 @@ def lsp_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
126126
"""Link to sections within the lsp specification."""
127127

128128
anchor = text.replace("/", "_")
129-
ref = f"https://microsoft.github.io/language-server-protocol/specifications/specification-current#{anchor}"
129+
ref = f"https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#{anchor}"
130130

131131
node = nodes.reference(rawtext, text, refuri=ref, **options)
132132
return [node], []

docs/ext/relevant_to.py

Lines changed: 0 additions & 275 deletions
This file was deleted.

docs/extensions/_installation.rst

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/extensions/relevant_to.rst

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
Relevent To
2+
===========
3+
4+
The ``esbonio.relevant_to`` extension is similar to the `sphinx-panels`_ and `sphinx-tabs`_ extensions, where you can define sections of documentation that is only relevant to a given subject (e.g. Python version) and be able to choose between them.
5+
6+
However, instead of presenting these sections as tabs, this extension uses a dropdown which scales better when you have a large collection of subjects to cover (like text editors!)
7+
8+
Additionally this extension
9+
10+
- Reflects the chosen topic in the page's URL, making subject choices linkable
11+
- Uses `htmx`_ to swap out the relevant sections.
12+
13+
See the Esbonio language server's :ref:`lsp_getting_started` guide for an example of this extension in action.
14+
15+
.. note::
16+
17+
This extension currently only supports HTML builders.
18+
19+
.. _htmx: https://htmx.org/
20+
.. _sphinx-panels: https://sphinx-panels.readthedocs.io/en/latest/index.html#tabbed-content
21+
.. _sphinx-tabs: https://sphinx-tabs.readthedocs.io/en/latest/
22+
23+
24+
Getting Started
25+
---------------
26+
27+
The ``esbonio.relevant_to`` is available through the ``esbonio-extensions`` Python package.
28+
29+
.. code-block:: console
30+
31+
$ pip install esbonio-extensions
32+
33+
Ensure that the extension is enabled by including ``esbonio.relevant_to`` in the ``extensions`` list inside your project's ``conf.py``::
34+
35+
extensions = [
36+
"esbonio.relevant_to"
37+
]
38+
39+
40+
Then within your documentation, "relevant sections" are defined using the :rst:dir:`relevent-to` directive.
41+
42+
.. rst:directive:: relevent-to
43+
44+
Define sections that can be swapped out based on the chosen subject.
45+
Consider the following example.
46+
47+
.. code-block:: rst
48+
49+
.. relevant-to:: Colour
50+
51+
Blue
52+
The chosen colour is blue.
53+
54+
Green
55+
The chosen colour is green.
56+
57+
Red
58+
The chosen colour is red.
59+
60+
The argument to the directive defines the category of subject this section is about. The content of the directive must be a valid `definition list <https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#definition-lists>`_ where the term is the name of the subject (``Red``, ``Green`` or ``Blue`` in this case) and the definition is the term's corresponding content.
61+
62+
Here is how the above example is rendered.
63+
64+
.. relevant-to:: Colour
65+
66+
Blue
67+
The chosen colour is blue.
68+
69+
Green
70+
The chosen colour is green.
71+
72+
Red
73+
The chosen colour is red.
74+
75+
The body of a definition can contain most reStructuredText constructs including roles and directives
76+
77+
.. literalinclude:: /lsp/getting-started.rst
78+
:language: rst
79+
:start-at: .. relevant-to:: Editor
80+
:end-before: Emacs
81+
82+
However section titles are not supported.

0 commit comments

Comments
 (0)