A CKAN extension that allows attaching a flexible data dictionary (resource documentation) to any resource — not just those backed by the Datastore.
Each resource’s documentation can include a validation schema defined individually using JSON Schema Draft 2020-12, enabling optional enforcement of structure and constraints while maintaining the flexibility of a free-form data dictionary.
The official specification for JSON Schema Draft 2020-12 is available here.
Here is an example of a resource documentation in a format of Datastore fields. But it's not limited to that format, you can save any custom data you need.
It's also possible to define a validation schema for the resource documentation, which will be used to validate the documentation data.
Requirements
Compatibility with core CKAN versions:
| CKAN version | Compatible? |
|---|---|
| 2.9 and earlier | no |
| 2.10+ | yes |
Installation
To install ckanext-resource-docs:
-
Activate your CKAN virtual environment, for example:
. /usr/lib/ckan/default/bin/activate -
Install the extension from PyPI:
pip install ckanext-resource-docs
-
Add
resource_docsto theckan.pluginssetting in your CKAN config file (usually located at/etc/ckan/default/ckan.ini). -
Restart CKAN. For example, if you've deployed CKAN with Apache on Ubuntu:
sudo service apache2 reload
Config settings
The following options control how ckanext-resource-docs behaves.
ckanext.resource_docs.append_docs_to_resource_api
Type: bool
Default: false
When true, resource documentation is automatically included in the standard CKAN resource API response. This allows clients to retrieve documentation without making a separate API call.
Example:
ckanext.resource_docs.append_docs_to_resource_api = true
Example API response
With append_docs_to_resource_api = true and the default api_field_name:
{
"id": "resource-id-123",
"name": "my-resource.csv",
"url": "https://example.com/data.csv",
"format": "CSV",
"resource_docs": {
"documentation": "This dataset contains...",
"fields": [
{
"name": "column1",
"description": "Description of column1",
"type": "string"
}
]
}
}
ckanext.resource_docs.api_field_name
Type: string
Default: resource_docs
Specifies the field name in the API response that will contain the resource documentation. Only applies if append_docs_to_resource_api is enabled.
Example:
ckanext.resource_docs.api_field_name = documentation
With this setting, the documentation appears under "documentation" field instead of "resource_docs".
ckanext.resource_docs.show_view
Type: bool
Default: false
When true, the resource documentation is displayed in the resource view page in the CKAN web interface.
Example:
ckanext.resource_docs.show_view = true
View example:
Interface
The IResourceDocs interface allows CKAN plugins to extend the behavior of resource documentation extension.
Current methods:
prepopulate_resource_docs- Provide initial documentation using resource metadata.
Example implementation
import json
import ckan.plugins as p
import ckan.logic as tk
from ckanext.resource_docs.interfaces import IResourceDocs
class YourPlugin(p.SingletonPlugin):
"""Example plugin implementing IResourceDocs."""
...
p.implements(IResourceDocs, inherit=True)
def prepopulate_resource_docs(self, resource: dict[str, Any]) -> str:
"""Provide initial documentation using the DataStore Data Dictionary."""
try:
result = tk.get_action("datastore_info")(
{"user": tk.current_user.name if tk.current_user else ""},
{"id": resource["id"]}
)
except (tk.ValidationError, tk.ObjectNotFound):
return ""
return json.dumps(result["fields"])
Developer installation
To install ckanext-resource-docs for development, activate your CKAN virtualenv and do:
git clone https://github.com/DataShades/ckanext-resource-docs.git
cd ckanext-resource-docs
pip install -e .
Tests
To run the tests, do:
pytest --ckan-ini=test.ini
License
Metadata
Release files for ckanext-resource-docs 0.4.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ckanext_resource_docs-0.4.5.tar.gz | 336.0 kB | Without provenance | Details for ckanext_resource_docs-0.4.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ckanext_resource_docs-0.4.5-py3-none-any.whl | Python 3 | none | any | Details for ckanext_resource_docs-0.4.5-py3-none-any.whl |
Total release size: 679.5 kB
Release files / ckanext_resource_docs-0.4.5.tar.gz
| Download URL | ckanext_resource_docs-0.4.5.tar.gz |
|---|---|
| Size | 336.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ed19ea55bf5e95c23ab9f60eedbb5fb12c82c1f6a053f3cee651e355c7ed16a9
|
|
BLAKE2b-256 checksum How to use checksums |
ade374602ce0f87976981933e3b75e33d5dc8783c80443fa8e7ea2290b47d292
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.18
|
Release files / ckanext_resource_docs-0.4.5-py3-none-any.whl
| Download URL | ckanext_resource_docs-0.4.5-py3-none-any.whl |
|---|---|
| Size | 343.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
106a96c9cea170097a007545ffa84ca06ab0add576582200c282878012aed39d
|
|
BLAKE2b-256 checksum How to use checksums |
36e3f8213199e6db4a68144d6e9e66d0fb48439956614c0aff32866c847d3d63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.18
|
Security for ckanext-resource-docs 0.4.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.