Skip to content

Commit 0d413fd

Browse files
authored
docs: fix sphinx nitpicky issues (#2036)
Enable nitpicky mode for Sphinx and fix all warnings and errors that occur when running with nitpicky enabled. Other changes: - Add a tox environment for building docs (-docs). This is so we can test building docs on various versions of python as there seems to be some differences in warnings between different versions. This tox environment is enabled for linux CI builds. - Change readthedocs to use python 3.9 as earlier versions do not handle `@typing.overload` with type aliases. - Fixes #1878
1 parent 63ff76c commit 0d413fd

31 files changed

+199
-89
lines changed

.github/workflows/validate.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,18 @@ jobs:
2525
- python-version: "3.7"
2626
os: ubuntu-latest
2727
extensive-tests: true
28+
TOXENV_SUFFIX: "-docs"
2829
- python-version: "3.8"
2930
os: ubuntu-latest
3031
TOX_EXTRA_COMMAND: "- isort --check-only --diff ."
32+
TOXENV_SUFFIX: "-docs"
3133
- python-version: "3.9"
3234
os: ubuntu-latest
3335
TOX_EXTRA_COMMAND: "- black --check --diff ./rdflib"
3436
- python-version: "3.10"
3537
os: ubuntu-latest
3638
TOX_EXTRA_COMMAND: "flake8 --exit-zero rdflib"
39+
TOXENV_SUFFIX: "-docs"
3740
steps:
3841
- uses: actions/checkout@v3
3942
- name: Set up Python ${{ matrix.python-version }}
@@ -72,6 +75,7 @@ jobs:
7275
OS=${{ matrix.os }} \
7376
EXTENSIVE=${{ matrix.extensive-tests }} \
7477
TOX_PYTHON_VERSION=${{ matrix.python-version }} \
78+
TOXENV_SUFFIX=${{ matrix.TOXENV_SUFFIX }} \
7579
gha:validate
7680
env:
7781
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.readthedocs.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ formats:
1212
build:
1313
os: ubuntu-20.04
1414
tools:
15-
python: "3.7"
15+
# Using 3.9 as earlier versions have trouble generating documentation for
16+
# `@typing.overload`` with type aliases.
17+
python: "3.9"
1618

1719
python:
1820
install:

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ and will be removed for release.
5858
<!-- -->
5959
<!-- -->
6060

61+
- Fixed some cross-referencing issues in RDFLib documentation.
62+
Closed [issue #1878](https://github.com/RDFLib/rdflib/issues/1878).
63+
[PR #2036](https://github.com/RDFLib/rdflib/pull/2036).
64+
65+
<!-- -->
66+
<!-- -->
67+
<!-- CHANGE BARRIER: END -->
68+
<!-- -->
69+
<!-- -->
70+
71+
<!-- -->
72+
<!-- -->
73+
<!-- CHANGE BARRIER: START -->
74+
<!-- -->
75+
<!-- -->
76+
6177
- PLACEHOLDER.
6278
Description of changes.
6379
Closed [issue #....](https://github.com/RDFLib/rdflib/issues/).

Taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ tasks:
9595
-m tox \
9696
{{.CLI_ARGS}}
9797
env:
98-
TOXENV: '{{if .TOX_PYTHON_VERSION}}py{{mustRegexReplaceAll "^([0-9]+)[.]([0-9]+).*" .TOX_PYTHON_VERSION "${1}${2}"}}{{if .EXTENSIVE}}-extensive{{end}}{{end}}'
98+
TOXENV: '{{if .TOX_PYTHON_VERSION}}py{{mustRegexReplaceAll "^([0-9]+)[.]([0-9]+).*" .TOX_PYTHON_VERSION "${1}${2}"}}{{if .EXTENSIVE}}-extensive{{end}}{{.TOXENV_SUFFIX | default ""}}{{end}}'
9999
test:
100100
desc: Run tests
101101
cmds:

docs/apidocs/examples.rst

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,112 +3,112 @@ examples Package
33

44
These examples all live in ``./examples`` in the source-distribution of RDFLib.
55

6-
:mod:`conjunctive_graphs` Module
7-
--------------------------------
6+
:mod:`~examples.conjunctive_graphs` Module
7+
------------------------------------------
88

99
.. automodule:: examples.conjunctive_graphs
1010
:members:
1111
:undoc-members:
1212
:show-inheritance:
1313

14-
:mod:`custom_datatype` Module
15-
-----------------------------
14+
:mod:`~examples.custom_datatype` Module
15+
---------------------------------------
1616

1717
.. automodule:: examples.custom_datatype
1818
:members:
1919
:undoc-members:
2020
:show-inheritance:
2121

22-
:mod:`custom_eval` Module
23-
-------------------------
22+
:mod:`~examples.custom_eval` Module
23+
-----------------------------------
2424

2525
.. automodule:: examples.custom_eval
2626
:members:
2727
:undoc-members:
2828
:show-inheritance:
2929

30-
:mod:`foafpaths` Module
31-
-----------------------
30+
:mod:`~examples.foafpaths` Module
31+
---------------------------------
3232

3333
.. automodule:: examples.foafpaths
3434
:members:
3535
:undoc-members:
3636
:show-inheritance:
3737

38-
:mod:`prepared_query` Module
39-
----------------------------
38+
:mod:`~examples.prepared_query` Module
39+
--------------------------------------
4040

4141
.. automodule:: examples.prepared_query
4242
:members:
4343
:undoc-members:
4444
:show-inheritance:
4545

46-
:mod:`resource_example` Module
47-
------------------------------
46+
:mod:`~examples.resource_example` Module
47+
----------------------------------------
4848

4949
.. automodule:: examples.resource_example
5050
:members:
5151
:undoc-members:
5252
:show-inheritance:
5353

54-
:mod:`berkeleydb_example` Module
55-
--------------------------------
54+
:mod:`~examples.berkeleydb_example` Module
55+
------------------------------------------
5656

5757
.. automodule:: examples.berkeleydb_example
5858
:members:
5959
:undoc-members:
6060
:show-inheritance:
6161

62-
:mod:`slice` Module
63-
-------------------
62+
:mod:`~examples.slice` Module
63+
-----------------------------
6464

6565
.. automodule:: examples.slice
6666
:members:
6767
:undoc-members:
6868
:show-inheritance:
6969

70-
:mod:`smushing` Module
71-
----------------------
70+
:mod:`~examples.smushing` Module
71+
--------------------------------
7272

7373
.. automodule:: examples.smushing
7474
:members:
7575
:undoc-members:
7676
:show-inheritance:
7777

78-
:mod:`sparql_query_example` Module
79-
----------------------------------
78+
:mod:`~examples.sparql_query_example` Module
79+
--------------------------------------------
8080

8181
.. automodule:: examples.sparql_query_example
8282
:members:
8383
:undoc-members:
8484
:show-inheritance:
8585

86-
:mod:`sparql_update_example` Module
87-
-----------------------------------
86+
:mod:`~examples.sparql_update_example` Module
87+
---------------------------------------------
8888

8989
.. automodule:: examples.sparql_update_example
9090
:members:
9191
:undoc-members:
9292
:show-inheritance:
9393

94-
:mod:`sparqlstore_example` Module
95-
-----------------------------------
94+
:mod:`~examples.sparqlstore_example` Module
95+
-------------------------------------------
9696

9797
.. automodule:: examples.sparqlstore_example
9898
:members:
9999
:undoc-members:
100100
:show-inheritance:
101101

102-
:mod:`swap_primer` Module
103-
-------------------------
102+
:mod:`~examples.swap_primer` Module
103+
-----------------------------------
104104

105105
.. automodule:: examples.swap_primer
106106
:members:
107107
:undoc-members:
108108
:show-inheritance:
109109

110-
:mod:`transitive` Module
111-
------------------------
110+
:mod:`~examples.transitive` Module
111+
----------------------------------
112112

113113
.. automodule:: examples.transitive
114114
:members:

docs/conf.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,42 @@ def find_version(filename):
254254
# "WARNING: more than one target found for cross-reference"
255255
"ref.python",
256256
]
257+
258+
nitpicky = True
259+
260+
nitpick_ignore = [
261+
("py:data", "typing.Literal"),
262+
("py:class", "typing.IO[bytes]"),
263+
("py:class", "http.client.HTTPMessage"),
264+
("py:class", "importlib.metadata.EntryPoint"),
265+
("py:class", "xml.dom.minidom.Document"),
266+
("py:class", "xml.dom.minidom.DocumentFragment"),
267+
# sphinx-autodoc-typehints has some issues with TypeVars.
268+
# https://github.com/tox-dev/sphinx-autodoc-typehints/issues/39
269+
("py:class", "rdflib.plugin.PluginT"),
270+
# These are related to pyparsing.
271+
("py:class", "Diagnostics"),
272+
("py:class", "ParseAction"),
273+
("py:class", "ParseFailAction"),
274+
("py:class", "pyparsing.core.TokenConverter"),
275+
("py:class", "pyparsing.results.ParseResults"),
276+
]
277+
278+
if sys.version_info < (3, 9):
279+
nitpick_ignore.extend(
280+
[
281+
("py:class", "_TriplePatternType"),
282+
("py:class", "_TripleType"),
283+
("py:class", "_ObjectType"),
284+
("py:class", "_PredicateType"),
285+
("py:class", "_SubjectType"),
286+
("py:class", "TextIO"),
287+
]
288+
)
289+
290+
if sys.version_info < (3, 8):
291+
nitpick_ignore.extend(
292+
[
293+
("py:class", "importlib_metadata.EntryPoint"),
294+
]
295+
)

docs/developers.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ ideally be updated to the pytest test-style when they are touched.
132132
Test should go into the ``test/`` directory, either into an existing test file
133133
with a name that is applicable to the test being written, or into a new test
134134
file with a name that is descriptive of the tests placed in it. Test files
135-
should be named `test_*.py` so that `pytest can discover them
135+
should be named ``test_*.py`` so that `pytest can discover them
136136
<https://docs.pytest.org/en/latest/explanation/goodpractices.html#conventions-for-python-test-discovery>`_.
137137

138138
Running static checks
@@ -399,6 +399,6 @@ No matter how you create the release tag, remember to upload tarball to pypi wit
399399
# WARNING: once uploaded can never be modified, only deleted!
400400
twine upload dist/rdflib-X.X.X[.-]*
401401

402-
Set new dev version number in the above locations, i.e. next release `-dev`: ``5.0.1-dev`` and commit again.
402+
Set new dev version number in the above locations, i.e. next release ``-dev``: ``5.0.1-dev`` and commit again.
403403

404404
Tweet, email mailing list and inform members in the chat.

docs/namespaces_and_bindings.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespaces provided grows with user contributions to RDFLib.
2929

3030
These Namespaces, and any others that users define, can also be associated with prefixes using the :class:`rdflib.namespace.NamespaceManager`, e.g. using ``foaf`` for ``http://xmlns.com/foaf/0.1/``.
3131

32-
Each RDFLib graph has a :attr:`~rdflib.graph.Graph.namespace_manager` that keeps a list of namespace to prefix mappings. The namespace manager is populated when reading in RDF, and these prefixes are used when serialising RDF, or when parsing SPARQL queries. Prefixes can be bound with the :meth:`rdflib.graph.bind` method::
32+
Each RDFLib graph has a :attr:`~rdflib.graph.Graph.namespace_manager` that keeps a list of namespace to prefix mappings. The namespace manager is populated when reading in RDF, and these prefixes are used when serialising RDF, or when parsing SPARQL queries. Prefixes can be bound with the :meth:`rdflib.graph.Graph.bind` method::
3333

3434
from rdflib import Graph, Namespace
3535
from rdflib.namespace import FOAF
@@ -41,15 +41,15 @@ Each RDFLib graph has a :attr:`~rdflib.graph.Graph.namespace_manager` that keeps
4141
g.bind("ex", EX) # bind a user-declared namespace to a prefix
4242
4343

44-
The :meth:`rdflib.graph.bind` method is actually supplied by the :class:`rdflib.namespace.NamespaceManager` class - see next.
44+
The :meth:`rdflib.graph.Graph.bind` method is actually supplied by the :class:`rdflib.namespace.NamespaceManager` class - see next.
4545

4646
NamespaceManager
4747
----------------
4848

49-
Each RDFLib graph comes with a :class:`rdflib.namespace.NamespaceManager` instance in the `namespace_manager` field; you can use the `bind` method of this instance to bind a prefix to a namespace URI,
50-
as above, however note that the `NamespaceManager` automatically performs some bindings according to a selected strategy.
49+
Each RDFLib graph comes with a :class:`rdflib.namespace.NamespaceManager` instance in the :attr:`~rdflib.graph.Graph.namespace_manager` field; you can use the :meth:`~rdflib.namespace.NamespaceManager.bind` method of this instance to bind a prefix to a namespace URI,
50+
as above, however note that the :class:`~rdflib.namespace.NamespaceManager` automatically performs some bindings according to a selected strategy.
5151

52-
Namespace binding strategies are indicated with the `bind_namespaces` input parameter to `NamespaceManager` instances
52+
Namespace binding strategies are indicated with the ``bind_namespaces`` input parameter to :class:`~rdflib.namespace.NamespaceManager` instances
5353
and may be set via ``Graph`` also::
5454

5555
from rdflib import Graph
@@ -95,7 +95,7 @@ for example::
9595
9696
9797

98-
`NamespaceManager` also has a method to normalize a given url::
98+
:class:`~rdflib.namespace.NamespaceManager` also has a method to normalize a given url::
9999

100100
from rdflib.namespace import NamespaceManager
101101

docs/persisting_n3_terms.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ A formula-aware store could also support the persistence of this distinction by
7777
7878
This function would return all the Blank Node identifiers assigned to formulae or just those that contain statements matching the given triple pattern and would be the way a serializer determines if a term refers to a formula (in order to properly serializer it).
7979

80-
How much would such an interface reduce the need to model formulae terms as first class objects (perhaps to be returned by the :meth:`~rdflib.Graph.triple` function)? Would it be more useful for the :class:`~rdflib.Graph` (or the store itself) to return a Context object in place of a formula term (using the formulae interface to make this determination)?
80+
How much would such an interface reduce the need to model formulae terms as first class objects (perhaps to be returned by the :meth:`~rdflib.Graph.triples` function)? Would it be more useful for the :class:`~rdflib.Graph` (or the store itself) to return a Context object in place of a formula term (using the formulae interface to make this determination)?
8181

8282
Conversely, would these interfaces (variables and formulae) be considered optimizations only since you have the distinction by the kinds of terms triples returns (which would be expanded to include variables and formulae)?
8383

docs/plugin_parsers.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Name Class
2222
========= ====================================================================
2323
json-ld :class:`~rdflib.plugins.parsers.jsonld.JsonLDParser`
2424
hext :class:`~rdflib.plugins.parsers.hext.HextuplesParser`
25-
html :class:`~rdflib.plugins.parsers.structureddata.StructuredDataParser`
2625
n3 :class:`~rdflib.plugins.parsers.notation3.N3Parser`
2726
nquads :class:`~rdflib.plugins.parsers.nquads.NQuadsParser`
2827
nt :class:`~rdflib.plugins.parsers.ntriples.NTParser`

0 commit comments

Comments
 (0)