Skip to content

Commit ebb5b9f

Browse files
authored
📚 Minor improvements to docs (#670)
1 parent 74b21f7 commit ebb5b9f

File tree

9 files changed

+63
-23
lines changed

9 files changed

+63
-23
lines changed

docs/docutils.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ The commands are based on the [Docutils Front-End Tools](https://docutils.source
3535
```
3636
:::
3737

38+
:::{versionadded} 0.19.0
39+
`myst-suppress-warnings` replicates the functionality of sphinx's [`suppress_warnings`](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-suppress_warnings) for `myst.` warnings in the `docutils` CLI.
40+
:::
41+
3842
The CLI commands can also utilise the [`docutils.conf` configuration file](https://docutils.sourceforge.io/docs/user/config.html) to configure the behaviour of the CLI commands. For example:
3943

4044
```

docs/faq/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ See the [](syntax/header-anchors) section of extended syntaxes.
142142
:::
143143

144144
If you'd like to *automatically* generate targets for each of your section headers,
145-
check out the [`autosectionlabel`](https://www.sphinx-doc.org/en/master/usage/extensions/autosectionlabel.html)
145+
check out the {external+sphinx:std:doc}`autosectionlabel <usage/extensions/autosectionlabel>`
146146
sphinx feature. You can activate it in your Sphinx site by adding the following to your
147147
`conf.py` file:
148148

@@ -179,7 +179,7 @@ Moved to [](myst-warnings)
179179
### Sphinx-specific page front matter
180180

181181
Sphinx intercepts front matter and stores them within the global environment
182-
(as discussed [in the deflists documentation](https://www.sphinx-doc.org/en/master/usage/restructuredtext/field-lists.html)).
182+
(as discussed in the {external+sphinx:std:doc}`sphinx documentation <usage/restructuredtext/field-lists>`.
183183
There are certain front-matter keys (or their translations) that are also recognised specifically by docutils and parsed to inline Markdown:
184184

185185
- `author`

docs/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ conda install -c conda-forge myst-parser
2828
(intro/sphinx)=
2929
## Enable MyST in Sphinx
3030

31-
To get started with Sphinx, see their [Quickstart Guide](https://www.sphinx-doc.org/en/master/usage/quickstart.html).
31+
To get started with Sphinx, see their {external+sphinx:std:doc}`quick-start guide <usage/quickstart>`.
3232

3333
To use the MyST parser in Sphinx, simply add the following to your `conf.py` file:
3434

docs/syntax/optional.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ myst:
1313
:width: 200px
1414
```
1515
key4: example
16+
confpy: sphinx `conf.py` {external+sphinx:std:doc}`configuration file <usage/configuration>`
1617
---
1718

1819
(syntax/extensions)=
@@ -53,12 +54,12 @@ myst_enable_extensions = [
5354

5455
## Typography
5556

56-
Adding `"smartquotes"` to `myst_enable_extensions` (in the sphinx `conf.py` [configuration file](https://www.sphinx-doc.org/en/master/usage/configuration.html)) will automatically convert standard quotations to their opening/closing variants:
57+
Adding `"smartquotes"` to `myst_enable_extensions` (in the {{ confpy }}) will automatically convert standard quotations to their opening/closing variants:
5758

5859
- `'single quotes'`: 'single quotes'
5960
- `"double quotes"`: "double quotes"
6061

61-
Adding `"replacements"` to `myst_enable_extensions` (in the sphinx `conf.py` [configuration file](https://www.sphinx-doc.org/en/master/usage/configuration.html)) will automatically convert some common typographic texts
62+
Adding `"replacements"` to `myst_enable_extensions` (in the {{ confpy }}) will automatically convert some common typographic texts
6263

6364
text | converted
6465
----- | ----------
@@ -95,7 +96,7 @@ and you will need to suppress the `myst.strikethrough` warning
9596
(syntax/math)=
9697
## Math shortcuts
9798

98-
Math is parsed by adding to the `myst_enable_extensions` list option, in the sphinx `conf.py` [configuration file](https://www.sphinx-doc.org/en/master/usage/configuration.html) one or both of:
99+
Math is parsed by adding to the `myst_enable_extensions` list option, in the {{ confpy }} one or both of:
99100

100101
- `"dollarmath"` for parsing of dollar `$` and `$$` encapsulated math.
101102
- `"amsmath"` for direct parsing of [amsmath LaTeX environments](https://ctan.org/pkg/amsmath).
@@ -230,7 +231,7 @@ See [the extended syntax option](syntax/amsmath).
230231
(syntax/mathjax)=
231232
### Mathjax and math parsing
232233
233-
When building HTML using the [sphinx.ext.mathjax](https://www.sphinx-doc.org/en/master/usage/extensions/math.html#module-sphinx.ext.mathjax) extension (enabled by default),
234+
When building HTML using the {external+sphinx:mod}`sphinx.ext.mathjax <sphinx.ext.mathjax>` extension (enabled by default),
234235
If `dollarmath` is enabled, Myst-Parser injects the `tex2jax_ignore` (MathJax v2) and `mathjax_ignore` (MathJax v3) classes in to the top-level section of each MyST document, and adds the following default MathJax configuration:
235236
236237
MathJax version 2 (see [the tex2jax preprocessor](https://docs.mathjax.org/en/v2.7-latest/options/preprocessors/tex2jax.html#configure-tex2jax):
@@ -252,7 +253,7 @@ To change this behaviour, set a custom regex, for identifying HTML classes to pr
252253
(syntax/linkify)=
253254
## Linkify
254255

255-
Adding `"linkify"` to `myst_enable_extensions` (in the sphinx `conf.py` [configuration file](https://www.sphinx-doc.org/en/master/usage/configuration.html)) will automatically identify "bare" web URLs and add hyperlinks:
256+
Adding `"linkify"` to `myst_enable_extensions` (in the {{ confpy }}) will automatically identify "bare" web URLs and add hyperlinks:
256257

257258
`www.example.com` -> www.example.com
258259

@@ -267,7 +268,7 @@ Either directly; `pip install linkify-it-py` or *via* `pip install myst-parser[l
267268

268269
## Substitutions (with Jinja2)
269270

270-
Adding `"substitution"` to `myst_enable_extensions` (in the sphinx `conf.py` [configuration file](https://www.sphinx-doc.org/en/master/usage/configuration.html)) will allow you to add substitutions, added in either the `conf.py` using `myst_substitutions`:
271+
Adding `"substitution"` to `myst_enable_extensions` (in the {{ confpy }}) will allow you to add substitutions, added in either the `conf.py` using `myst_substitutions`:
271272

272273
```python
273274
myst_substitutions = {
@@ -352,7 +353,7 @@ This may lead to unexpected outcomes.
352353

353354
:::
354355

355-
Substitution references are assessed as [Jinja2 expressions](http://jinja.palletsprojects.com) which can use [filters](https://jinja.palletsprojects.com/en/2.11.x/templates/#list-of-builtin-filters), and also contains the [Sphinx Environment](https://www.sphinx-doc.org/en/master/extdev/envapi.html) in the context (as `env`).
356+
Substitution references are assessed as [Jinja2 expressions](http://jinja.palletsprojects.com) which can use [filters](https://jinja.palletsprojects.com/en/2.11.x/templates/#list-of-builtin-filters), and also contains the {external+sphinx:std:doc}`Sphinx Environment <extdev/envapi>` in the context (as `env`).
356357
Therefore you can do things like:
357358

358359
```md
@@ -400,7 +401,7 @@ However, since Jinja2 substitutions allow for Python methods to be used, you can
400401

401402
## Code fences using colons
402403

403-
By adding `"colon_fence"` to `myst_enable_extensions` (in the sphinx `conf.py` [configuration file](https://www.sphinx-doc.org/en/master/usage/configuration.html)),
404+
By adding `"colon_fence"` to `myst_enable_extensions` (in the {{ confpy }}),
404405
you can also use `:::` delimiters to denote code fences, instead of ```` ``` ````.
405406

406407
Using colons instead of back-ticks has the benefit of allowing the content to be rendered correctly, when you are working in any standard Markdown editor.
@@ -537,7 +538,7 @@ $ myst-anchors -l 2 docs/syntax/optional.md
537538

538539
## Definition Lists
539540

540-
By adding `"deflist"` to `myst_enable_extensions` (in the sphinx `conf.py` [configuration file](https://www.sphinx-doc.org/en/master/usage/configuration.html)),
541+
By adding `"deflist"` to `myst_enable_extensions` (in the {{ confpy }}),
541542
you will be able to utilise definition lists.
542543
Definition lists utilise the [markdown-it-py deflist plugin](markdown_it:md/plugins), which itself is based on the [Pandoc definition list specification](http://johnmacfarlane.net/pandoc/README.html#definition-lists).
543544

@@ -616,7 +617,7 @@ Term 3
616617
(syntax/tasklists)=
617618
## Task Lists
618619

619-
By adding `"tasklist"` to `myst_enable_extensions` (in the sphinx `conf.py` [configuration file](https://www.sphinx-doc.org/en/master/usage/configuration.html)),
620+
By adding `"tasklist"` to `myst_enable_extensions` (in the {{ confpy }}),
620621
you will be able to utilise task lists.
621622
Task lists utilise the [markdown-it-py tasklists plugin](markdown_it:md/plugins),
622623
and are applied to markdown list items starting with `[ ]` or `[x]`:
@@ -725,7 +726,7 @@ Currently `sphinx.ext.autodoc` does not support MyST, see [](howto/autodoc).
725726
(syntax/attributes)=
726727
## Inline attributes
727728

728-
By adding `"attrs_inline"` to `myst_enable_extensions` (in the sphinx `conf.py` [configuration file](https://www.sphinx-doc.org/en/master/usage/configuration.html)),
729+
By adding `"attrs_inline"` to `myst_enable_extensions` (in the {{ confpy }}),
729730
you can enable parsing of inline attributes after certain inline syntaxes.
730731
This is adapted from [djot inline attributes](https://htmlpreview.github.io/?https://github.com/jgm/djot/blob/master/doc/syntax.html#inline-attributes),
731732
and also related to [pandoc bracketed spans](https://pandoc.org/MANUAL.html#extension-bracketed_spans).
@@ -844,7 +845,7 @@ This is usually a bad option, because the HTML is treated as raw text during the
844845

845846
HTML parsing to the rescue!
846847

847-
By adding `"html_image"` to `myst_enable_extensions` (in the sphinx `conf.py` [configuration file](https://www.sphinx-doc.org/en/master/usage/configuration.html)),
848+
By adding `"html_image"` to `myst_enable_extensions` (in the {{ confpy }}),
848849
MySt-Parser will attempt to convert any isolated `img` tags (i.e. not wrapped in any other HTML) to the internal representation used in sphinx.
849850

850851
```html
@@ -866,7 +867,7 @@ I'm an inline image: <img src="img/fun-fish.png" height="20px">
866867

867868
## Markdown Figures
868869

869-
By adding `"colon_fence"` to `myst_enable_extensions` (in the sphinx `conf.py` [configuration file](https://www.sphinx-doc.org/en/master/usage/configuration.html)),
870+
By adding `"colon_fence"` to `myst_enable_extensions` (in the {{ confpy }}),
870871
we can combine the above two extended syntaxes,
871872
to create a fully Markdown compliant version of the `figure` directive named `figure-md`.
872873

@@ -908,7 +909,7 @@ As we see here, the target we set can be referenced:
908909

909910
## HTML Admonitions
910911

911-
By adding `"html_admonition"` to `myst_enable_extensions` (in the sphinx `conf.py` [configuration file](https://www.sphinx-doc.org/en/master/usage/configuration.html)),
912+
By adding `"html_admonition"` to `myst_enable_extensions` (in the {{ confpy }}),
912913
you can enable parsing of `<div class="admonition">` HTML blocks.
913914
These blocks will be converted internally to Sphinx admonition directives, and so will work correctly for all output formats.
914915
This is helpful when you care about viewing the "source" Markdown, such as in Jupyter Notebooks.
@@ -974,7 +975,7 @@ You can also nest HTML admonitions:
974975

975976
## Direct LaTeX Math
976977

977-
By adding `"amsmath"` to `myst_enable_extensions` (in the sphinx `conf.py` [configuration file](https://www.sphinx-doc.org/en/master/usage/configuration.html)),
978+
By adding `"amsmath"` to `myst_enable_extensions` (in the {{ confpy }}),
978979
you can enable direct parsing of [amsmath](https://ctan.org/pkg/amsmath) LaTeX equations.
979980
These top-level math environments will then be directly parsed:
980981

docs/syntax/roles-and-directives.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
Roles and directives provide a way to extend the syntax of MyST in an unbound manner,
66
by interpreting a chuck of text as a specific type of markup, according to its name.
77

8-
Mostly all [docutils roles](https://docutils.sourceforge.io/docs/ref/rst/roles.html), [docutils directives](https://docutils.sourceforge.io/docs/ref/rst/directives.html), [sphinx roles](https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html), or [sphinx directives](https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html) can be used in MyST.
8+
Mostly all
9+
[docutils roles](https://docutils.sourceforge.io/docs/ref/rst/roles.html),
10+
[docutils directives](https://docutils.sourceforge.io/docs/ref/rst/directives.html),
11+
{external+sphinx:std:doc}`Sphinx roles <usage/restructuredtext/roles>`, or
12+
{external+sphinx:std:doc}`Sphinx directives <usage/restructuredtext/directives>`
13+
can be used in MyST.
914

1015
## Syntax
1116

docs/syntax/syntax.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ would be equivalent to:
8585
### Setting HTML Metadata
8686

8787
The front-matter can contain the special key `html_meta`; a dict with data to add to the generated HTML as [`<meta>` elements](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta).
88-
This is equivalent to using the [RST `meta` directive](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#html-metadata).
88+
This is equivalent to using the {external+sphinx:ref}`meta directive <html-meta>`.
8989

9090
HTML metadata can also be added globally in the `conf.py` *via* the `myst_html_meta` variable, in which case it will be added to all MyST documents.
9191
For each document, the `myst_html_meta` dict will be updated by the document level front-matter `html_meta`, with the front-matter taking precedence.
@@ -257,7 +257,8 @@ Target headers are defined with this syntax:
257257
(header_target)=
258258
```
259259

260-
They can then be referred to with the [ref inline role](https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-ref):
260+
They can then be referred to with the
261+
{external+sphinx:ref}`ref inline role <ref-role>`:
261262

262263
```md
263264
{ref}`header_target`
@@ -277,7 +278,7 @@ Alternatively using the markdown syntax:
277278
[my text](header_target)
278279
```
279280

280-
is equivalent to using the [any inline role](https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-any):
281+
is equivalent to using the {external+sphinx:ref}`any inline role <any-role>`:
281282

282283
```md
283284
{any}`my text <header_target>`

myst_parser/inventory.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,12 @@ def inventory_cli(inputs: None | list[str] = None):
320320
metavar="NAME",
321321
help="Filter the inventory by reference name pattern",
322322
)
323+
parser.add_argument(
324+
"-l",
325+
"--loc",
326+
metavar="LOC",
327+
help="Filter the inventory by reference location pattern",
328+
)
323329
parser.add_argument(
324330
"-f",
325331
"--format",
@@ -363,6 +369,15 @@ def inventory_cli(inputs: None | list[str] = None):
363369
if fnmatchcase(n, args.name)
364370
}
365371

372+
if args.loc:
373+
for domain in invdata["objects"]:
374+
for otype in list(invdata["objects"][domain]):
375+
invdata["objects"][domain][otype] = {
376+
n: i
377+
for n, i in invdata["objects"][domain][otype].items()
378+
if fnmatchcase(i["loc"], args.loc)
379+
}
380+
366381
# clean up empty items
367382
for domain in list(invdata["objects"]):
368383
for otype in list(invdata["objects"][domain]):

tests/test_inventory.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ def test_inv_filter_fnmatch(data_regression):
3737
data_regression.check(output)
3838

3939

40-
@pytest.mark.parametrize("options", [(), ("-d", "std"), ("-o", "doc"), ("-n", "ref")])
40+
@pytest.mark.parametrize(
41+
"options", [(), ("-d", "std"), ("-o", "doc"), ("-n", "ref"), ("-l", "index.html*")]
42+
)
4143
def test_inv_cli_v2(options, capsys, file_regression):
4244
inventory_cli([str(STATIC / "objects_v2.inv"), "-f", "yaml", *options])
4345
text = capsys.readouterr().out.strip() + "\n"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Python
2+
version: ''
3+
objects:
4+
std:
5+
label:
6+
ref:
7+
loc: index.html#ref
8+
text: Title
9+
doc:
10+
index:
11+
loc: index.html
12+
text: Title

0 commit comments

Comments
 (0)