Skip to content

Commit

Permalink
Added google-style docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
lu-pl committed Jul 11, 2024
1 parent cff7ad5 commit 9ddbf54
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions lodkit/uri_tools/uriclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,24 @@ class uriclass:
For class attributes with just type information, URIs are constructed using UUIDs,
for class attributes with string values, URIs are constructed using hashing based on that string.
Example:
Examples:
@uriclass(Namespace("https://test.org/test/"))
class uris:
x1: str
@uriclass(Namespace("https://test.org/test/"))
class uris:
x1: str
y1 = "hash value 1"
y2 = "hash value 1"
y1 = "hash value 1"
y2 = "hash value 1"
print(uris.x1) # Namespace("https://test.org/test/<UUID>")
print(uris.y1 == uris.y2) # True
print(uris.x1) # Namespace("https://test.org/test/<UUID>")
print(uris.y1 == uris.y2) # True
"""

def __init__(
self,
namespace: str,
uri_constructor: _TURIConstructorFactory = mkuri_factory,
) -> None:

self._mkuri = uri_constructor(namespace)

def __call__[T](self, cls: T) -> T:
Expand All @@ -59,17 +57,16 @@ def make_uriclass(
make_uriclass provides functionality structurally equivalent to @uriclass,
but fields are read from an Iterable[str | tuple[str, str]].
Example:
uris = make_uriclass(
cls_name="TestURIFun",
namespace="https://test.org/test/",
fields=("x", ("y1", "hash value 1"), ("y2", "hash value 1")),
)
Examples:
uris = make_uriclass(
cls_name="TestURIFun",
namespace="https://test.org/test/",
fields=("x", ("y1", "hash value 1"), ("y2", "hash value 1")),
)
print(uris.x1) # Namespace("https://test.org/test/<UUID>")
print(uris.y1 == uris.y2) # True
print(uris.x1) # Namespace("https://test.org/test/<UUID>")
print(uris.y1 == uris.y2) # True
"""
_mkuri = uri_constructor(namespace)

Expand Down

0 comments on commit 9ddbf54

Please sign in to comment.