Skip to content

Commit 9eedcac

Browse files
dgarcia360roydahan
authored andcommitted
docs: add myst parser
1 parent fb2a7fa commit 9eedcac

File tree

11 files changed

+34
-59
lines changed

11 files changed

+34
-59
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.7.2"
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 & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
# -*- coding: utf-8 -*-
22

33
import os
4-
from datetime import date
54
import re
6-
from docutils import nodes
7-
from recommonmark.transform import AutoStructify
8-
from recommonmark.parser import CommonMarkParser, splitext, urlparse
5+
from datetime import date
6+
from pathlib import Path
97
from sphinx_scylladb_theme.utils import multiversion_regex_builder
108
from redirects_cli import cli as redirects_cli
119

@@ -45,6 +43,7 @@
4543
'sphinx.ext.autosectionlabel',
4644
'sphinx_scylladb_theme',
4745
'sphinx_multiversion',
46+
'sphinx_scylladb_markdown'
4847
]
4948

5049
# Add any paths that contain templates here, relative to this directory.
@@ -86,6 +85,23 @@
8685
# Prefix added to all the URLs generated in the 404 page.
8786
notfound_urls_prefix = ''
8887

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+
89105
# -- Options for multiversion extension
90106

91107
# Whitelist pattern for tags
@@ -149,57 +165,20 @@
149165

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

186-
187-
def build_finished(app, exception):
174+
def redirect_api_page_to_javadoc(app, exception):
188175
version_name = os.getenv("SPHINX_MULTIVERSION_NAME", "")
189176
version_name = "/" + version_name if version_name else ""
190177
redirect_to = version_name +'/api/index.html'
191-
out_file = app.outdir +'/api.html'
192-
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))
193180

194181
def setup(app):
195-
# Setup Markdown parser
196-
app.add_source_parser(CustomCommonMarkParser)
197-
app.add_config_value('recommonmark_config', {
198-
'enable_eval_rst': True,
199-
'enable_auto_toc_tree': False,
200-
}, True)
201-
app.add_transform(AutoStructify)
202-
203182
# Replace DataStax links
204183
current_slug = os.getenv("SPHINX_MULTIVERSION_NAME", "stable")
205184
replacements = {
@@ -208,7 +187,5 @@ def setup(app):
208187
}
209188
app.add_config_value('replacements', replacements, True)
210189
app.connect('source-read', replace_relative_links)
211-
212-
# Create redirect to JavaDoc API
213-
app.connect('build-finished', build_finished)
190+
app.connect('build-finished', redirect_api_page_to_javadoc)
214191

faq/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,6 @@ and we've had many reports where the problem turned out to be in user code.
157157

158158
See [Blobs.java] in the `driver-examples` module for some examples and explanations.
159159

160-
[Blobs.java]: https://github.com/datastax/java-driver/tree/3.x/driver-examples/src/main/java/com/datastax/driver/examples/datatypes/Blobs.java
161-
162-
163160
### How do I use the driver in an OSGi application?
164161

165162
Read our [OSGi-specific FAQ section](osgi/) to find out.

faq/osgi/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
```eval_rst
1+
```{eval-rst}
22
:orphan:
33
```
44
## Frequently Asked Questions - OSGi

manual/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ simply navigate to each sub-directory.
306306
[NoHostAvailableException]: https://docs.datastax.com/en/drivers/java/3.11/com/datastax/driver/core/exceptions/NoHostAvailableException.html
307307
[LocalDate]: https://docs.datastax.com/en/drivers/java/3.11/com/datastax/driver/core/LocalDate.html
308308

309-
```eval_rst
309+
```{eval-rst}
310310
.. toctree::
311311
:hidden:
312312
:glob:

manual/custom_codecs/extras/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
```eval_rst
1+
```{eval-rst}
22
:orphan:
33
```
44
## Optional codecs

manual/object_mapper/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ See the child pages for more information:
2121
* [using the mapper](using/)
2222
* [using custom codecs](custom_codecs/)
2323

24-
```eval_rst
24+
```{eval-rst}
2525
.. toctree::
2626
:hidden:
2727
:glob:

manual/statements/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ wrap your statements in a custom [StatementWrapper] implementation.
4141
[execute]: https://docs.datastax.com/en/drivers/java/3.11/com/datastax/driver/core/Session.html#execute-com.datastax.driver.core.Statement-
4242
[executeAsync]: https://docs.datastax.com/en/drivers/java/3.11/com/datastax/driver/core/Session.html#executeAsync-com.datastax.driver.core.Statement-
4343

44-
```eval_rst
44+
```{eval-rst}
4545
.. toctree::
4646
:hidden:
4747
:glob:

upgrade_guide/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ exhaustive list of new features in 2.0.
827827
(`ResultSet#getAvailableWithoutFetching` and `ResultSet#isFullyFetched`)
828828
as well as a mean to force the pre-fetching of the next page (`ResultSet#fetchMoreResults`).
829829

830-
```eval_rst
830+
```{eval-rst}
831831
.. toctree::
832832
:hidden:
833833
:glob:

upgrade_guide/migrating_from_astyanax/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ See the child pages for more information:
99
* [Migrating Astyanax configurations to DataStax Java driver configurations](configuration/)
1010
* [Querying and retrieving results comparisons.](queries_and_results/)
1111

12-
```eval_rst
12+
```{eval-rst}
1313
.. toctree::
1414
:hidden:
1515
:glob:

0 commit comments

Comments
 (0)