Skip to content

Commit 022d397

Browse files
committed
📚 DOCS: Full update
1 parent 3e06b80 commit 022d397

31 files changed

+2543
-1523
lines changed

CHANGELOG.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Full Changelog: [v0.17.2...v0.18.0](https://github.com/executablebooks/MyST-Pars
1616

1717
This release adds support for Sphinx v5 (dropping v3), restructures the code base into modules, and also restructures the documentation, to make it easier for developers/users to follow.
1818

19-
It also introduces **document-level configuration** *via* the Markdown top-matter, under the `myst` key.
19+
It also introduces **document-level configuration** *via* the Markdown front-matter, under the `myst` key.
2020
See the [Local configuration](docs/configuration.md) section for more information.
2121

2222
### Breaking changes
@@ -28,7 +28,7 @@ The `to_docutils`, `to_html`, `to_tokens` (from `myst_parser/main.py`) and `mock
2828
Instead, for single page builds, users should use the docutils parser API/CLI (see [](docs/docutils.md)),
2929
and for testing, functionality has been moved to <https://github.com/chrisjsewell/sphinx-pytest>.
3030

31-
The top-level `html_meta` and `substitutions` top-matter keys have also been deprecated (i.e. they will still work but will emit a warning), as they now form part of the `myst` config, e.g.
31+
The top-level `html_meta` and `substitutions` front-matter keys have also been deprecated (i.e. they will still work but will emit a warning), as they now form part of the `myst` config, e.g.
3232

3333
```yaml
3434
---
@@ -100,7 +100,7 @@ In addition, configuration to more finely tune this behaviour has been added.
100100
- `myst_url_schemes=("http", "https")`, sets what URL schemes are treated as (1)
101101
- `myst_ref_domains=("std", "py")`, sets what Sphinx reference domains are checked, when handling (3)
102102

103-
See [Markdown Links and Referencing](docs/syntax/syntax.md#markdown-links-and-referencing) for more information.
103+
See [Markdown Links and Referencing](docs/syntax/cross-referencing.md) for more information.
104104

105105
### ‼️ Dollarmath is now disabled by default
106106

@@ -143,7 +143,7 @@ would be equivalent to:
143143
# My Title with *emphasis*
144144
```
145145

146-
See [Front matter](docs/syntax/syntax.md#front-matter) for more information.
146+
See [Front matter](docs/configuration.md) for more information.
147147

148148
### 👌 Internal improvements
149149

@@ -291,7 +291,7 @@ is converted to:
291291

292292
These classes should be supported by most sphinx HTML themes.
293293

294-
See [Tables syntax](docs/syntax/syntax.md#tables) for more information.
294+
See [Tables syntax](docs/syntax/tables.md) for more information.
295295

296296
### Pull Requests
297297

@@ -382,7 +382,7 @@ In particular for users, this update alters the parsing of tables to be consiste
382382
> {sub-ref}`today` | {sub-ref}`wordcount-words` words | {sub-ref}`wordcount-minutes` min read
383383
```
384384

385-
See [the roles syntax guide](docs/syntax/syntax.md) for further information.
385+
See [the roles syntax guide](docs/syntax/roles-and-directives.md) for further information.
386386

387387
- The **`dmath_double_inline`** configuration option allows display math (i.e. `$$`) within an inline context.
388388
See [the math syntax guide](docs/syntax/optional.md#math-shortcuts) for further information.
@@ -467,7 +467,7 @@ Minor fixes:
467467
: If the label is an integer, then it will always use this integer for the rendered label (i.e. they are manually numbered).
468468
: Add `myst_footnote_transition` configuration, to turn on/off transition line.
469469
: Add `footnotes` class to transition `<hr>` in HTML.
470-
: See [the syntax guide](docs/syntax/syntax.md) for further information.
470+
: See [the typography guide](docs/syntax/typography.md) for further information.
471471

472472
👌 IMPROVE: `substitution` extension logic
473473

docs/_static/local.css

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
1+
/** landing page logo **/
2+
#landing-page-logo {
3+
background: none;
4+
}
5+
16
/** Add a counter before subsections **/
2-
h1 {
7+
h1:not(.rubric) {
38
counter-reset: subsection;
49
text-decoration: underline;
510
}
6-
h2 {
7-
counter-reset: subsubsection;
8-
}
9-
h2::before {
10-
counter-increment: subsection;
11-
content: counter(subsection) ". ";
12-
}
13-
.tippy-box h2::before {
14-
content: unset;
15-
}
16-
h3::before {
17-
counter-increment: subsubsection;
18-
content: counter(subsection) "." counter(subsubsection) ". ";
19-
}
20-
.tippy-box h3::before {
21-
content: unset;
22-
}
2311

2412
/** MyST examples */
2513
.myst-example {
@@ -35,6 +23,9 @@ h3::before {
3523
.myst-example-render {
3624
padding: 0.5rem;
3725
}
26+
.myst-example-render > :first-child {
27+
margin-top: 0.5rem;
28+
}
3829

3930
/** No icon for admonitions with no-icon class */
4031
div.admonition.no-icon > .admonition-title::before {
@@ -45,24 +36,30 @@ div.admonition.no-icon > .admonition-title {
4536
}
4637

4738
/* Live preview page */
48-
iframe.pyscript, textarea.pyscript {
49-
width: 100%;
50-
height: 100%;
51-
min-height: 300px;
52-
}
53-
div.pyscript {
54-
min-height: 300px;
55-
}
56-
iframe.pyscript {
57-
padding: 4px;
39+
@media (min-width: 768px) {
40+
.preview-input-tabs {
41+
height: 100%;
42+
}
43+
textarea.pyscript.input {
44+
height: 100%;
45+
}
5846
}
5947
textarea.pyscript {
48+
width: 100%;
49+
min-height: 300px;
6050
padding: 30px 20px 20px;
6151
border-radius: 8px;
6252
resize: vertical;
6353
font-size: 16px;
6454
font-family: monospace;
6555
}
56+
textarea.pyscript.output {
57+
height: 100%;
58+
}
59+
div.pyscript {
60+
min-height: 300px;
61+
}
62+
6663
.display-flex {
6764
display: flex;
6865
}

docs/conf.py

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
# list see the documentation:
55
# https://www.sphinx-doc.org/en/master/usage/configuration.html
66

7+
import hashlib
78
from datetime import date
9+
from pathlib import Path
810

911
from sphinx.application import Sphinx
10-
from sphinx.transforms.post_transforms import SphinxPostTransform
1112

1213
from myst_parser import __version__
1314

@@ -32,6 +33,7 @@
3233
"sphinx.ext.intersphinx",
3334
"sphinx.ext.viewcode",
3435
"sphinx.ext.autodoc",
36+
"sphinx.ext.autosummary",
3537
"sphinx_design",
3638
"sphinx_copybutton",
3739
"sphinxext.rediraffe",
@@ -40,6 +42,7 @@
4042
"sphinxext.opengraph",
4143
"sphinx_pyscript",
4244
"sphinx_tippy",
45+
"sphinx_togglebutton",
4346
]
4447

4548
# Add any paths that contain templates here, relative to this directory.
@@ -61,6 +64,7 @@
6164
# -- Autodoc settings ---------------------------------------------------
6265

6366
autodoc2_packages = ["../myst_parser"]
67+
autodoc2_exclude_files = ["_docs.py"]
6468
autodoc2_hidden_objects = ["dunder", "private", "inherited"]
6569
autodoc2_replace_annotations = [
6670
("re.Pattern", "typing.Pattern"),
@@ -71,9 +75,14 @@
7175
("myst_parser._compat.TypedDict", "typing.TypedDict"),
7276
("sphinx.directives.SphinxDirective", "sphinx.util.docutils.SphinxDirective"),
7377
]
78+
autodoc2_docstring_parser_regexes = [
79+
("myst_parser", "myst"),
80+
(r"myst_parser\.setup", "myst"),
81+
]
7482
nitpicky = True
7583
nitpick_ignore_regex = [
7684
(r"py:.*", r"docutils\..*"),
85+
(r"py:.*", r"pygments\..*"),
7786
]
7887
nitpick_ignore = [
7988
("py:obj", "myst_parser._docs._ConfigBase"),
@@ -101,7 +110,6 @@
101110
"tasklist",
102111
"attrs_inline",
103112
"attrs_block",
104-
"inv_link",
105113
]
106114
myst_url_schemes = {
107115
"http": None,
@@ -131,6 +139,10 @@
131139
myst_footnote_transition = True
132140
myst_dmath_double_inline = True
133141
myst_enable_checkboxes = True
142+
myst_substitutions = {
143+
"role": "[role](#syntax/roles)",
144+
"directive": "[directive](#syntax/directives)",
145+
}
134146

135147
# -- HTML output -------------------------------------------------
136148

@@ -146,6 +158,7 @@
146158
"path_to_docs": "docs",
147159
"use_repository_button": True,
148160
"use_edit_page_button": True,
161+
"use_issues_button": True,
149162
}
150163
# OpenGraph metadata
151164
ogp_site_url = "https://myst-parser.readthedocs.io/en/latest"
@@ -163,6 +176,7 @@
163176

164177
rediraffe_redirects = {
165178
"using/intro.md": "sphinx/intro.md",
179+
"syntax/syntax.md": "syntax/typography.md",
166180
"sphinx/intro.md": "intro.md",
167181
"using/use_api.md": "api/index.md",
168182
"api/index.md": "api/reference.rst",
@@ -191,46 +205,40 @@
191205
# -- Local Sphinx extensions -------------------------------------------------
192206

193207

194-
class StripUnsupportedLatex(SphinxPostTransform):
195-
"""Remove unsupported nodes from the doctree."""
196-
197-
default_priority = 900
198-
199-
def run(self):
200-
if self.app.builder.format != "latex":
201-
return
202-
from docutils import nodes
203-
204-
for node in self.document.findall():
205-
if node.tagname == "image" and node["uri"].endswith(".svg"):
206-
node.parent.replace(node, nodes.inline("", "Removed SVG image"))
207-
if node.tagname == "mermaid":
208-
node.parent.replace(node, nodes.inline("", "Removed Mermaid diagram"))
209-
210-
211208
def setup(app: Sphinx):
212209
"""Add functions to the Sphinx setup."""
213210
from myst_parser._docs import (
214211
DirectiveDoc,
215212
DocutilsCliHelpDirective,
213+
MystAdmonitionDirective,
216214
MystConfigDirective,
217215
MystExampleDirective,
216+
MystLexer,
217+
MystToHTMLDirective,
218218
MystWarningsDirective,
219+
NumberSections,
220+
StripUnsupportedLatex,
219221
)
220222

221223
app.add_directive("myst-config", MystConfigDirective)
222224
app.add_directive("docutils-cli-help", DocutilsCliHelpDirective)
223225
app.add_directive("doc-directive", DirectiveDoc)
224226
app.add_directive("myst-warnings", MystWarningsDirective)
225227
app.add_directive("myst-example", MystExampleDirective)
228+
app.add_directive("myst-admonitions", MystAdmonitionDirective)
229+
app.add_directive("myst-to-html", MystToHTMLDirective)
226230
app.add_post_transform(StripUnsupportedLatex)
231+
app.add_post_transform(NumberSections)
227232
app.connect("html-page-context", add_version_to_css)
233+
app.add_lexer("myst", MystLexer)
228234

229235

230-
def add_version_to_css(app, pagename, templatename, context, doctree):
236+
def add_version_to_css(app: Sphinx, pagename, templatename, context, doctree):
231237
"""Add the version number to the local.css file, to bust the cache for changes."""
232238
if app.builder.name != "html":
233239
return
234240
if "_static/local.css" in context.get("css_files", {}):
241+
css = Path(app.srcdir, "_static/local.css").read_text("utf8")
242+
hashed = hashlib.sha256(css.encode("utf-8")).hexdigest()
235243
index = context["css_files"].index("_static/local.css")
236-
context["css_files"][index] = f"_static/local.css?v={__version__}"
244+
context["css_files"][index] = f"_static/local.css?hash={hashed}"

0 commit comments

Comments
 (0)