Skip to content

Commit 144892d

Browse files
committed
[Documentation] Replace recommonmark by myst-parser
This is a bit rough, but i did that while trying to figure out if there would be a good way to do pre commit checks on RsT files. Recommonmark has been deprecated, then archived last year. This was tracked by: llvm/llvm-iwg#30 https://github.com/readthedocs/recommonmark Before merging that we would have to update the bots, which I'm not in a good position to do, so feel free to take over!
1 parent 84216d1 commit 144892d

File tree

7 files changed

+21
-94
lines changed

7 files changed

+21
-94
lines changed

.github/workflows/release-tasks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
doxygen \
3232
graphviz \
3333
python3-github \
34-
python3-recommonmark \
34+
python3-myst-parser \
3535
python3-sphinx \
3636
ninja-build \
3737
texlive-font-utils

clang/docs/conf.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,11 @@
3232
# Add any paths that contain templates here, relative to this directory.
3333
templates_path = ["_templates"]
3434

35-
# The suffix of source filenames.
36-
source_suffix = {
37-
".rst": "restructuredtext",
38-
}
3935

40-
try:
41-
import recommonmark
42-
except ImportError:
43-
# manpages do not use any .md sources
44-
if not tags.has("builder-man"):
45-
raise
46-
else:
47-
import sphinx
48-
49-
if sphinx.version_info >= (3, 0):
50-
# This requires 0.5 or later.
51-
extensions.append("recommonmark")
52-
else:
53-
source_parsers = {".md": "recommonmark.parser.CommonMarkParser"}
54-
source_suffix[".md"] = "markdown"
36+
import sphinx
37+
38+
if sphinx.version_info >= (3, 0):
39+
extensions.append("myst_parser")
5540

5641
# The encoding of source files.
5742
# source_encoding = 'utf-8-sig'

flang/docs/conf.py

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,14 @@
99
# All configuration values have a default; values that are commented out
1010
# serve to show the default.
1111

12-
import sys, os
1312
from datetime import date
14-
from recommonmark.parser import CommonMarkParser
15-
1613
# If extensions (or modules to document with autodoc) are in another directory,
1714
# add these directories to sys.path here. If the directory is relative to the
1815
# documentation root, use os.path.abspath to make it absolute, like shown here.
1916
# sys.path.insert(0, os.path.abspath('.'))
2017

2118
# -- General configuration -----------------------------------------------------
2219

23-
# https://github.com/readthedocs/recommonmark/issues/177
24-
# Method used to remove the warning message.
25-
class CustomCommonMarkParser(CommonMarkParser):
26-
def visit_document(self, node):
27-
pass
28-
29-
3020
# If your documentation needs a minimal Sphinx version, state it here.
3121
# needs_sphinx = '1.0'
3222
# Add any Sphinx extension module names here, as strings. They can be extensions
@@ -36,49 +26,11 @@ def visit_document(self, node):
3626
# Add any paths that contain templates here, relative to this directory.
3727
templates_path = ["_templates"]
3828

39-
# The suffix of source filenames.
40-
source_suffix = {
41-
".rst": "restructuredtext",
42-
}
43-
try:
44-
import recommonmark
45-
except ImportError:
46-
# manpages do not use any .md sources
47-
if not tags.has("builder-man"):
48-
raise
49-
else:
50-
import sphinx
51-
52-
if sphinx.version_info >= (3, 0):
53-
# This requires 0.5 or later.
54-
extensions.append("recommonmark")
55-
else:
56-
source_parsers = {".md": CustomCommonMarkParser}
57-
source_suffix[".md"] = "markdown"
58-
extensions.append("sphinx_markdown_tables")
59-
60-
# Setup AutoStructify for inline .rst toctrees in index.md
61-
from recommonmark.transform import AutoStructify
62-
63-
# Stolen from https://github.com/readthedocs/recommonmark/issues/93
64-
# Monkey patch to fix recommonmark 0.4 doc reference issues.
65-
from recommonmark.states import DummyStateMachine
66-
67-
orig_run_role = DummyStateMachine.run_role
68-
69-
def run_role(self, name, options=None, content=None):
70-
if name == "doc":
71-
name = "any"
72-
return orig_run_role(self, name, options, content)
73-
74-
DummyStateMachine.run_role = run_role
75-
76-
def setup(app):
77-
# Disable inline math to avoid
78-
# https://github.com/readthedocs/recommonmark/issues/120 in Extensions.md
79-
app.add_config_value("recommonmark_config", {"enable_inline_math": False}, True)
80-
app.add_transform(AutoStructify)
29+
import sphinx
8130

