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

Tidy up of examples docs #3028

Draft
wants to merge 1 commit into
base: 8.x
Choose a base branch
from
Draft
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
14 changes: 11 additions & 3 deletions docs/apidocs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@ examples Package

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

:mod:`~examples.conjunctive_graphs` Module
------------------------------------------
:mod:`~examples.datasets` Module
--------------------------------

.. automodule:: examples.datasets
:members:
:undoc-members:
:show-inheritance:

:mod:`~examples.jsonld_serialization` Module
--------------------------------------------

.. automodule:: examples.conjunctive_graphs
.. automodule:: examples.jsonld_serialization
:members:
:undoc-members:
:show-inheritance:
Expand Down
12 changes: 6 additions & 6 deletions examples/datasets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
This file contains a number of common tasks using the RDFLib Dataset class.
This module contains a number of common tasks using the RDFLib Dataset class.

An RDFLib Dataset is an object that stores multiple Named Graphs - instances of RDFLib
Graph identified by IRI - within it and allows whole-of-dataset or single Graph use.
Expand All @@ -10,11 +10,11 @@
There is an older implementation of a Dataset-like class in RDFLib < 7.x called
ConjunctiveGraph that is now deprecated.

Sections in this file:
Sections in this module:

1. Creating & Adding
2. Looping & Counting
3. Manipulating Graphs
1. Creating & Growing Datasets
2. Looping & Counting triples/quads in Datasets
3. Manipulating Graphs with Datasets
"""

from rdflib import Dataset, Graph, Literal, URIRef
Expand All @@ -30,7 +30,7 @@
# mypy: ignore_errors=true

#######################################################################################
# 1. Creating & Adding
# 1. Creating & Growing
#######################################################################################

# Create an empty Dataset
Expand Down
29 changes: 20 additions & 9 deletions examples/jsonld_serialization.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
"""
JSON-LD is "A JSON-based Serialization for Linked Data" (https://www.w3.org/TR/json-ld/) that RDFLib implements for RDF serialization.
JSON-LD is "A JSON-based Serialization for Linked Data" (https://www.w3.org/TR/json-ld/)
that RDFLib implements for RDF serialization.

This file demonstrated some of the JSON-LD things you can do with RDFLib. Parsing & serializing so far. More to be added later.
This file demonstrated some of the JSON-LD things you can do with RDFLib. Parsing &
serializing so far. More to be added later.


Parsing
-------
There are a number of "flavours" of JSON-LD - compact and verbose etc. RDFLib can parse all of these in a normal RDFLib way.

There are a number of "flavours" of JSON-LD - compact and verbose etc. RDFLib can parse
all of these in a normal RDFLib way.


Serialization
-------------
JSON-LD has a number of options for serialization - more than other RDF formats. For example, IRIs within JSON-LD can be compacted down to CURIES when a "context" statment is added to the JSON-LD data that maps identifiers - short codes - to IRIs and namespace IRIs like this:

# here the short code "dcterms" is mapped to the IRI http://purl.org/dc/terms/ and "schema" to https://schema.org/, as per RDFLib's in-build namespace prefixes
JSON-LD has a number of options for serialization - more than other RDF formats. For
example, IRIs within JSON-LD can be compacted down to CURIES when a "context" statement
is added to the JSON-LD data that maps identifiers - short codes - to IRIs and namespace
IRIs like this:

"@context": {
"dct": "http://purl.org/dc/terms/",
"schema": "https://schema.org/"
}
.. code-block:: json

"@context": {
"dcterms": "http://purl.org/dc/terms/",
"schema": "https://schema.org/"
}

Here the short code "dcterms" is mapped to the IRI http://purl.org/dc/terms/ and
"schema" to https://schema.org/, as per RDFLib's in-build namespace prefixes.
"""

# import RDFLib and other things
Expand Down
Loading