Skip to main content

A CKAN extension that lets you attach a flexible, schema-free data dictionary (“resource documentation”) to any resource, not just Datastore-backed ones.

Project description

Tests

A CKAN extension that lets you attach a flexible, schema-free data dictionary (resource documentation) to any resource — not just those backed by the Datastore. It supports custom fields via extensions, reuses CKAN’s existing data dictionary UI, and displays documentation directly on resource pages.

New in the latest version: you can now define a validation schema for each resource’s documentation individually, using JSON Schema Draft 2020-12. This allows you to optionally enforce structure and constraints while still keeping the flexibility of a free-form data dictionary.

You can read the official specification for JSON Schema Draft 2020-12 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.

Documentation table

It's also possible to define a validation schema for the resource documentation, which will be used to validate the documentation data.

Validation schema

Requirements

Compatibility with core CKAN versions:

CKAN version Compatible?
2.9 and earlier no
2.10+ yes

Installation

To install ckanext-resource-docs:

  1. Activate your CKAN virtual environment, for example:

    . /usr/lib/ckan/default/bin/activate
    
  2. Install the extension from PyPI:

    pip install ckanext-resource-docs
    
  3. Add resource_docs to the ckan.plugins setting in your CKAN config file (usually located at /etc/ckan/default/ckan.ini).

  4. 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

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".


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"
      }
    ]
  }
}

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

AGPL

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ckanext_resource_docs-0.2.0.tar.gz (329.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ckanext_resource_docs-0.2.0-py3-none-any.whl (334.2 kB view details)

Uploaded Python 3

File details

Details for the file ckanext_resource_docs-0.2.0.tar.gz.

File metadata

  • Download URL: ckanext_resource_docs-0.2.0.tar.gz
  • Upload date:
  • Size: 329.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for ckanext_resource_docs-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0fa6696094969a64976b41d04bbc619a9ab548d2aa5bacecd29dc474b7ed0c2b
MD5 57e108b4ce73ed3b154fb0d4c98e23c8
BLAKE2b-256 2dac14194b5b68c252c6ed766e840be130bae32acadc0499ecd6621e6ee76e3c

See more details on using hashes here.

File details

Details for the file ckanext_resource_docs-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ckanext_resource_docs-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b0593bb6901e1164cbfa583a25380aeff9d74440662dbaf7cd72d4cf6f18893
MD5 bb02ab9f485d64107358e34e180ad778
BLAKE2b-256 3b28973a04f2034291b4f03c76e7d325d6709a715b3d97c882de539a89eb0fa1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page