Skip to content

Commit 4ca5bc1

Browse files
authored
Adapt doc generation to new CAPI2 JSON Schema definition (#626)
Adapt doc generation to new CAPI2 JSON Schema definition
1 parent 0511302 commit 4ca5bc1

File tree

6 files changed

+23
-14
lines changed

6 files changed

+23
-14
lines changed

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ formats: all
1111

1212
# Optionally set the version of Python and requirements required to build your docs
1313
python:
14-
version: 3
14+
version: 3.8
1515
install:
1616
- requirements: doc/requirements.txt
1717
- method: pip

doc/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Sphinx >= 3.0
1+
Sphinx >= 6.2.1
22
sphinx-rtd-theme
33
sphinxcontrib-programoutput

doc/source/conf.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
from datetime import datetime
1515
from distutils.version import LooseVersion
1616

17+
import jsonschema2md
18+
1719
import fusesoc
18-
from fusesoc.capi2.core import gen_doc
20+
from fusesoc.capi2.json_schema import capi2_schema
21+
from fusesoc.utils import yaml_read
1922

2023
# -- Path setup --------------------------------------------------------------
2124

@@ -56,6 +59,7 @@
5659
"sphinx.ext.intersphinx",
5760
"sphinx.ext.todo",
5861
"sphinxcontrib.programoutput",
62+
"myst_parser",
5963
]
6064

6165
intersphinx_mapping = {"https://docs.python.org/3": None}
@@ -67,8 +71,7 @@
6771
# The suffix(es) of source filenames.
6872
# You can specify multiple suffix as a list of string:
6973
#
70-
# source_suffix = ['.rst', '.md']
71-
source_suffix = ".rst"
74+
source_suffix = [".rst", ".md"]
7275

7376
# The master toctree document.
7477
master_doc = "index"
@@ -203,7 +206,11 @@
203206

204207
# -- Extension configuration -------------------------------------------------
205208

209+
p = jsonschema2md.Parser(
210+
examples_as_yaml=False,
211+
show_examples="all",
212+
)
213+
md_lines = p.parse_schema(yaml_read(capi2_schema))
206214

207-
s = gen_doc()
208-
with open(os.path.join(os.path.abspath("."), "ref/capi2.rst"), "w") as f:
209-
f.write(s)
215+
with open(os.path.join(os.path.abspath("."), "ref/capi2.md"), "w") as f:
216+
f.write("".join(md_lines))

doc/source/ref/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ FuseSoC Reference Manual
66
:maxdepth: 2
77
:caption: Contents
88

9-
capi2.rst
9+
capi2.md
1010
migrations.rst
1111
glossary.rst

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def read(fname):
5656
"pyyaml",
5757
"simplesat>=0.8.0",
5858
"fastjsonschema",
59+
"jsonschema2md",
60+
"myst_parser",
5961
],
6062
# Supported Python versions: 3.6+
6163
python_requires=">=3.6, <4",

tox.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@ description = Automatically (re-)build the HTML documentation with Sphinx
5555
deps =
5656
-rdoc/requirements.txt
5757
sphinx-autobuild
58+
myst_parser
59+
jsonschema2md
5860
commands =
59-
# capi2.rst is generated during the documentation build and would
61+
# capi2.md is generated during the documentation build and would
6062
# immediately re-trigger a build. We ignore the generated file, and instead
61-
# watch the primary source of information for the generated file. Since
62-
# capi2.rst is also produced from some other files this check isn't fully
63-
# exhaustive, but covers most use cases.
63+
# watch the primary source of information for the generated file.
6464
sphinx-autobuild \
6565
--open-browser \
6666
-d "{toxworkdir}/docs_doctree" \
67-
--ignore "*/doc/source/ref/capi2.rst" \
67+
--ignore "*/doc/source/ref/capi2.md" \
6868
--watch "fusesoc/capi2" \
6969
doc/source \
7070
"{toxworkdir}/docs_out" \

0 commit comments

Comments
 (0)