Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings generated by docs build #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/Closure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Closure
:members:
:undoc-members:
:inherited-members:
:show-inheritance:
:show-inheritance:
4 changes: 2 additions & 2 deletions docs/source/owlrl.rst → docs/source/OWLRL.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
owlrl
OWLRL
=====

.. automodule:: owlrl
.. automodule:: owlrl.OWLRL
:members:
:undoc-members:
:inherited-members:
Expand Down
4 changes: 3 additions & 1 deletion docs/source/OWLRLExtras.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ OWLRLExtras
:members:
:undoc-members:
:inherited-members:
:show-inheritance:
:show-inheritance:

.. autofunction:: owlrl.OWLRLExtras._strToRational
2 changes: 1 addition & 1 deletion docs/source/XsdDatatypes_source.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ XsdDatatypes.py
---------------

.. literalinclude:: ../../owlrl/XsdDatatypes.py
:linenos:
:linenos:
Empty file added docs/source/_static/.gitkeep
Empty file.
10 changes: 7 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# Usually you set "language" from the command lihttps://rdflib.readthedocs.io/en/stable/ne for these cases.
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down Expand Up @@ -194,4 +194,8 @@
# -- Options for intersphinx extension ---------------------------------------

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {"https://docs.python.org/": None}
intersphinx_mapping = {
"python": ("https://docs.python.org/", None),
"rdflib": ("https://rdflib.readthedocs.io/en/stable/", None)
}

10 changes: 9 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ OWL-RL Documentation
:maxdepth: 2
:caption: Modules

owlrl
stubs/owlrl.__index__
stubs/owlrl.DeductiveClosure
AxiomaticTriples
Closure
CombinedClosure
Expand All @@ -33,3 +34,10 @@ OWL-RL Documentation
RestrictedDatatype
XsdDatatypes

.. toctree::
:maxdepth: 1
:caption: Reference Source

AxiomaticTriples_source
DatatypeHandling_source
XsdDatatypes_source
22 changes: 0 additions & 22 deletions docs/source/stubs/owlrl.Closure.rst

This file was deleted.

9 changes: 5 additions & 4 deletions docs/source/stubs/owlrl.DeductiveClosure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ owlrl.DeductiveClosure


.. automethod:: __init__

.. automethod:: expand
.. automethod:: use_improved_datatypes_conversions
.. automethod:: use_rdflib_datatypes_conversions
.. autoattribute:: improved_datatype_generic

.. rubric:: Methods

Expand All @@ -24,8 +27,6 @@ owlrl.DeductiveClosure

.. rubric:: Attributes

.. autosummary::

~DeductiveClosure.improved_datatype_generic
.. autosummary:: improved_datatype_generic


Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,21 @@ owlrl

.. rubric:: Functions

.. autosummary::

convert_graph
interpret_owl_imports
return_closure_class
.. autofunction:: convert_graph
.. autofunction:: interpret_owl_imports
.. autofunction:: return_closure_class






.. rubric:: Classes

.. autosummary::

DeductiveClosure





Expand Down
14 changes: 7 additions & 7 deletions owlrl/Closure.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Core:
There are some methods that are implemented in the subclasses only, ie, this class cannot be used by itself!

:param graph: The RDF graph to be extended.
:type graph: :class:`rdflib.Graph`
:type graph: :class:`rdflib.graph.Graph`

:param axioms: Whether axioms should be added or not.
:type axioms: bool
Expand All @@ -65,13 +65,13 @@ class Core:
:type rdfs: bool

:param destination: The destination graph to which the results are written. If None, use the source graph.
:type destination: :class:`rdflib.Graph`
:type destination: :class:`rdflib.graph.Graph`

:var IMaxNum: Maximal index of :code:`rdf:_i` occurrence in the graph.
:type IMaxNum: int

:var graph: The real graph.
:type graph: :class:`rdflib.Graph`
:type graph: :class:`rdflib.graph.Graph`

