Skip to content

Commit 7060ee7

Browse files
dgarcia360tchaikov
authored andcommitted
docs: add myst parser
(cherry picked from commit 9eedcac)
1 parent a044b1c commit 7060ee7

File tree

4 files changed

+28
-53
lines changed

4 files changed

+28
-53
lines changed

docs/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ setupenv:
2525
setup:
2626
$(POETRY) install
2727
$(POETRY) update
28-
cp -TLr source $(SOURCEDIR)
28+
@if [ ! -d "$(SOURCEDIR)" ]; then mkdir -p "$(SOURCEDIR)"; fi
29+
cp -RL source/* $(SOURCEDIR)
2930
cd $(SOURCEDIR) && find . -name README.md -execdir mv '{}' index.md ';'
3031

3132
# Clean commands

docs/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ authors = ["Java Driver Contributors"]
88
python = "^3.9"
99
pyyaml = "6.0.1"
1010
pygments = "2.15.1"
11-
recommonmark = "0.7.1"
1211
redirects_cli ="~0.1.3"
1312
sphinx-scylladb-theme = "~1.6.1"
1413
sphinx-sitemap = "2.5.1"
@@ -17,6 +16,7 @@ Sphinx = "7.2.6"
1716
sphinx-multiversion-scylla = "~0.3.1"
1817
setuptools = "^65.6.3"
1918
wheel = "^0.38.4"
19+
sphinx-scylladb-markdown = "^0.1.2"
2020

2121
[build-system]
2222
requires = ["poetry>=0.12"]

docs/source/conf.py

Lines changed: 24 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
# -*- coding: utf-8 -*-
22

33
import os
4-
import sys
5-
from datetime import date
6-
import yaml
74
import re
8-
from docutils import nodes
9-
from recommonmark.transform import AutoStructify
10-
from recommonmark.parser import CommonMarkParser, splitext, urlparse
5+
from datetime import date
6+
from pathlib import Path
117
from sphinx_scylladb_theme.utils import multiversion_regex_builder
128
from redirects_cli import cli as redirects_cli
139

@@ -47,6 +43,7 @@
4743
'sphinx.ext.autosectionlabel',
4844
'sphinx_scylladb_theme',
4945
'sphinx_multiversion',
46+
'sphinx_scylladb_markdown'
5047
]
5148

5249
# Add any paths that contain templates here, relative to this directory.
@@ -88,6 +85,23 @@
8885
# Prefix added to all the URLs generated in the 404 page.
8986
notfound_urls_prefix = ''
9087

88+
# -- Options for markdown extension
89+
scylladb_markdown_enable = True
90+
scylladb_markdown_recommonmark_versions = [
91+
'scylla-3.7.2.x',
92+
'scylla-3.10.2.x',
93+
'scylla-3.11.0.x',
94+
'scylla-3.11.2.x',
95+
'scylla-4.7.2.x',
96+
'scylla-4.10.0.x',
97+
'scylla-4.11.1.x',
98+
'scylla-4.12.0.x',
99+
'scylla-4.13.0.x',
100+
'scylla-4.14.1.x',
101+
'scylla-4.15.0.x',
102+
]
103+
suppress_warnings = ["ref.any", "myst.header","myst.xref_missing"]
104+
91105
# -- Options for multiversion extension
92106

93107
# Whitelist pattern for tags
@@ -151,57 +165,20 @@
151165

152166
# Dictionary of values to pass into the template engine’s context for all pages
153167
html_context = {'html_baseurl': html_baseurl}
154-
155-
# -- Initialize Sphinx
156-
157-
class CustomCommonMarkParser(CommonMarkParser):
158-
159-
def visit_document(self, node):
160-
pass
161-
162-
def visit_link(self, mdnode):
163-
# Override MarkDownParser to avoid checking if relative links exists
164-
ref_node = nodes.reference()
165-
destination = mdnode.destination
166-
_, ext = splitext(destination)
167-
168-
url_check = urlparse(destination)
169-
scheme_known = bool(url_check.scheme)
170-
171-
if not scheme_known and ext.replace('.', '') in self.supported:
172-
destination = destination.replace(ext, '')
173-
ref_node['refuri'] = destination
174-
ref_node.line = self._get_line(mdnode)
175-
if mdnode.title:
176-
ref_node['title'] = mdnode.title
177-
next_node = ref_node
178-
179-
self.current_node.append(next_node)
180-
self.current_node = ref_node
181-
182168
def replace_relative_links(app, docname, source):
183169
result = source[0]
184170
for key in app.config.replacements:
185171
result = re.sub(key, app.config.replacements[key], result)
186172
source[0] = result
187173

188-
189-
def build_finished(app, exception):
174+
def redirect_api_page_to_javadoc(app, exception):
190175
version_name = os.getenv("SPHINX_MULTIVERSION_NAME", "")
191176
version_name = "/" + version_name if version_name else ""
192177
redirect_to = version_name +'/api/index.html'
193-
out_file = app.outdir +'/api.html'
194-
redirects_cli.create(redirect_to=redirect_to,out_file=out_file)
178+
out_file = Path(app.outdir) / 'api.html'
179+
redirects_cli.create(redirect_to=redirect_to, out_file=str(out_file))
195180

196181
def setup(app):
197-
# Setup Markdown parser
198-
app.add_source_parser(CustomCommonMarkParser)
199-
app.add_config_value('recommonmark_config', {
200-
'enable_eval_rst': True,
201-
'enable_auto_toc_tree': False,
202-
}, True)
203-
app.add_transform(AutoStructify)
204-
205182
# Replace DataStax links
206183
current_slug = os.getenv("SPHINX_MULTIVERSION_NAME", "stable")
207184
replacements = {
@@ -210,7 +187,4 @@ def setup(app):
210187
}
211188
app.add_config_value('replacements', replacements, True)
212189
app.connect('source-read', replace_relative_links)
213-
214-
# Create redirect to JavaDoc API
215-
app.connect('build-finished', build_finished)
216-
190+
app.connect('build-finished', redirect_api_page_to_javadoc)

manual/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Common topics:
3434
* [Case sensitivity](case_sensitivity/)
3535
* [OSGi](osgi/)
3636

37-
```eval_rst
37+
```{eval-rst}
3838
.. toctree::
3939
:hidden:
4040
:glob:

0 commit comments

Comments
 (0)