From db36d6277ad2066c507aec5c1937736d434d3291 Mon Sep 17 00:00:00 2001 From: Julian Risch Date: Fri, 27 Oct 2023 14:53:03 +0200 Subject: [PATCH] docs: Add readme sync for API docs 2.0 (#6173) * add sync docs for preview * add example config for audio docs * hardcode version in renderer * use custom renderer for preview docs * update comment and excerpt --- .github/utils/pydoc-markdown.sh | 8 ++++++++ .github/workflows/readme_sync.yml | 10 ++++++++++ docs/pydoc/config-preview/audio.yml | 26 ++++++++++++++++++++++++++ docs/pydoc/renderers.py | 13 +++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 docs/pydoc/config-preview/audio.yml diff --git a/.github/utils/pydoc-markdown.sh b/.github/utils/pydoc-markdown.sh index 4322da034..39bc6dd78 100755 --- a/.github/utils/pydoc-markdown.sh +++ b/.github/utils/pydoc-markdown.sh @@ -9,3 +9,11 @@ for file in ../config/* ; do echo "Converting $file..." pydoc-markdown "$file" done +# render preview markdown docs +cd .. +rm -rf temp-preview && mkdir temp-preview +cd temp-preview +for file in ../config-preview/* ; do + echo "Converting $file..." + pydoc-markdown "$file" +done diff --git a/.github/workflows/readme_sync.yml b/.github/workflows/readme_sync.yml index f0e5d0283..f13389a70 100644 --- a/.github/workflows/readme_sync.yml +++ b/.github/workflows/readme_sync.yml @@ -53,6 +53,16 @@ jobs: with: rdme: docs ./docs/pydoc/temp --key="$README_API_KEY" --version=${{ steps.current-version.outputs.minor }}-unstable + - name: Sync preview docs with 2.0 + # Sync the preview docs to the `2.0` version on Readme + id: sync-main-preview + if: github.ref_name == 'main' && github.event_name == 'push' + uses: readmeio/rdme@8.3.1 + env: + README_API_KEY: ${{ secrets.README_API_KEY }} + with: + rdme: docs ./docs/pydoc/temp-preview --key="$README_API_KEY" --version=2.0 + - name: Sync docs with current release # Mutually exclusive with the previous one, this step is supposed to only run on version branches. # Sync the current Haystack version `X.Y.Z` with its corresponding Readme version `X.Y`. diff --git a/docs/pydoc/config-preview/audio.yml b/docs/pydoc/config-preview/audio.yml new file mode 100644 index 000000000..200005959 --- /dev/null +++ b/docs/pydoc/config-preview/audio.yml @@ -0,0 +1,26 @@ +loaders: + - type: loaders.CustomPythonLoader + search_path: [../../../haystack/preview/components/audio] + modules: ["whisper_local"] + 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: renderers.ReadmePreviewRenderer + excerpt: LocalWhisperTranscriber transcribes audio files using OpenAI's Whisper models on your local machine + category_slug: haystack-classes + title: LocalWhisperTranscriber API + slug: local-whisper-transcriber-api + order: 10 + markdown: + descriptive_class_title: false + descriptive_module_title: true + add_method_class_prefix: true + add_member_class_prefix: false + filename: local_whisper_transcriber_api.md diff --git a/docs/pydoc/renderers.py b/docs/pydoc/renderers.py index c74a60dc7..6450f666c 100644 --- a/docs/pydoc/renderers.py +++ b/docs/pydoc/renderers.py @@ -133,3 +133,16 @@ class ReadmeRenderer(Renderer): slug=self.slug, order=self.order, ) + + +@dataclasses.dataclass +class ReadmePreviewRenderer(ReadmeRenderer): + """ + This custom Renderer behaves just like the ReadmeRenderer but renders docs with the hardcoded version 2.0 to generate correct category ids. + """ + + def _doc_version(self) -> str: + """ + Returns the hardcoded docs version 2.0. + """ + return "v2.0"