:var axioms: Whether axioms should be added or not.
:type axioms: bool
Expand All @@ -96,15 +96,15 @@ def __init__(self, graph: Graph, axioms, daxioms, rdfs: bool = False, destinatio
The parameter descriptions here are from the old documentation.

@param graph: the RDF graph to be extended
@type graph: rdflib.Graph
@type graph: Graph
@param axioms: whether axioms should be added or not
@type axioms: boolean
@param daxioms: whether datatype axioms should be added or not
@type daxioms: boolean
@param rdfs: whether RDFS inference is also done (used in subclassed only)
@type rdfs: boolean
@param destination: the destination graph to which the results are written. If None, use the source graph.
@type destination: rdflib.Graph
@type destination: Graph
"""
self._debug = debugGlobal

Expand Down Expand Up @@ -248,7 +248,7 @@ def store_triple(self, t):
added any new triple, and the full processing can stop.

:param t: The triple to be added to the graph, unless it is already there
:type t: tuple (s,p,o)
:type t: tuple
"""
(s, p, o) = t
if not isinstance(p, Literal) and not (t in self.destination or t in self.graph):
Expand All @@ -261,7 +261,7 @@ def closure(self):
"""
Generate the closure the graph. This is the real 'core'.

The processing rules store new triples via the separate method :func:`.Core.store_triple` which stores
The processing rules store new triples via the separate method :func:`owlrl.Closure.Core.store_triple` which stores
them in the :code:`added_triples` array. If that array is empty at the end of a cycle,
it means that the whole process can be stopped.

Expand Down
2 changes: 1 addition & 1 deletion owlrl/DatatypeHandling.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ def _strToPlainLiteral(v):
def use_Alt_lexical_conversions():
"""
Registering the datatypes item for RDFLib, ie, bind the dictionary values. The 'bind' method of RDFLib adds
extra datatypes to the registered ones in RDFLib, though the table used here (I.e., :py:data:`.AltXSDToPYTHON`) actually
extra datatypes to the registered ones in RDFLib, though the table used here (I.e., :code:`AltXSDToPYTHON`) actually
overrides all of the default conversion routines. The method also add a Decimal entry to the :code:`PythonToXSD` list of
RDFLib.
"""
Expand Down
4 changes: 2 additions & 2 deletions owlrl/OWLRLExtras.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def _strToRational(v):
class OWLRL_Extension(RDFS_OWLRL_Semantics):
"""
Additional rules to OWL 2 RL. The initialization method also adds the :code:`owl:rational` datatype to the set of
allowed datatypes with the :py:func:`._strToRational` function as a conversion between the literal form and a Rational. The
allowed datatypes with the :func:`owlrl.OWLRLExtras._strToRational` function as a conversion between the literal form and a Rational. The
:code:`xsd:decimal` datatype is also set to be a subclass of :code:`owl:rational`. Furthermore, the restricted datatypes are
extracted from the graph using a separate method in a different module
(:py:func:`.RestrictedDatatype.extract_faceted_datatypes`), and all those datatypes are also added to the set of allowed
Expand Down Expand Up @@ -227,7 +227,7 @@ def one_time_rules(self):

def add_axioms(self):
"""
Add the :class:`.OWLRL_Extension.extra_axioms`, related to the self restrictions.
Add the :class:`owlrl.OWLRLExtras.OWLRL_Extension.extra_axioms`, related to the self restrictions. This method is invoked only once at the beginning, and prior of, the forward chaining process.
"""
RDFS_OWLRL_Semantics.add_axioms(self)
for t in self.extra_axioms:
Expand Down
6 changes: 3 additions & 3 deletions owlrl/RestrictedDatatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
import re

from rdflib.namespace import OWL, RDF, RDFS, XSD
from rdflib import Literal as rdflibLiteral
from rdflib import Literal as rdflibLiteral, Graph

from .DatatypeHandling import AltXSDToPYTHON
from functools import reduce
Expand Down Expand Up @@ -197,15 +197,15 @@ def _match(r, l):
#######################################################################################################


def extract_faceted_datatypes(core, graph):
def extract_faceted_datatypes(core, graph: Graph):
"""
Extractions of restricted (i.e., faceted) datatypes from the graph.

:param core: The core closure instance that is being handled.
:type core: :class:`.Closure.Core`

:param graph: RDFLib graph.
:type graph: :class:`RDFLib.Graph`
:type graph: :class:`rdflib.graph.Graph`

:return: List of :class:`.RestrictedDatatype` instances.
:rtype: list
Expand Down
27 changes: 11 additions & 16 deletions owlrl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

The main entry point to the package is via the :class:`.DeductiveClosure` class. This class should be
initialized to control the parameters of the deductive closure; the forward chaining is done via the
L{expand<DeductiveClosure.expand>} method.
L{expand<owlrl.DeductiveClosure.expand>} method.
The simplest way to use the package from an RDFLib application is as follows::

graph = Graph() # creation of an RDFLib graph
Expand All @@ -48,7 +48,7 @@
expand function does not change any state.

For convenience, a second entry point to the package is provided in the form of a function called
:func:`.convert_graph`, that expects a directory with various options, including a file name. The function
:func:`owlrl.convert_graph`, that expects a directory with various options, including a file name. The function
parses the file, creates the expanded graph, and serializes the result into RDF/XML or Turtle. This function is
particularly useful as an entry point for a CGI call (where the HTML form parameters are in a directory) and is easy to
use with a command line interface. The package distribution contains an example for both.
Expand Down Expand Up @@ -87,13 +87,6 @@
methods that are executed only once either at the beginning or at the end of the full processing cycle. Adding axiomatic
triples is handled separately, which allows a finer user control over these features.

Literals must be handled separately. Indeed, the functionality relies on 'extended' RDF graphs, that allows literals
to be in a subject position, too. Because RDFLib does not allow that, processing begins by exchanging all literals in
the graph for bnodes (identical literals get the same associated bnode). Processing occurs on these bnodes; at the end
of the process all these bnodes are replaced by their corresponding literals if possible (if the bnode occurs in a
subject position, that triple is removed from the resulting graph). Details of this processing is handled in the
separate :class:`.Literals.LiteralProxies` class.

The OWL specification includes references to datatypes that are not in the core RDFS specification, consequently not
directly implemented by RDFLib. These are added in a separate module of the package.

Expand All @@ -102,8 +95,10 @@
-------------------------------------

The current distribution of RDFLib is fairly poor in handling datatypes, particularly in checking whether a lexical form
of a literal is "proper" as for its declared datatype. A typical example is::
of a literal is "proper" as for its declared datatype. A typical example is ::

"-1234"^^xsd:nonNegativeInteger

which should not be accepted as valid literal. Because the requirements of OWL 2 RL are much stricter in this respect,
an alternative set of datatype handling (essentially, conversions) had to be implemented (see the :py:mod:`.XsdDatatypes`
module).
Expand Down Expand Up @@ -233,15 +228,13 @@ def interpret_owl_imports(iformat, graph):
Interpret the owl import statements. Essentially, recursively merge with all the objects in the owl import
statement, and remove the corresponding triples from the graph.

This method can be used by an application prior to expansion. It is *not* done by the the :class:`.DeductiveClosure`
This method can be used by an application prior to expansion. It is *not* done by the :class:`.DeductiveClosure`
class.

:param iformat: Input format; can be one of :code:`AUTO`, :code:`TURTLE`, or :code:`RDFXML`. :code:`AUTO` means that
the suffix of the file name or URI will decide: '.ttl' means Turtle, RDF/XML otherwise.
:param iformat: Input format; can be one of :code:`AUTO`, :code:`TURTLE`, or :code:`RDFXML`. :code:`AUTO` means that the suffix of the file name or URI will decide: '.ttl' means Turtle, RDF/XML otherwise.
:type iformat: str

:param graph: The RDFLib Graph instance to parse into.
:type graph: :class:`RDFLib.Graph`
:type graph: :class:`rdflib.graph.Graph`
"""
while True:
# 1. collect the import statements:
Expand Down Expand Up @@ -330,7 +323,7 @@ class DeductiveClosure:
:type datatype_axioms: bool

:var improved_datatype_generic: Whether the improved set of lexical-to-Python conversions should be used for datatype handling *in general*, I.e., not only for a particular instance and not only for inference purposes. Default: False.
:type improved_Datatype_generic: bool
:type improved_datatype_generic: bool
"""

# This is the original set of param definitions in the class definition
Expand Down Expand Up @@ -380,6 +373,8 @@ def __init__(
if not isinstance(closure_class, type):
raise ValueError("The closure type argument must be a class reference")
else:


self.closure_class = closure_class
self.axiomatic_triples = axiomatic_triples
self.datatype_axioms = datatype_axioms
Expand Down