Skip to content

Commit 3b2c6f3

Browse files
nicholascarvemonet
andauthored
Pr/3143 (#3144)
* Start migrating the documentation from .rst sphynx to .md material for mkdocs. Add mkdocs.yml with proper configuration, enable automated generation of the doc API from the docstring, and start converting a few pages (index, getting started, developers) for demo. * Add automated (opt-in) tests of all python codeblocks in the markdown docs using pytest-markdown-docs. Needed to comment 1 small test that seemingly should fail (AttributeError: DefinedNamespace like object has no attribute '_NS', indeed the DefinedNamespace class expect a _NS, so it makes sense it fails) but for some reason it was not properly failing when ran with regular pytest, but it fails with pytest-markdown-docs * convert all documentations pages to markdown, convert all docstrings to markdown with google style, updated config for mkdocs (readthedocs, tox, task) fixed #3128 * delete files, dependencies and mentions related to sphinx * uncomment test previously commented for experimenting with markdown codeblock testing * update poetry lock * blacked again * ignore mypy errors --------- Co-authored-by: Vincent Emonet <[email protected]>
1 parent 98cec06 commit 3b2c6f3

File tree

178 files changed

+6703
-8345
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+6703
-8345
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ updates:
99
# see https://github.com/dependabot/dependabot-core/pull/10194
1010
versioning-strategy: auto
1111
ignore:
12-
- dependency-name: sphinx
13-
versions:
14-
- 3.4.3
15-
- 3.5.2
1612
# We only use setuptools for a couple of things in the test suite
1713
# There is no need to keep it bleeding-edge. There are too frequent
1814
# updates to setuptools, requires too much maintenance to keep it up to date.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
.flakeheaven_cache/
22
RDFLib.sublime-project
3-
/docs/_build/
43
RDFLib.sublime-workspace
54
coverage/
65
cov.xml
76
/.hgtags
87
/.hgignore
98
build/
109
/docs/draft/
10+
/docs/apidocs/
11+
/docs/_build/
1112
*~
1213
test_reports/*latest.ttl
1314
# PyCharm

.readthedocs.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ formats:
99
- htmlzip
1010
- pdf
1111

12+
# https://docs.readthedocs.com/platform/stable/intro/mkdocs.html
1213
build:
13-
os: ubuntu-20.04
14+
os: "ubuntu-24.04"
1415
tools:
15-
# Using 3.9 as earlier versions have trouble generating documentation for
16-
# `@typing.overload`` with type aliases.
17-
python: "3.9"
16+
python: "3"
1817
jobs:
1918
post_create_environment:
2019
# Using requirements-poetry.in as requirements-poetry.txt has conflicts with
@@ -24,8 +23,6 @@ build:
2423
- poetry export --only=main --only=docs --without-hashes -o requirements.txt
2524
- pip install --no-cache-dir -r requirements.txt
2625
- pip install .
27-
- python -c "from rdflib import Graph; print(Graph)"
2826

29-
sphinx:
30-
configuration: docs/conf.py
31-
fail_on_warning: true
27+
mkdocs:
28+
configuration: mkdocs.yml

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ recursive-include examples *.py
99
graft test
1010
graft docs
1111
prune docs/_build
12+
prune site/
1213
global-exclude *.pyc *$py.class

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
![](docs/_static/RDFlib.png)
1+
![](docs/_static/RDFlib.png)
2+
3+
# RDFLib
24

3-
RDFLib
4-
======
55
[![Build Status](https://github.com/RDFLib/rdflib/actions/workflows/validate.yaml/badge.svg?branch=main)](https://github.com/RDFLib/rdflib/actions?query=branch%3Amain)
66
[![Documentation Status](https://readthedocs.org/projects/rdflib/badge/?version=latest)](https://rdflib.readthedocs.io/en/latest/?badge=latest)
77
[![Coveralls branch](https://img.shields.io/coveralls/RDFLib/rdflib/main.svg)](https://coveralls.io/r/RDFLib/rdflib?branch=main)
@@ -31,7 +31,7 @@ The RDFlib community maintains many RDF-related Python code repositories with di
3131
* [sparqlwrapper](https://github.com/RDFLib/sparqlwrapper) - a simple Python wrapper around a SPARQL service to remotely execute your queries
3232
* [pyLODE](https://github.com/RDFLib/pyLODE) - An OWL ontology documentation tool using Python and templating, based on LODE.
3333
* [pyrdfa3](https://github.com/RDFLib/pyrdfa3) - RDFa 1.1 distiller/parser library: can extract RDFa 1.1/1.0 from (X)HTML, SVG, or XML in general.
34-
* [pymicrodata](https://github.com/RDFLib/pymicrodata) - A module to extract RDF from an HTML5 page annotated with microdata.
34+
* [pymicrodata](https://github.com/RDFLib/pymicrodata) - A module to extract RDF from an HTML5 page annotated with microdata.
3535
* [pySHACL](https://github.com/RDFLib/pySHACL) - A pure Python module which allows for the validation of RDF graphs against SHACL graphs.
3636
* [OWL-RL](https://github.com/RDFLib/OWL-RL) - A simple implementation of the OWL2 RL Profile which expands the graph with all possible triples that OWL RL defines.
3737

@@ -134,18 +134,21 @@ g.add((
134134
Literal("Nick", datatype=XSD.string)
135135
))
136136
```
137+
137138
The triple (in n-triples notation) `<http://example.com/person/nick> <http://xmlns.com/foaf/0.1/givenName> "Nick"^^<http://www.w3.org/2001/XMLSchema#string> .`
138139
is created where the property `FOAF.givenName` is the URI `<http://xmlns.com/foaf/0.1/givenName>` and `XSD.string` is the
139140
URI `<http://www.w3.org/2001/XMLSchema#string>`.
140141

141142
You can bind namespaces to prefixes to shorten the URIs for RDF/XML, Turtle, N3, TriG, TriX & JSON-LD serializations:
142143

143-
```python
144+
```python
144145
g.bind("foaf", FOAF)
145146
g.bind("xsd", XSD)
146147
```
148+
147149
This will allow the n-triples triple above to be serialised like this:
148-
```python
150+
151+
```python
149152
print(g.serialize(format="turtle"))
150153
```
151154

Taskfile.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,19 @@ tasks:
170170
desc: Clean generated documentation
171171
cmds:
172172
- task: _rimraf
173-
vars: { RIMRAF_TARGET: "docs/_build/" }
173+
vars: { RIMRAF_TARGET: "site/" }
174174

175175
docs:
176176
desc: Build documentation
177177
cmds:
178178
- echo "PYTHONPATH=${PYTHONPATH}"
179-
- "{{.VENV_PYTHON}} -m sphinx.cmd.build -T -W -b html -d docs/_build/doctree docs docs/_build/html {{.CLI_ARGS}}"
179+
- "{{.VENV_PYTHON}} -m mkdocs build {{.CLI_ARGS}}"
180180

181181
docs:live-server:
182182
desc: Run a live server on generated docs
183183
cmds:
184184
- 'echo "NOTE: Docs must be built for this to work"'
185-
- npx -p live-server live-server docs/_build/html/ {{.CLI_ARGS}}
185+
- npx -p live-server live-server site/ {{.CLI_ARGS}}
186186

187187
default:
188188
desc: Run validate
@@ -356,7 +356,7 @@ tasks:
356356
cd var/test-sdist/rdflib-*
357357
poetry install
358358
poetry run mypy --show-error-context --show-error-codes -p rdflib
359-
poetry run sphinx-build -T -W -b html -d docs/_build/doctree docs docs/_build/html
359+
poetry run mkdocs build
360360
poetry run pytest
361361
362362
test:no_internet:

devtools/diffrtpy.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@
33
This is a tool that can be used with git difftool to generate a diff that
44
ignores type hints and comments.
55
6-
The name of this script, ``diffrtpy`` is short for "diff runtime python", as
6+
The name of this script, `diffrtpy` is short for "diff runtime python", as
77
this will only compare the parts of the python code that has a runtime impact.
88
99
This is to make it easier to review PRs that contain type hints.
1010
1111
To use this script
1212
13-
.. code-block:: bash
14-
task run -- python -m pip install --upgrade strip-hints black python-minifier
15-
PYLOGGING_LEVEL=INFO task run -- git difftool -y -x $(readlink -f devtools/diffrtpy.py) upstream/main | tee /var/tmp/compact.diff
13+
```bash
14+
task run -- python -m pip install --upgrade strip-hints black python-minifier
15+
PYLOGGING_LEVEL=INFO task run -- git difftool -y -x $(readlink -f devtools/diffrtpy.py) upstream/main | tee /var/tmp/compact.diff
16+
```
1617
17-
Then attach ``/var/tmp/compact.diff`` to the PR.
18+
Then attach `/var/tmp/compact.diff` to the PR.
1819
"""
1920

2021
from __future__ import annotations

docs/CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Some ways in which you can contribute to RDFLib are:
4646
## Pull Requests
4747

4848
Contributions that involve changes to the RDFLib repository have to be made with
49-
pull requests and should follow the [RDFLib developers guide](./developers.rst).
49+
pull requests and should follow the [RDFLib developers guide](./developers.md).
5050

5151
For changes that add features or affect the public API of RDFLib, it is
5252
recommended to first open an issue to discuss the change before starting to work
@@ -55,5 +55,5 @@ spending time on it.
5555

5656
## Code of Conduct
5757

58-
All contributions to the project should be consistent with the [code of
59-
conduct](./CODE_OF_CONDUCT.md) adopted by RDFLib.
58+
All contributions to the project should be consistent with the
59+
[code of conduct](./CODE_OF_CONDUCT.md) adopted by RDFLib.

0 commit comments

Comments
 (0)