From f75ec6f764d4f18abd3f5bdc89824ed41701791f Mon Sep 17 00:00:00 2001 From: mutantsan Date: Thu, 24 Oct 2024 13:47:05 +0300 Subject: [PATCH] doc: update doc --- README.md | 63 +-------------- docs/index.md | 62 +++++++++++++- mkdocs.yml | 7 +- site/404.html | 54 ++++--------- site/index.html | 147 +++++++++++++++++++++++++++------- site/search/search_index.json | 2 +- site/sitemap.xml | 2 +- site/sitemap.xml.gz | Bin 190 -> 194 bytes 8 files changed, 203 insertions(+), 134 deletions(-) diff --git a/README.md b/README.md index 661af39..8bead03 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ This extension will capture and retain a comprehensive record of all changes within a CKAN app. +Read the [documentation](https://datashades.github.io/ckanext-event-audit/) for a full user guide. + ## Developer installation To install ckanext-event-audit for development, activate your CKAN virtualenv and @@ -14,66 +16,6 @@ do: pip install -e . pip install -r dev-requirements.txt - -## Register new repositories - -There are few repositories available by default, but you can register new repositories to store the events. Think of it as a way to store the events in different databases or services. We don't want to limit the extension to a specific storage. The main idea is to provide a way to store, retrieve, and filter the events. - -To register a new repository, you need to define a repository class and register it. - -### Defining the repository class - -To register a new repository, you need to define a repository class that inherits from `AbstractRepository` and implements the following methods: `write_event`, `get_event`, and `filter_events`. - -For example: - -```python -from ckanext.event_audit.repositories import AbstractRepository -from ckanext.event_audit import types - - -class MyRepository(AbstractRepository): - name = "my_repository" - - @classmethod - def get_name(cls) -> str: - return "my_repository" - - def write_event(self, event: types.Event) -> types.WriteStatus: - pass - - def get_event(self, event_id: str) -> types.Event | None: - pass - - def filter_events(self, filters: types.Filters) -> list[types.Event]: - pass -``` - -See the existing repositories as examples (`ckanext/event_audit/repositories/`). - -### Registering the repository - -To register the new repository, you need to use a IEventAudit interface and the `register_repository` method. - -For example: - -```python -from ckanext.event_audit.interfaces import IEventAudit -from ckanext.your_extension.repositories import MyRepository - -class MyRepositoryPlugin(plugins.SingletonPlugin): - ... - plugins.implements(IEventAudit, inherit=True) - - # IEventAudit - - def register_repository(self) -> dict[str, type[AbstractRepository]]: - return { - MyRepository.get_name(): MyRepository, - } -``` - - ## Tests To run the tests, do: @@ -83,3 +25,4 @@ To run the tests, do: ## License [AGPL](https://www.gnu.org/licenses/agpl-3.0.en.html) + diff --git a/docs/index.md b/docs/index.md index 34a0c59..661af39 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,8 +4,6 @@ This extension will capture and retain a comprehensive record of all changes within a CKAN app. -Read the [documentation](https://datashades.github.io/ckanext-event-audit/) for a full user guide. - ## Developer installation To install ckanext-event-audit for development, activate your CKAN virtualenv and @@ -16,6 +14,66 @@ do: pip install -e . pip install -r dev-requirements.txt + +## Register new repositories + +There are few repositories available by default, but you can register new repositories to store the events. Think of it as a way to store the events in different databases or services. We don't want to limit the extension to a specific storage. The main idea is to provide a way to store, retrieve, and filter the events. + +To register a new repository, you need to define a repository class and register it. + +### Defining the repository class + +To register a new repository, you need to define a repository class that inherits from `AbstractRepository` and implements the following methods: `write_event`, `get_event`, and `filter_events`. + +For example: + +```python +from ckanext.event_audit.repositories import AbstractRepository +from ckanext.event_audit import types + + +class MyRepository(AbstractRepository): + name = "my_repository" + + @classmethod + def get_name(cls) -> str: + return "my_repository" + + def write_event(self, event: types.Event) -> types.WriteStatus: + pass + + def get_event(self, event_id: str) -> types.Event | None: + pass + + def filter_events(self, filters: types.Filters) -> list[types.Event]: + pass +``` + +See the existing repositories as examples (`ckanext/event_audit/repositories/`). + +### Registering the repository + +To register the new repository, you need to use a IEventAudit interface and the `register_repository` method. + +For example: + +```python +from ckanext.event_audit.interfaces import IEventAudit +from ckanext.your_extension.repositories import MyRepository + +class MyRepositoryPlugin(plugins.SingletonPlugin): + ... + plugins.implements(IEventAudit, inherit=True) + + # IEventAudit + + def register_repository(self) -> dict[str, type[AbstractRepository]]: + return { + MyRepository.get_name(): MyRepository, + } +``` + + ## Tests To run the tests, do: diff --git a/mkdocs.yml b/mkdocs.yml index d69166c..54e2360 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,7 +1,7 @@ -site_name: ckanext-popo -site_url: https://.github.io/ckanext-popo/ +site_name: ckanext-event-audit +site_url: https://.github.io/ckanext-event-audit/ -repo_url: https://github.com//ckanext-popo +repo_url: https://github.com//ckanext-event-audit markdown_extensions: - pymdownx.snippets # include code snippets @@ -74,4 +74,3 @@ theme: nav: - index.md - - hui.md diff --git a/site/404.html b/site/404.html index 2bed01c..40aae07 100644 --- a/site/404.html +++ b/site/404.html @@ -11,19 +11,19 @@ - + - ckanext-popo + ckanext-event-audit - + - + @@ -42,9 +42,9 @@ - + - + @@ -81,9 +81,9 @@