From 52508a69469cbfcf3aef8e170b76303adf3d9013 Mon Sep 17 00:00:00 2001 From: Silvano Cerza <3314350+silvanocerza@users.noreply.github.com> Date: Thu, 8 Feb 2024 17:07:01 +0100 Subject: [PATCH] feat: Generate API docs (#380) * Adds docs generation in instructor_embedders * Trigger CI * Update config.yml * Remove CI trigger --- .github/workflows/instructor_embedders.yml | 32 ++++++++------ .../instructor_embedders/pydoc/config.yml | 30 +++++++++++++ .../instructor_embedders/pyproject.toml | 44 ++++++++----------- 3 files changed, 66 insertions(+), 40 deletions(-) create mode 100644 integrations/instructor_embedders/pydoc/config.yml diff --git a/.github/workflows/instructor_embedders.yml b/.github/workflows/instructor_embedders.yml index 4145408e2..09d04e9d3 100644 --- a/.github/workflows/instructor_embedders.yml +++ b/.github/workflows/instructor_embedders.yml @@ -5,8 +5,8 @@ on: - cron: "0 0 * * *" pull_request: paths: - - 'integrations/instructor_embedders/**' - - '.github/workflows/instructor_embedders.yml' + - "integrations/instructor_embedders/**" + - ".github/workflows/instructor_embedders.yml" defaults: run: @@ -16,19 +16,23 @@ jobs: test: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: '3.10' + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" - - name: Install Hatch - run: pip install --upgrade hatch + - name: Install Hatch + run: pip install --upgrade hatch - - name: Lint - run: hatch run lint:all + - name: Lint + run: hatch run lint:all - - name: Run tests - run: hatch run cov + - name: Generate docs + if: runner.os == 'Linux' + run: hatch run docs + + - name: Run tests + run: hatch run cov diff --git a/integrations/instructor_embedders/pydoc/config.yml b/integrations/instructor_embedders/pydoc/config.yml new file mode 100644 index 000000000..cc16a72f7 --- /dev/null +++ b/integrations/instructor_embedders/pydoc/config.yml @@ -0,0 +1,30 @@ +loaders: + - type: haystack_pydoc_tools.loaders.CustomPythonLoader + search_path: [../src] + modules: + [ + "haystack_integrations.components.embedders.instructor_embedders", + "haystack_integrations.components.embedders.instructor_embedders.embedding_backend", + ] + 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: Embedders integration for Haystack + category_slug: haystack-integrations + title: Embedders + slug: integrations-instructor-embedders + order: 90 + markdown: + descriptive_class_title: false + descriptive_module_title: true + add_method_class_prefix: true + add_member_class_prefix: false + filename: _readme_instructor_embedders.md diff --git a/integrations/instructor_embedders/pyproject.toml b/integrations/instructor_embedders/pyproject.toml index c8a591b69..24e69ce59 100644 --- a/integrations/instructor_embedders/pyproject.toml +++ b/integrations/instructor_embedders/pyproject.toml @@ -10,9 +10,7 @@ readme = "README.md" requires-python = ">=3.7" license = "Apache-2.0" keywords = [] -authors = [ - { name = "deepset GmbH", email = "info@deepset.ai" }, -] +authors = [{ name = "deepset GmbH", email = "info@deepset.ai" }] classifiers = [ "Development Status :: 4 - Beta", "Programming Language :: Python", @@ -43,7 +41,7 @@ dependencies = [ "tqdm", "rich", - "InstructorEmbedding" + "InstructorEmbedding", ] [project.optional-dependencies] @@ -66,38 +64,26 @@ root = "../.." git_describe_command = 'git describe --tags --match="integrations/instructor_embedders-v[0-9]*"' [tool.hatch.envs.default] -dependencies = ["pytest", "pytest-cov"] +dependencies = ["pytest", "pytest-cov", "haystack-pydoc-tools"] [tool.hatch.envs.default.scripts] cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=instructor-embedders --cov=tests" no-cov = "cov --no-cov" test = "pytest {args:tests}" +docs = "pydoc-markdown pydoc/config.yml" [[tool.hatch.envs.test.matrix]] python = ["38", "39", "310", "311"] [tool.hatch.envs.lint] detached = true -dependencies = [ - "black>=23.1.0", - "mypy>=1.0.0", - "ruff>=0.0.243", -] +dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"] + [tool.hatch.envs.lint.scripts] typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}" -style = [ - "ruff {args:.}", - "black --check --diff {args:.}", -] -fmt = [ - "black {args:.}", - "ruff --fix {args:.}", - "style", -] -all = [ - "style", - "typing", -] +style = ["ruff {args:.}", "black --check --diff {args:.}"] +fmt = ["black {args:.}", "ruff --fix {args:.}", "style"] +all = ["style", "typing"] [tool.coverage.run] branch = true @@ -141,9 +127,15 @@ ignore = [ # Allow boolean positional values in function calls, like `dict.get(... True)` "FBT003", # Ignore checks for possible passwords - "S105", "S106", "S107", + "S105", + "S106", + "S107", # Ignore complexity - "C901", "PLR0911", "PLR0912", "PLR0913", "PLR0915", + "C901", + "PLR0911", + "PLR0912", + "PLR0913", + "PLR0915", ] unfixable = [ # Don't touch unused imports @@ -178,4 +170,4 @@ module = [ "pytest.*", "numpy.*", ] -ignore_missing_imports = true \ No newline at end of file +ignore_missing_imports = true