File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -216,7 +216,7 @@ attempt to use a locally cached version of contexts (see
216216[ § Cache JSON-LD Contexts] ( https://w3c.github.io/json-ld-bp/#cache-json-ld-contexts ) ).
217217Refresh the bundled copies with ` make download-bundled-contexts ` .
218218
219- ### Customizing the ContextLoader
219+ ### Customizing the ContextResolver
220220
221221You can customize the way contexts are loaded and cached by passing an instance
222222of ` ContextResolver ` . The following example implements a loader with a prefilled
Original file line number Diff line number Diff line change 1+ # :material-cached: ` ContextResolver `
2+
3+ ` ContextResolver ` resolves remote ` @context ` documents and caches the resolved
4+ contexts used by JSON-LD operations.
5+
6+ ::: pyld.ContextResolver
7+ options:
8+ show_root_heading: false
9+ show_bases: false
10+ heading_level: 3
11+
12+ Pass a custom ` ContextResolver ` with the ` contextResolver ` option when you need
13+ to provide your own resolved-context cache or adjust the remote-context recursion
14+ limit. The resolver still uses a ` DocumentLoader ` to fetch remote context
15+ documents, so pass the same loader with ` documentLoader ` .
16+
17+ {{ example('context_resolver.py', output_syntax='json') }}
18+
19+ The ` shared_cache ` object must behave like a mutable mapping. PyLD uses
20+ ` cachetools.LRUCache ` by default, but applications can provide another mapping
21+ when they need a different eviction policy.
22+
23+ Use ` max_context_urls ` to change how many remote contexts may be fetched while
24+ resolving nested or imported contexts.
Original file line number Diff line number Diff line change @@ -67,6 +67,12 @@ hide: [toc]
6767
6868 Load remote JSON-LD documents and contexts with the built-in loader classes.
6969
70+ - [ :material-cached:{ .lg .middle } ` ContextResolver ` ] ( context-resolver.md )
71+
72+ ---
73+
74+ Resolve and cache remote ` @context ` documents during JSON-LD processing.
75+
7076- :material-hard-hat:{ .lg .middle } __ In construction__
7177
7278 ---
You can’t perform that action at this time.
0 commit comments