From 63412792af850f28d495d8102d6f1cc3de86ba0d Mon Sep 17 00:00:00 2001 From: Tpt Date: Thu, 6 Oct 2022 15:27:08 +0200 Subject: [PATCH] Fixes pyoxigraph type documentation --- python/src/io.rs | 6 +++--- python/src/model.rs | 23 ++++++++++++----------- python/src/sparql.rs | 8 ++++---- python/src/store.rs | 24 +++++++++++++----------- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/python/src/io.rs b/python/src/io.rs index 645f94b5..c02f3b8d 100644 --- a/python/src/io.rs +++ b/python/src/io.rs @@ -117,7 +117,7 @@ pub fn parse( /// >>> output.getvalue() /// b' "1" .\n' #[pyfunction] -#[pyo3(text_signature = "(input, output, /, mime_type, *, base_iri = None)")] +#[pyo3(text_signature = "(input, output, /, mime_type)")] pub fn serialize(input: &PyAny, output: PyObject, mime_type: &str, py: Python<'_>) -> PyResult<()> { let output = if let Ok(path) = output.extract::<&str>(py) { PyWritable::from_file(path, py) @@ -155,7 +155,7 @@ pub fn serialize(input: &PyAny, output: PyObject, mime_type: &str, py: Python<'_ } } -#[pyclass(name = "TripleReader", module = "oxigraph")] +#[pyclass(name = "TripleReader")] pub struct PyTripleReader { inner: TripleReader, } @@ -176,7 +176,7 @@ impl PyTripleReader { } } -#[pyclass(name = "QuadReader", module = "oxigraph")] +#[pyclass(name = "QuadReader")] pub struct PyQuadReader { inner: QuadReader, } diff --git a/python/src/model.rs b/python/src/model.rs index 89f8c8af..111a4b3c 100644 --- a/python/src/model.rs +++ b/python/src/model.rs @@ -19,7 +19,7 @@ use std::vec::IntoIter; /// /// >>> str(NamedNode('http://example.com')) /// '' -#[pyclass(name = "NamedNode", module = "oxigraph")] +#[pyclass(name = "NamedNode")] #[pyo3(text_signature = "(value)")] #[derive(Eq, PartialEq, Ord, PartialOrd, Debug, Clone, Hash)] pub struct PyNamedNode { @@ -121,7 +121,7 @@ impl PyNamedNode { /// /// >>> str(BlankNode('ex')) /// '_:ex' -#[pyclass(name = "BlankNode", module = "oxigraph")] +#[pyclass(name = "BlankNode")] #[pyo3(text_signature = "(value)")] #[derive(Eq, PartialEq, Debug, Clone, Hash)] pub struct PyBlankNode { @@ -234,7 +234,7 @@ impl PyBlankNode { /// '"example"@en' /// >>> str(Literal('11', datatype=NamedNode('http://www.w3.org/2001/XMLSchema#integer'))) /// '"11"^^' -#[pyclass(name = "Literal", module = "oxigraph")] +#[pyclass(name = "Literal")] #[pyo3(text_signature = "(value, *, datatype = None, language = None)")] #[derive(Eq, PartialEq, Debug, Clone, Hash)] pub struct PyLiteral { @@ -353,7 +353,8 @@ impl PyLiteral { } /// The RDF `default graph name `_. -#[pyclass(name = "DefaultGraph", module = "oxigraph")] +#[pyclass(name = "DefaultGraph")] +#[pyo3(text_signature = "()")] #[derive(Eq, PartialEq, Debug, Clone, Copy, Hash)] pub struct PyDefaultGraph {} @@ -531,7 +532,7 @@ impl IntoPy for PyTerm { /// A triple could also be easily destructed into its components: /// /// >>> (s, p, o) = Triple(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1')) -#[pyclass(name = "Triple", module = "oxigraph")] +#[pyclass(name = "Triple")] #[derive(Eq, PartialEq, Debug, Clone, Hash)] #[pyo3(text_signature = "(subject, predicate, object)")] pub struct PyTriple { @@ -694,8 +695,8 @@ impl IntoPy for PyGraphName { /// :type predicate: NamedNode /// :param object: the quad object. /// :type object: NamedNode or BlankNode or Literal or Triple -/// :param graph: the quad graph name. If not present, the default graph is assumed. -/// :type graph: NamedNode or BlankNode or DefaultGraph or None, optional +/// :param graph_name: the quad graph name. If not present, the default graph is assumed. +/// :type graph_name: NamedNode or BlankNode or DefaultGraph or None, optional /// /// The :py:func:`str` function provides a serialization compatible with NTriples, Turtle, and SPARQL: /// @@ -708,7 +709,7 @@ impl IntoPy for PyGraphName { /// A quad could also be easily destructed into its components: /// /// >>> (s, p, o, g) = Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g')) -#[pyclass(name = "Quad", module = "oxigraph")] +#[pyclass(name = "Quad")] #[pyo3(text_signature = "(subject, predicate, object, graph_name = None)")] #[derive(Eq, PartialEq, Debug, Clone, Hash)] pub struct PyQuad { @@ -868,7 +869,7 @@ impl PyQuad { /// /// >>> str(Variable('foo')) /// '?foo' -#[pyclass(name = "Variable", module = "oxigraph")] +#[pyclass(name = "Variable")] #[pyo3(text_signature = "(value)")] #[derive(Eq, PartialEq, Debug, Clone, Hash)] pub struct PyVariable { @@ -1182,7 +1183,7 @@ fn triple_repr(triple: TripleRef<'_>, buffer: &mut String) { buffer.push('>'); } -#[pyclass(module = "oxigraph")] +#[pyclass] pub struct TripleComponentsIter { inner: IntoIter, } @@ -1198,7 +1199,7 @@ impl TripleComponentsIter { } } -#[pyclass(module = "oxigraph")] +#[pyclass] pub struct QuadComponentsIter { inner: IntoIter>, } diff --git a/python/src/sparql.rs b/python/src/sparql.rs index f4ddb924..547011d4 100644 --- a/python/src/sparql.rs +++ b/python/src/sparql.rs @@ -85,7 +85,7 @@ pub fn query_results_to_python(py: Python<'_>, results: QueryResults) -> PyResul /// >>> s, p, o = solution /// >>> s /// -#[pyclass(unsendable, name = "QuerySolution", module = "oxigraph")] +#[pyclass(unsendable, name = "QuerySolution")] pub struct PyQuerySolution { inner: QuerySolution, } @@ -136,7 +136,7 @@ impl PyQuerySolution { } } -#[pyclass(module = "oxigraph")] +#[pyclass] pub struct SolutionValueIter { inner: IntoIter>, } @@ -158,7 +158,7 @@ impl SolutionValueIter { /// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'))) /// >>> list(store.query('SELECT ?s WHERE { ?s ?p ?o }')) /// [>] -#[pyclass(unsendable, name = "QuerySolutions", module = "oxigraph")] +#[pyclass(unsendable, name = "QuerySolutions")] pub struct PyQuerySolutions { inner: QuerySolutionIter, } @@ -198,7 +198,7 @@ impl PyQuerySolutions { /// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'))) /// >>> list(store.query('CONSTRUCT WHERE { ?s ?p ?o }')) /// [ predicate= object=>>] -#[pyclass(unsendable, name = "QueryTriples", module = "oxigraph")] +#[pyclass(unsendable, name = "QueryTriples")] pub struct PyQueryTriples { inner: QueryTripleIter, } diff --git a/python/src/store.rs b/python/src/store.rs index 6775a1e3..4ff0d47b 100644 --- a/python/src/store.rs +++ b/python/src/store.rs @@ -23,7 +23,7 @@ use pyo3::{Py, PyRef}; /// :param path: the path of the directory in which the store should read and write its data. If the directory does not exist, it is created. /// If no directory is provided a temporary one is created and removed when the Python garbage collector removes the store. /// In this case, the store data are kept in memory and never written on disk. -/// :type path: str or None, optional. +/// :type path: str or None, optional /// :raises IOError: if the target directory contains invalid data or could not be accessed. /// /// The :py:func:`str` function provides a serialization of the store in NQuads: @@ -32,7 +32,7 @@ use pyo3::{Py, PyRef}; /// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g'))) /// >>> str(store) /// ' "1" .\n' -#[pyclass(name = "Store", module = "oxigraph")] +#[pyclass(name = "Store")] #[pyo3(text_signature = "(path = None)")] #[derive(Clone)] pub struct PyStore { @@ -101,8 +101,8 @@ impl PyStore { /// :type predicate: NamedNode or None /// :param object: the quad object or :py:const:`None` to match everything. /// :type object: NamedNode or BlankNode or Literal or None - /// :param graph: the quad graph name. To match only the default graph, use :py:class:`DefaultGraph`. To match everything use :py:const:`None`. - /// :type graph: NamedNode or BlankNode or DefaultGraph or None + /// :param graph_name: the quad graph name. To match only the default graph, use :py:class:`DefaultGraph`. To match everything use :py:const:`None`. + /// :type graph_name: NamedNode or BlankNode or DefaultGraph or None /// :return: an iterator of the quads matching the pattern. /// :rtype: iter(Quad) /// :raises IOError: if an I/O error happens during the quads lookup. @@ -152,7 +152,7 @@ impl PyStore { /// /// >>> store = Store() /// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'))) - /// >>> list(solution['s'] for solution in store.query('SELECT ?s WHERE { ?s ?p ?o }')) + /// >>> [solution['s'] for solution in store.query('SELECT ?s WHERE { ?s ?p ?o }')] /// [] /// /// ``CONSTRUCT`` query: @@ -169,7 +169,7 @@ impl PyStore { /// >>> store.query('ASK { ?s ?p ?o }') /// True #[pyo3( - text_signature = "($self, query, *, base_iri, use_default_graph_as_union, default_graph, named_graphs)" + text_signature = "($self, query, *, base_iri = None, use_default_graph_as_union = False, default_graph = None, named_graphs = None)" )] #[args( query, @@ -233,7 +233,7 @@ impl PyStore { /// >>> store.update('DELETE WHERE { ?p ?o }') /// >>> list(store) /// [] - #[pyo3(text_signature = "($self, update, *, base_iri)")] + #[pyo3(text_signature = "($self, update, *, base_iri = None)")] #[args(update, "*", base_iri = "None")] fn update(&self, update: &str, base_iri: Option<&str>, py: Python<'_>) -> PyResult<()> { py.allow_threads(|| { @@ -278,7 +278,7 @@ impl PyStore { /// >>> store.load(io.BytesIO(b'

"1" .'), "text/turtle", base_iri="http://example.com/", to_graph=NamedNode("http://example.com/g")) /// >>> list(store) /// [ predicate= object=> graph_name=>] - #[pyo3(text_signature = "($self, data, /, mime_type, *, base_iri = None, to_graph = None)")] + #[pyo3(text_signature = "($self, input, /, mime_type, *, base_iri = None, to_graph = None)")] #[args(input, mime_type, "*", base_iri = "None", to_graph = "None")] fn load( &self, @@ -362,7 +362,7 @@ impl PyStore { /// >>> store.bulk_load(io.BytesIO(b'

"1" .'), "text/turtle", base_iri="http://example.com/", to_graph=NamedNode("http://example.com/g")) /// >>> list(store) /// [ predicate= object=> graph_name=>] - #[pyo3(text_signature = "($self, data, /, mime_type, *, base_iri = None, to_graph = None)")] + #[pyo3(text_signature = "($self, input, /, mime_type, *, base_iri = None, to_graph = None)")] #[args(input, mime_type, "*", base_iri = "None", to_graph = "None")] fn bulk_load( &self, @@ -535,6 +535,8 @@ impl PyStore { /// Clears a graph from the store without removing it. /// + /// :param graph_name: the name of the name graph to clear. + /// :type graph_name: NamedNode or BlankNode or DefaultGraph /// :raises IOError: if an I/O error happens during the operation. /// /// >>> store = Store() @@ -672,7 +674,7 @@ impl PyStore { } } -#[pyclass(unsendable, module = "oxigraph")] +#[pyclass(unsendable)] pub struct QuadIter { inner: store::QuadIter, } @@ -691,7 +693,7 @@ impl QuadIter { } } -#[pyclass(unsendable, module = "oxigraph")] +#[pyclass(unsendable)] pub struct GraphNameIter { inner: store::GraphNameIter, }