31+
if sphinx.version_info >= (3, 0):
32+
extensions.append("myst_parser")
33+
extensions.append("sphinx_markdown_tables")
8234

8335
# The encoding of source files.
8436
# source_encoding = 'utf-8-sig'

llvm/docs/MarkdownQuickstartTemplate.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ without any syntax highlighting like this:
151151

152152
If you need to do fancier things than what has been shown in this document,
153153
you can mail the list or check the [Common Mark spec]. Sphinx specific
154-
integration documentation can be found in the [recommonmark docs].
154+
integration documentation can be found in the [myst-parser docs].
155155

156156
[Common Mark spec]: http://spec.commonmark.org/0.28/
157-
[recommonmark docs]: http://recommonmark.readthedocs.io/en/latest/index.html
157+
[myst-parser docs]: https://myst-parser.readthedocs.io/en/latest/
158158

159159
## Generating the documentation
160160

llvm/docs/SphinxQuickstartTemplate.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,19 @@ You can generate the HTML documentation from the sources locally if you want to
172172
see what they would look like. In addition to the normal
173173
`build tools <docs/GettingStarted.html>`_
174174
you need to install `Sphinx`_ and the
175-
`recommonmark <https://recommonmark.readthedocs.io/en/latest/>`_ extension.
175+
`myst-parser <https://myst-parser.readthedocs.io/en/latest/>`_ extension.
176176

177177
On Debian you can install these with:
178178

179179
.. code-block:: console
180180
181-
sudo apt install -y sphinx-doc python-recommonmark-doc
181+
sudo apt install -y sphinx-doc python3-myst-parser
182182
183-
On Ubuntu use pip to get an up-to-date version of recommonmark:
183+
On Ubuntu use pip to get an up-to-date version of python3-myst-parser:
184184

185185
.. code-block:: console
186186
187-
sudo pip install sphinx recommonmark
187+
sudo pip install sphinx myst-parser
188188
189189
Then run cmake to build the documentation inside the ``llvm-project`` checkout:
190190

llvm/docs/conf.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,11 @@
3636
".rst": "restructuredtext",
3737
}
3838

39-
try:
40-
import recommonmark
41-
except ImportError:
42-
# manpages do not use any .md sources
43-
if not tags.has("builder-man"):
44-
raise
45-
else:
46-
import sphinx
47-
48-
if sphinx.version_info >= (3, 0):
49-
# This requires 0.5 or later.
50-
extensions.append("recommonmark")
51-
else:
52-
source_parsers = {".md": "recommonmark.parser.CommonMarkParser"}
53-
source_suffix[".md"] = "markdown"
39+
import sphinx
40+
41+
if sphinx.version_info >= (3, 0):
42+
extensions.append("myst_parser")
43+
extensions.append("sphinx_markdown_tables")
5444

5545
# The encoding of source files.
5646
# source_encoding = 'utf-8-sig'

llvm/utils/release/build-docs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# ninja-build gcc-c++
1616
# * pip install sphinx-markdown-tables
1717
# * Ubuntu:
18-
# * apt-get install doxygen sphinx-common python3-recommonmark \
18+
# * apt-get install doxygen sphinx-common python3-myst-parser \
1919
# ninja-build graphviz texlive-font-utils
2020
# * pip install sphinx-markdown-tables
2121
#===------------------------------------------------------------------------===#

0 commit comments

Comments
 (0)