Skip to content

Commit 3654cc2

Browse files
authored
Merge pull request #235 from contentauth/mathern/docs-for-python
docs: Document Context+Settings API, Intents, Working Stores
2 parents 0622915 + ebc70b7 commit 3654cc2

7 files changed

Lines changed: 2951 additions & 361 deletions

File tree

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@ Features:
1212
- Add assertions and ingredients to assets.
1313
- Examples and unit tests to demonstrate usage.
1414

15+
<div style={{display: 'none'}}>
16+
17+
For the best experience, read the docs on the [CAI Open Source SDK documentation website](https://opensource.contentauthenticity.org/docs/c2pa-c).
18+
19+
If you want to view the documentation in GitHub, see:
20+
- [Using the Python library](docs/usage.md)
21+
- [Supported formats](https://github.com/contentauth/c2pa-rs/blob/main/docs/supported-formats.md)
22+
- [Configuring the SDK using `Context` and `Settings`](docs/context-settings.md)
23+
- [Using Builder intents](docs/intents.md) to ensure spec-compliant manifests
24+
- Using [working stores and archvies](docs/working-stores.md)
25+
- Selectively constructing manifests by [filtering actions and ingredients](docs/selective-manifests.md)
26+
- [Diagram of public classes in the Python library and their relationships](docs/class-diagram.md)
27+
- [Release notes](docs/release-notes.md)
28+
29+
</div>
30+
1531
## Prerequisites
1632

1733
This library requires Python version 3.10+.

docs/class-diagram.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
2+
# Class diagram
3+
4+
This diagram shows the public classes in the Python library and their relationships.
5+
6+
```mermaid
7+
classDiagram
8+
direction LR
9+
10+
class Settings {
11+
+from_json(json_str) Settings$
12+
+from_dict(config) Settings$
13+
+set(path, value) Settings
14+
+update(data) Settings
15+
+close()
16+
+is_valid bool
17+
}
18+
19+
class ContextProvider {
20+
<<abstract>>
21+
+is_valid bool*
22+
+execution_context*
23+
}
24+
25+
class Context {
26+
+from_json(json_str, signer) Context$
27+
+from_dict(config, signer) Context$
28+
+has_signer bool
29+
+is_valid bool
30+
+close()
31+
}
32+
33+
class Reader {
34+
+get_supported_mime_types() list~str~$
35+
+try_create(format_or_path, stream, manifest_data, context) Reader | None$
36+
+json() str
37+
+detailed_json() str
38+
+get_active_manifest() dict | None
39+
+get_manifest(label) dict
40+
+get_validation_state() str | None
41+
+get_validation_results() dict | None
42+
+resource_to_stream(uri, stream) int
43+
+is_embedded() bool
44+
+get_remote_url() str | None
45+
+close()
46+
}
47+
48+
class Builder {
49+
+from_json(manifest_json, context) Builder$
50+
+from_archive(stream) Builder$
51+
+get_supported_mime_types() list~str~$
52+
+set_no_embed()
53+
+set_remote_url(url)
54+
+set_intent(intent, digital_source_type)
55+
+add_resource(uri, stream)
56+
+add_ingredient(json, format, source)
57+
+add_action(action_json)
58+
+to_archive(stream)
59+
+with_archive(stream) Builder
60+
+sign(signer, format, source, dest) bytes
61+
+sign(format, source, dest) bytes
62+
+sign_file(source_path, dest_path, signer) bytes
63+
+close()
64+
}
65+
66+
class Signer {
67+
+from_info(signer_info) Signer$
68+
+from_callback(callback, alg, certs, tsa_url) Signer$
69+
+reserve_size() int
70+
+close()
71+
}
72+
73+
class C2paSignerInfo {
74+
<<ctypes.Structure>>
75+
+alg
76+
+sign_cert
77+
+private_key
78+
+ta_url
79+
}
80+
81+
class C2paSigningAlg {
82+
<<IntEnum>>
83+
ES256
84+
ES384
85+
ES512
86+
PS256
87+
PS384
88+
PS512
89+
ED25519
90+
}
91+
92+
class C2paBuilderIntent {
93+
<<IntEnum>>
94+
CREATE
95+
EDIT
96+
UPDATE
97+
}
98+
99+
class C2paDigitalSourceType {
100+
<<IntEnum>>
101+
DIGITAL_CAPTURE
102+
DIGITAL_CREATION
103+
TRAINED_ALGORITHMIC_MEDIA
104+
...
105+
}
106+
107+
class C2paError {
108+
<<Exception>>
109+
+message str
110+
}
111+
112+
class C2paError_Subtypes {
113+
<<nested classes>>
114+
ManifestNotFound
115+
NotSupported
116+
Json
117+
Io
118+
Verify
119+
Signature
120+
...
121+
}
122+
123+
ContextProvider <|-- Context : extends
124+
Settings --> Context : optional input
125+
Signer --> Context : optional, consumed
126+
C2paSignerInfo --> Signer : creates via from_info
127+
C2paSigningAlg --> C2paSignerInfo : alg field
128+
C2paSigningAlg --> Signer : from_callback alg
129+
Context --> Reader : context=
130+
Context --> Builder : context=
131+
Signer --> Builder : sign(signer)
132+
C2paBuilderIntent --> Builder : set_intent
133+
C2paDigitalSourceType --> Builder : set_intent
134+
C2paError --> C2paError_Subtypes : subclasses
135+
```

0 commit comments

Comments
 (0)