Skip to content

Commit fb04594

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

File tree

15 files changed

+39
-64
lines changed

15 files changed

+39
-64
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:

manual/core/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ for (ColumnDefinitions.Definition definition : row.getColumnDefinitions()) {
351351

352352
[CASSANDRA-10145]: https://issues.apache.org/jira/browse/CASSANDRA-10145
353353

354-
```eval_rst
354+
```{eval-rst}
355355
.. toctree::
356356
:hidden:
357357
:glob:

manual/core/configuration/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ config.getDefaultProfile().getInt(MyCustomOption.AWESOMENESS_FACTOR);
556556
[HOCON]: https://github.com/typesafehub/config/blob/master/HOCON.md
557557
[API conventions]: ../../api_conventions
558558

559-
```eval_rst
559+
```{eval-rst}
560560
.. toctree::
561561
:hidden:
562562
:glob:

manual/core/metadata/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ refreshed. See the [Performance](../performance/#debouncing) page for more detai
7979
[Metadata]: https://docs.datastax.com/en/drivers/java/4.17/com/datastax/oss/driver/api/core/metadata/Metadata.html
8080
[Node]: https://docs.datastax.com/en/drivers/java/4.17/com/datastax/oss/driver/api/core/metadata/Node.html
8181

82-
```eval_rst
82+
```{eval-rst}
8383
.. toctree::
8484
:hidden:
8585
:glob:

manual/core/statements/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ can create execution profiles to capture common combinations of those options).
8383
[execute]: https://docs.datastax.com/en/drivers/java/4.17/com/datastax/oss/driver/api/core/session/Session.html#execute-com.datastax.oss.driver.api.core.cql.Statement-
8484
[executeAsync]: https://docs.datastax.com/en/drivers/java/4.17/com/datastax/oss/driver/api/core/session/Session.html#executeAsync-com.datastax.oss.driver.api.core.cql.Statement-
8585

86-
```eval_rst
86+
```{eval-rst}
8787
.. toctree::
8888
:hidden:
8989
:glob:

manual/developer/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ from lowest to highest level:
3737

3838
If you're reading this on GitHub, the `.nav` file in each directory contains a suggested order.
3939

40-
```eval_rst
40+
```{eval-rst}
4141
.. toctree::
4242
:hidden:
4343
:glob:

manual/developer/common/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This covers utilities or concept that are shared throughout the codebase:
2727
* the [event bus](event_bus/) is used to decouple some of the internal components through
2828
asynchronous messaging.
2929

30-
```eval_rst
30+
```{eval-rst}
3131
.. toctree::
3232
:hidden:
3333
:glob:

manual/mapper/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ You can decide which logs to enable using the standard SLF4J mechanisms (categor
172172
addition, if you want no logs at all, it's possible to entirely remove them from the generated code
173173
with the Java compiler option `-Acom.datastax.oss.driver.mapper.logs.enabled=false`.
174174

175-
```eval_rst
175+
```{eval-rst}
176176
.. toctree::
177177
:hidden:
178178
:glob:

manual/mapper/config/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ You will find the generated files in `build/generated/sources/annotationProcesso
133133
* [Java 14 records](record/)
134134
* [Scala](scala/)
135135

136-
```eval_rst
136+
```{eval-rst}
137137
.. toctree::
138138
:hidden:
139139
:glob:

manual/mapper/daos/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ To control how the hierarchy is scanned, annotate interfaces with [@HierarchySca
173173
[@HierarchyScanStrategy]: https://docs.datastax.com/en/drivers/java/4.17/com/datastax/oss/driver/api/mapper/annotations/HierarchyScanStrategy.html
174174
[Entity Inheritance]: ../entities/#inheritance
175175

176-
```eval_rst
176+
```{eval-rst}
177177
.. toctree::
178178
:hidden:
179179
:glob:

manual/query_builder/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ For a complete tour of the API, browse the child pages in this manual:
213213
[DseQueryBuilder]: https://docs.datastax.com/en/drivers/java/4.17/com/datastax/dse/driver/api/querybuilder/DseQueryBuilder.html
214214
[DseSchemaBuilder]: https://docs.datastax.com/en/drivers/java/4.17/com/datastax/dse/driver/api/querybuilder/DseSchemaBuilder.html
215215

216-
```eval_rst
216+
```{eval-rst}
217217
.. toctree::
218218
:hidden:
219219
:glob:

manual/query_builder/schema/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ element type:
6565

6666
[SchemaBuilder]: https://docs.datastax.com/en/drivers/java/4.17/com/datastax/oss/driver/api/querybuilder/SchemaBuilder.html
6767

68-
```eval_rst
68+
```{eval-rst}
6969
.. toctree::
7070
:hidden:
7171
:glob:

0 commit comments

Comments
 (0)