From fc4cf908245020f771e212ad85edbc8f040f1411 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Thu, 1 Feb 2024 08:56:11 +0100 Subject: [PATCH] opensearch: generate API docs --- .github/workflows/opensearch.yml | 10 ++++++-- integrations/opensearch/pydoc/config.yml | 31 ++++++++++++++++++++++++ integrations/opensearch/pyproject.toml | 5 ++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 integrations/opensearch/pydoc/config.yml diff --git a/.github/workflows/opensearch.yml b/.github/workflows/opensearch.yml index aacb4ce71..72a01d090 100644 --- a/.github/workflows/opensearch.yml +++ b/.github/workflows/opensearch.yml @@ -18,6 +18,10 @@ env: PYTHONUNBUFFERED: "1" FORCE_COLOR: "1" +defaults: + run: + working-directory: integrations/opensearch + jobs: run: name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }} @@ -40,14 +44,16 @@ jobs: run: pip install --upgrade hatch - name: Lint - working-directory: integrations/opensearch if: matrix.python-version == '3.9' run: hatch run lint:all - name: Run opensearch container - working-directory: integrations/opensearch run: docker-compose up -d + - name: Generate docs + if: matrix.python-version == '3.9' && runner.os == 'Linux' + run: hatch run docs + - name: Run tests working-directory: integrations/opensearch run: hatch run cov diff --git a/integrations/opensearch/pydoc/config.yml b/integrations/opensearch/pydoc/config.yml new file mode 100644 index 000000000..3e07f6625 --- /dev/null +++ b/integrations/opensearch/pydoc/config.yml @@ -0,0 +1,31 @@ +loaders: + - type: haystack_pydoc_tools.loaders.CustomPythonLoader + search_path: [../src] + modules: [ + "haystack_integrations.components.retrievers.opensearch.bm25_retriever", + "haystack_integrations.components.retrievers.opensearch.embedding_retriever", + "haystack_integrations.document_stores.opensearch.document_store", + "haystack_integrations.document_stores.opensearch.filters", + ] + ignore_when_discovered: ["__init__"] +processors: + - type: filter + expression: + documented_only: true + do_not_filter_modules: false + skip_empty_modules: true + - type: smart + - type: crossref +renderer: + type: haystack_pydoc_tools.renderers.ReadmePreviewRenderer + excerpt: OpenSearch integration for Haystack + category_slug: haystack-integrations + title: OpenSearch + slug: integrations-opensearch + order: 130 + markdown: + descriptive_class_title: false + descriptive_module_title: true + add_method_class_prefix: true + add_member_class_prefix: false + filename: _readme_opensearch.md diff --git a/integrations/opensearch/pyproject.toml b/integrations/opensearch/pyproject.toml index 3edd544a2..794fa73fa 100644 --- a/integrations/opensearch/pyproject.toml +++ b/integrations/opensearch/pyproject.toml @@ -49,6 +49,7 @@ dependencies = [ "coverage[toml]>=6.5", "pytest", "pytest-xdist", + "haystack-pydoc-tools", ] [tool.hatch.envs.default.scripts] test = "pytest {args:tests}" @@ -62,6 +63,10 @@ cov = [ "cov-report", ] +docs = [ + "pydoc-markdown pydoc/config.yml" +] + [[tool.hatch.envs.all.matrix]] python = ["3.8", "3.9", "3.10", "3.11"]