From 474d41466ccbe480953283ea1279092ff92d7758 Mon Sep 17 00:00:00 2001 From: Jackmin801 Date: Sun, 23 Oct 2022 20:41:41 +0800 Subject: [PATCH 01/16] docs: add versioned docs to sidebar --- docs/_templates/sidebar/brand.html | 47 +++++++++++++++++------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/docs/_templates/sidebar/brand.html b/docs/_templates/sidebar/brand.html index 1531f31b10f..48e37ed9643 100644 --- a/docs/_templates/sidebar/brand.html +++ b/docs/_templates/sidebar/brand.html @@ -16,26 +16,33 @@ {%- endif %} {% endblock brand_content %} + +
Star - {% if versions %} - + - {% endif %} -
+ \ No newline at end of file From d24e82bda23df5fcd53fd6155ebd19c7e040665f Mon Sep 17 00:00:00 2001 From: Jackmin801 Date: Fri, 21 Oct 2022 01:20:28 +0800 Subject: [PATCH 02/16] docs: add version metadata --- docs/_versions.json | 1 + docs/_versions.yml | 34 ++++++++++++++++++++++++++++++++++ docs/y2j.py | 5 +++++ 3 files changed, 40 insertions(+) create mode 100644 docs/_versions.json create mode 100644 docs/_versions.yml create mode 100644 docs/y2j.py diff --git a/docs/_versions.json b/docs/_versions.json new file mode 100644 index 00000000000..0c7e993aa06 --- /dev/null +++ b/docs/_versions.json @@ -0,0 +1 @@ +[{"version": "v0.18.0"}, {"version": "v0.17.0"}, {"version": "v0.16.5"}, {"version": "v0.16.0"}, {"version": "v0.15.4"}, {"version": "v0.15.0"}, {"version": "v0.14.11"}, {"version": "v0.14.0"}, {"version": "v0.13.33"}, {"version": "v0.13.0"}, {"version": "v0.12.9"}, {"version": "v0.12.0"}, {"version": "v0.11.3"}, {"version": "v0.11.0"}, {"version": "v0.10.5"}, {"version": "v0.10.0"}, {"version": "v0.9.18"}, {"version": "v0.9.0"}, {"version": "v0.8.11"}, {"version": "v0.8.0"}, {"version": "v0.7.3"}, {"version": "v0.7.0"}, {"version": "v0.6.3"}, {"version": "v0.6.0"}, {"version": "v0.5.3"}, {"version": "v0.5.0"}, {"version": "v0.4.3"}, {"version": "v0.4.0"}, {"version": "v0.3.3"}, {"version": "v0.3.0"}, {"version": "v0.2.0"}, {"version": "v0.1.7"}, {"version": "v0.1.1"}, {"version": "v0.0.0"}] \ No newline at end of file diff --git a/docs/_versions.yml b/docs/_versions.yml new file mode 100644 index 00000000000..bcad5cf44e3 --- /dev/null +++ b/docs/_versions.yml @@ -0,0 +1,34 @@ +- version: v0.18.0 +- version: v0.17.0 +- version: v0.16.5 +- version: v0.16.0 +- version: v0.15.4 +- version: v0.15.0 +- version: v0.14.11 +- version: v0.14.0 +- version: v0.13.33 +- version: v0.13.0 +- version: v0.12.9 +- version: v0.12.0 +- version: v0.11.3 +- version: v0.11.0 +- version: v0.10.5 +- version: v0.10.0 +- version: v0.9.18 +- version: v0.9.0 +- version: v0.8.11 +- version: v0.8.0 +- version: v0.7.3 +- version: v0.7.0 +- version: v0.6.3 +- version: v0.6.0 +- version: v0.5.3 +- version: v0.5.0 +- version: v0.4.3 +- version: v0.4.0 +- version: v0.3.3 +- version: v0.3.0 +- version: v0.2.0 +- version: v0.1.7 +- version: v0.1.1 +- version: v0.0.0 \ No newline at end of file diff --git a/docs/y2j.py b/docs/y2j.py new file mode 100644 index 00000000000..e5227f04a4e --- /dev/null +++ b/docs/y2j.py @@ -0,0 +1,5 @@ +import yaml +import json + +with open('_versions.yml') as versions_yml, open('_versions.json', 'w') as versions_json: + json.dump(yaml.safe_load(versions_yml), versions_json) \ No newline at end of file From 2234dbe8dcaa05521f54fa3b94ff708291efb8fc Mon Sep 17 00:00:00 2001 From: Jackmin801 Date: Sun, 23 Oct 2022 20:51:15 +0800 Subject: [PATCH 03/16] ci: add workflow to build old docs --- .github/workflows/build-old-docs.yml | 116 +++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 .github/workflows/build-old-docs.yml diff --git a/.github/workflows/build-old-docs.yml b/.github/workflows/build-old-docs.yml new file mode 100644 index 00000000000..86f01db7724 --- /dev/null +++ b/.github/workflows/build-old-docs.yml @@ -0,0 +1,116 @@ +name: Build old docs + +on: + workflow_dispatch: + inputs: + release_token: + description: 'Your release token' + required: true + triggered_by: + description: 'CD | TAG | MANUAL' + required: false + default: MANUAL + package: + description: The name of the repo to build documentation for. + type: string + default: docarray + repo_owner: + description: The owner of the repo to build documentation for. Defaults to 'jina-ai'. + type: string + default: jina-ai + pages_branch: + description: Branch that Github Pages observes + type: string + default: gh-pages + git_config_name: + type: string + default: Jina Dev Bot + git_config_email: + type: string + default: dev-bot@jina.ai + +jobs: + token-check: + runs-on: ubuntu-latest + steps: + - run: echo "Success!" + if: "${{ github.event.inputs.release_token }} == ${{ env.release_token }}" + env: + release_token: ${{ secrets.JINA_DEV_RELEASE_TOKEN }} + - id: get_versions + run: | + printf "versions=" >> $GITHUB_OUTPUT + curl https://raw.githubusercontent.com/${{ inputs.repo_owner }}/${{ inputs.package }}/main/docs/_versions.json >> $GITHUB_OUTPUT + outputs: + versions: ${{ steps.get_versions.outputs.versions }} + + build-doc: + needs: token-check + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: ${{ fromJson(needs.token-check.outputs.versions) }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + ref: ${{ matrix.version }} + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Get latest templates + run: | + git show --summary + echo "Get latest sidebar brand template" + wget https://raw.githubusercontent.com/${{ inputs.repo_owner }}/${{ inputs.package }}/main/docs/_templates/sidebar/brand.html + mv ./brand.html ./docs/_templates/sidebar/brand.html + - name: Install dependencies + run: | + pip install .[devel] + cd docs + pip install -r requirements.txt + pip install --pre -U furo + pip install sphinx-markdown-tables==0.0.17 + - name: Sphinx Build + run: | + cd docs + bash makedoc.sh + - name: Package build into artifact + run: | + mv ./docs/_build/dirhtml ./${{ matrix.version }} + zip -r /tmp/build.zip ./${{ matrix.version }}/* + - name: Upload built html + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.version }} + path: /tmp/build.zip + retention-days: 1 + + push-docs: + runs-on: ubuntu-latest + needs: build-doc + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + ref: ${{ inputs.pages_branch }} + - uses: actions/download-artifact@v3 + with: + path: /tmp/artifacts + - name: Clear old builds + run: | + cd docs + for i in $(ls /tmp/artifacts); do git rm -rf "$i" || true; done + - name: In with new builds + run: | + cd docs + for i in $(ls /tmp/artifacts); do unzip "/tmp/artifacts/$i/build.zip"; done + wget https://raw.githubusercontent.com/${{ inputs.repo_owner }}/${{ inputs.package }}/main/docs/_versions.json + - name: Push it up! + run: | + git config --local user.email "${{ inputs.git_config_email }}" + git config --local user.name "${{ inputs.git_config_name }}" + git show --summary + git add . && git commit -m "chore(docs): update docs due to ${{github.event_name}} on ${{github.repository}}" + git push origin From 97455554768547e6863c0da5ce0091c170332e8e Mon Sep 17 00:00:00 2001 From: Jackmin801 Date: Sun, 23 Oct 2022 21:30:58 +0800 Subject: [PATCH 04/16] ci: version aware build workflow for latest docs --- .github/workflows/force-docs-build.yml | 94 +++++++++++++++----------- 1 file changed, 56 insertions(+), 38 deletions(-) diff --git a/.github/workflows/force-docs-build.yml b/.github/workflows/force-docs-build.yml index 48f86048faa..099fb207a00 100644 --- a/.github/workflows/force-docs-build.yml +++ b/.github/workflows/force-docs-build.yml @@ -10,6 +10,24 @@ on: description: 'CD | TAG | MANUAL' required: false default: MANUAL + package: + description: The name of the repo to build documentation for. + type: string + default: docarray + repo_owner: + description: The owner of the repo to build documentation for. Defaults to 'jina-ai'. + type: string + default: jina-ai + pages_branch: + description: Branch that Github Pages observes + type: string + default: gh-pages + git_config_name: + type: string + default: Jina Dev Bot + git_config_email: + type: string + default: dev-bot@jina.ai jobs: token-check: @@ -20,52 +38,52 @@ jobs: env: release_token: ${{ secrets.DOCARRAY_RELEASE_TOKEN }} - release-docs: + build-and-push-latest-docs: needs: token-check runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.5.0 + - uses: actions/checkout@v3 with: - fetch-depth: 0 + fetch-depth: 1 - uses: actions/setup-python@v4 with: - python-version: 3.7 - - name: Build doc and push to gh-pages + python-version: '3.10' + - name: Install Dependencies run: | - git config --local user.email "dev-bot@jina.ai" - git config --local user.name "Jina Dev Bot" - python -m pip install --upgrade pip - python -m pip install wheel - # pip does not properly resolve dependency versions with syntax pip install --no-cache-dir ".[test,full]" - pip install --no-cache-dir ".[test]" - pip install --no-cache-dir ".[full]" - pip install --no-cache-dir ".[qdrant]" - pip install --no-cache-dir ".[annlite]" - pip install --no-cache-dir ".[weaviate]" - pip install --no-cache-dir ".[elasticsearch]" - pip install --no-cache-dir ".[redis]" - mkdir gen-html + pip install .[devel] cd docs pip install -r requirements.txt pip install --pre -U furo + pip install sphinx-markdown-tables==0.0.17 + - name: Sphinx Build + run: | + cd docs bash makedoc.sh - cd ./_build/dirhtml/ - cp -r ./ ../../../gen-html - cd - # back to ./docs - cd .. - git checkout -f gh-pages - git rm -rf ./docs - mkdir -p docs - cd gen-html - cp -r ./ ../docs - cd ../docs - ls -la - touch .nojekyll - cp 404/index.html 404.html - sed -i 's/href="\.\./href="/' 404.html # fix asset urls that needs to be updated in 404.html - echo docarray.jina.ai > CNAME - cd .. - git add docs - git status - git commit -m "chore(docs): update docs due to ${{github.event_name}} on ${{github.repository}}" - git push --force origin gh-pages + mv ./_build/dirhtml /tmp/gen-html + - name: Checkout to GH pages branch (${{ inputs.pages_branch }}) + run: | + git fetch origin ${{ inputs.pages_branch }}:${{ inputs.pages_branch }} --depth 1 + git checkout -f ${{ inputs.pages_branch }} + git reset --hard HEAD + - name: Small config stuff + run: | + touch /tmp/gen-html/.nojekyll + cp ./docs/CNAME /tmp/gen-html/CNAME + cp ./docs/_versions.json /tmp/gen-html/_versions.json + cp /tmp/gen-html/404/index.html /tmp/gen-html/404.html + sed -i 's/href="\.\./href="/' /tmp/gen-html/404.html # fix asset urls that needs to be updated in 404.html + - name: Moving old doc versions + run: | + cd docs + for i in $(cat _versions.json | jq '.[].version' | tr -d '"'); do mv "$i" /tmp/gen-html; done + - name: Swap in new docs + run: | + rm -rf ./docs + mv /tmp/gen-html ./docs + - name: Push it up! + run: | + git config --local user.email "${{ inputs.git_config_email }}" + git config --local user.name "${{ inputs.git_config_name }}" + git show --summary + git add ./docs && git commit -m "chore(docs): update docs due to ${{github.event_name}} on ${{github.repository}}" + git push origin ${{ inputs.pages_branch }} From df156a7c75ac0647628f4e602a9133fa742ea13d Mon Sep 17 00:00:00 2001 From: Jackmin801 Date: Mon, 24 Oct 2022 00:31:17 +0800 Subject: [PATCH 05/16] style: blacken doc scripts --- docs/conf.py | 219 ++++++++++++++++++++++++++------------------------- docs/y2j.py | 6 +- 2 files changed, 116 insertions(+), 109 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index b1add3cb35c..39c79d98dde 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -3,56 +3,56 @@ import sys from os import path -sys.path.insert(0, path.abspath('..')) - -project = 'DocArray' -slug = re.sub(r'\W+', '-', project.lower()) -author = 'Jina AI' -copyright = 'Jina AI Limited. All rights reserved.' -source_suffix = ['.rst', '.md'] -master_doc = 'index' -language = 'en' -repo_dir = '../' +sys.path.insert(0, path.abspath("..")) + +project = "DocArray" +slug = re.sub(r"\W+", "-", project.lower()) +author = "Jina AI" +copyright = "Jina AI Limited. All rights reserved." +source_suffix = [".rst", ".md"] +master_doc = "index" +language = "en" +repo_dir = "../" autodoc_default_options = {"members": True, "inherited-members": True} try: - if 'DOCARRAY_VERSION' not in os.environ: - pkg_name = 'docarray' - libinfo_py = path.join(repo_dir, pkg_name, '__init__.py') - libinfo_content = open(libinfo_py, 'r').readlines() + if "DOCARRAY_VERSION" not in os.environ: + pkg_name = "docarray" + libinfo_py = path.join(repo_dir, pkg_name, "__init__.py") + libinfo_content = open(libinfo_py, "r").readlines() version_line = [ - l.strip() for l in libinfo_content if l.startswith('__version__') + l.strip() for l in libinfo_content if l.startswith("__version__") ][0] exec(version_line) else: - __version__ = os.environ['DOCARRAY_VERSION'] + __version__ = os.environ["DOCARRAY_VERSION"] except FileNotFoundError: - __version__ = '0.0.0' + __version__ = "0.0.0" version = __version__ release = __version__ -templates_path = ['_templates'] +templates_path = ["_templates"] exclude_patterns = [ - '_build', - 'Thumbs.db', - '.DS_Store', - 'tests', - 'page_templates', - '.github', + "_build", + "Thumbs.db", + ".DS_Store", + "tests", + "page_templates", + ".github", ] -pygments_style = 'rainbow_dash' -html_theme = 'furo' +pygments_style = "rainbow_dash" +html_theme = "furo" -base_url = '/' -html_baseurl = 'https://docarray.jina.ai' -sitemap_url_scheme = '{link}' +base_url = "/" +html_baseurl = "https://docarray.jina.ai" +sitemap_url_scheme = "{link}" sitemap_locales = [None] sitemap_filename = "sitemap.xml" html_theme_options = { - 'light_logo': 'logo-light.svg', - 'dark_logo': 'logo-dark.svg', + "light_logo": "logo-light.svg", + "dark_logo": "logo-dark.svg", "sidebar_hide_name": True, "light_css_variables": { "color-brand-primary": "#009191", @@ -62,111 +62,110 @@ "color-brand-primary": "#FBCB67", "color-brand-content": "#FBCB67", }, - # PLEASE DO NOT DELETE the empty line between `start-announce` and `end-announce` # PLEASE DO NOT DELETE `start-announce`/ `end-announce` it is used for our dev bot to inject announcement from GH - # start-announce - # end-announce } -html_static_path = ['_static'] -html_extra_path = ['html_extra'] +html_static_path = ["_static"] +html_extra_path = ["html_extra"] html_css_files = [ - 'main.css', - 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta2/css/all.min.css', + "main.css", + "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta2/css/all.min.css", ] html_js_files = [ - 'https://cdn.jsdelivr.net/npm/vue@2/dist/vue.min.js', - 'https://cdn.jsdelivr.net/npm/qabot@0.4' - ] + "https://cdn.jsdelivr.net/npm/vue@2/dist/vue.min.js", + "https://cdn.jsdelivr.net/npm/qabot@0.4", +] htmlhelp_basename = slug html_show_sourcelink = False -html_favicon = '_static/favicon.png' +html_favicon = "_static/favicon.png" -latex_documents = [(master_doc, f'{slug}.tex', project, author, 'manual')] +latex_documents = [(master_doc, f"{slug}.tex", project, author, "manual")] man_pages = [(master_doc, slug, project, [author], 1)] texinfo_documents = [ - (master_doc, slug, project, author, slug, project, 'Miscellaneous') + (master_doc, slug, project, author, slug, project, "Miscellaneous") ] epub_title = project -epub_exclude_files = ['search.html'] +epub_exclude_files = ["search.html"] # -- Extension configuration ------------------------------------------------- extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.autosummary', - 'sphinx_autodoc_typehints', - 'sphinx.ext.viewcode', - 'sphinx.ext.coverage', - 'sphinxcontrib.apidoc', - 'sphinxarg.ext', - 'sphinx_copybutton', - 'sphinx_sitemap', - 'sphinx.ext.intersphinx', - 'sphinxext.opengraph', - 'notfound.extension', - 'myst_parser', - 'sphinx_design', - 'sphinx_inline_tabs', + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx_autodoc_typehints", + "sphinx.ext.viewcode", + "sphinx.ext.coverage", + "sphinxcontrib.apidoc", + "sphinxarg.ext", + "sphinx_copybutton", + "sphinx_sitemap", + "sphinx.ext.intersphinx", + "sphinxext.opengraph", + "notfound.extension", + "myst_parser", + "sphinx_design", + "sphinx_inline_tabs", ] -myst_enable_extensions = ['colon_fence', 'substitution'] +myst_enable_extensions = ["colon_fence", "substitution"] # -- Custom 404 page # sphinx-notfound-page # https://github.com/readthedocs/sphinx-notfound-page notfound_context = { - 'title': 'Page Not Found', - 'body': ''' + "title": "Page Not Found", + "body": """

Page Not Found

Oops, we couldn't find that page.

You can try "asking our docs" on the right corner of the page to find answer.

Otherwise, please create a Github issue and one of our team will respond.

-''', +""", } notfound_no_urls_prefix = True apidoc_module_dir = repo_dir -apidoc_output_dir = 'api' -apidoc_excluded_paths = ['tests', 'legacy', 'hub', 'toy*', 'setup.py'] +apidoc_output_dir = "api" +apidoc_excluded_paths = ["tests", "legacy", "hub", "toy*", "setup.py"] apidoc_separate_modules = True -apidoc_extra_args = ['-t', 'template/'] -autodoc_member_order = 'bysource' -autodoc_mock_imports = ['argparse', 'numpy', 'np', 'tensorflow', 'torch', 'scipy'] -autoclass_content = 'both' +apidoc_extra_args = ["-t", "template/"] +autodoc_member_order = "bysource" +autodoc_mock_imports = ["argparse", "numpy", "np", "tensorflow", "torch", "scipy"] +autoclass_content = "both" set_type_checking_flag = False -html_last_updated_fmt = '' +html_last_updated_fmt = "" nitpicky = True -nitpick_ignore = [('py:class', 'type')] +nitpick_ignore = [("py:class", "type")] linkcheck_ignore = [ # Avoid link check on local uri - 'http://0.0.0.0:*', - 'pods/encode.yml', - 'https://github.com/jina-ai/docarray/commit/*', - '.github/*', - 'extra-requirements.txt', - 'fastentrypoints.py' '../../101', - '../../102', - 'http://www.twinsun.com/tz/tz-link.htm', # Broken link from pytz library - 'https://urllib3.readthedocs.io/en/latest/contrib.html#google-app-engine', # Broken link from urllib3 library - 'https://linuxize.com/post/how-to-add-swap-space-on-ubuntu-20-04/', + "http://0.0.0.0:*", + "pods/encode.yml", + "https://github.com/jina-ai/docarray/commit/*", + ".github/*", + "extra-requirements.txt", + "fastentrypoints.py" "../../101", + "../../102", + "http://www.twinsun.com/tz/tz-link.htm", # Broken link from pytz library + "https://urllib3.readthedocs.io/en/latest/contrib.html#google-app-engine", # Broken link from urllib3 library + "https://linuxize.com/post/how-to-add-swap-space-on-ubuntu-20-04/", # This link works but gets 403 error on linkcheck ] linkcheck_timeout = 20 linkcheck_retries = 2 linkcheck_anchors = False -ogp_site_url = 'https://docarray.jina.ai/' -ogp_image = 'https://docarray.jina.ai/_static/banner.png' +ogp_site_url = "https://docarray.jina.ai/" +ogp_image = "https://docarray.jina.ai/_static/banner.png" ogp_use_first_image = True ogp_description_length = 300 -ogp_type = 'website' -ogp_site_name = f'DocArray {os.environ.get("SPHINX_MULTIVERSION_VERSION", version)} Documentation' +ogp_type = "website" +ogp_site_name = ( + f'DocArray {os.environ.get("SPHINX_MULTIVERSION_VERSION", version)} Documentation' +) ogp_custom_meta_tags = [ '', @@ -174,7 +173,7 @@ '', '', '', - ''' + """ - ''', + """, ] def add_server_address(app): # This makes variable `server_address` available to docbot.js - server_address = app.config['server_address'] + server_address = app.config["server_address"] js_text = "var server_address = '%s';" % server_address app.add_js_file(None, body=js_text) + def configure_qa_bot_ui(app): # This sets the server address to - server_address = app.config['server_address'] - js_text = """ + server_address = app.config["server_address"] + js_text = ( + """ document.addEventListener('DOMContentLoaded', function() { document.querySelector('qa-bot').setAttribute('server', '%s'); }); - """ % server_address + """ + % server_address + ) app.add_js_file(None, body=js_text) @@ -213,29 +216,31 @@ def setup(app): from sphinx.locale import _ app.add_object_type( - 'confval', - 'confval', - objname='configuration value', - indextemplate='pair: %s; configuration value', + "confval", + "confval", + objname="configuration value", + indextemplate="pair: %s; configuration value", doc_field_types=[ PyField( - 'type', - label=_('Type'), + "type", + label=_("Type"), has_arg=False, - names=('type',), - bodyrolename='class', + names=("type",), + bodyrolename="class", ), Field( - 'default', - label=_('Default'), + "default", + label=_("Default"), has_arg=False, - names=('default',), + names=("default",), ), ], ) app.add_config_value( - name='server_address', - default=os.getenv('JINA_DOCSBOT_SERVER', 'https://jina-ai-docarray.docsqa.jina.ai'), - rebuild='', + name="server_address", + default=os.getenv( + "JINA_DOCSBOT_SERVER", "https://jina-ai-docarray.docsqa.jina.ai" + ), + rebuild="", ) - app.connect('builder-inited', configure_qa_bot_ui) \ No newline at end of file + app.connect("builder-inited", configure_qa_bot_ui) diff --git a/docs/y2j.py b/docs/y2j.py index e5227f04a4e..bd0ad092ca7 100644 --- a/docs/y2j.py +++ b/docs/y2j.py @@ -1,5 +1,7 @@ import yaml import json -with open('_versions.yml') as versions_yml, open('_versions.json', 'w') as versions_json: - json.dump(yaml.safe_load(versions_yml), versions_json) \ No newline at end of file +with open("_versions.yml") as versions_yml, open( + "_versions.json", "w" +) as versions_json: + json.dump(yaml.safe_load(versions_yml), versions_json) From 8d825d1a3e3a39045208cbfa18e5552dc4c888f6 Mon Sep 17 00:00:00 2001 From: Jackmin801 Date: Mon, 24 Oct 2022 19:17:16 +0800 Subject: [PATCH 06/16] ci: revert python version to 3.7 in docs workflows --- .github/workflows/build-old-docs.yml | 2 +- .github/workflows/force-docs-build.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-old-docs.yml b/.github/workflows/build-old-docs.yml index 86f01db7724..e70be62166d 100644 --- a/.github/workflows/build-old-docs.yml +++ b/.github/workflows/build-old-docs.yml @@ -58,7 +58,7 @@ jobs: ref: ${{ matrix.version }} - uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.7' - name: Get latest templates run: | git show --summary diff --git a/.github/workflows/force-docs-build.yml b/.github/workflows/force-docs-build.yml index 099fb207a00..82970b5f62e 100644 --- a/.github/workflows/force-docs-build.yml +++ b/.github/workflows/force-docs-build.yml @@ -47,7 +47,7 @@ jobs: fetch-depth: 1 - uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.7' - name: Install Dependencies run: | pip install .[devel] From 25c75efd4c06067f34dbf2db793aa567fc0ee6ff Mon Sep 17 00:00:00 2001 From: Jackmin801 Date: Mon, 24 Oct 2022 19:23:11 +0800 Subject: [PATCH 07/16] ci: revert installs to previous method --- .github/workflows/build-old-docs.yml | 11 ++++++++++- .github/workflows/force-docs-build.yml | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-old-docs.yml b/.github/workflows/build-old-docs.yml index e70be62166d..8856b7353bf 100644 --- a/.github/workflows/build-old-docs.yml +++ b/.github/workflows/build-old-docs.yml @@ -67,7 +67,16 @@ jobs: mv ./brand.html ./docs/_templates/sidebar/brand.html - name: Install dependencies run: | - pip install .[devel] + python -m pip install --upgrade pip + python -m pip install wheel + # pip does not properly resolve dependency versions with syntax pip install --no-cache-dir ".[test,full]" + pip install --no-cache-dir ".[test]" + pip install --no-cache-dir ".[full]" + pip install --no-cache-dir ".[qdrant]" + pip install --no-cache-dir ".[annlite]" + pip install --no-cache-dir ".[weaviate]" + pip install --no-cache-dir ".[elasticsearch]" + pip install --no-cache-dir ".[redis]" cd docs pip install -r requirements.txt pip install --pre -U furo diff --git a/.github/workflows/force-docs-build.yml b/.github/workflows/force-docs-build.yml index 82970b5f62e..22fe3f0c020 100644 --- a/.github/workflows/force-docs-build.yml +++ b/.github/workflows/force-docs-build.yml @@ -50,7 +50,16 @@ jobs: python-version: '3.7' - name: Install Dependencies run: | - pip install .[devel] + python -m pip install --upgrade pip + python -m pip install wheel + # pip does not properly resolve dependency versions with syntax pip install --no-cache-dir ".[test,full]" + pip install --no-cache-dir ".[test]" + pip install --no-cache-dir ".[full]" + pip install --no-cache-dir ".[qdrant]" + pip install --no-cache-dir ".[annlite]" + pip install --no-cache-dir ".[weaviate]" + pip install --no-cache-dir ".[elasticsearch]" + pip install --no-cache-dir ".[redis]" cd docs pip install -r requirements.txt pip install --pre -U furo From 940e42c7347f33e36c05069dfee3c674398cf00a Mon Sep 17 00:00:00 2001 From: Jackmin801 Date: Mon, 24 Oct 2022 23:25:44 +0800 Subject: [PATCH 08/16] ci: fix typos --- .github/workflows/build-old-docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-old-docs.yml b/.github/workflows/build-old-docs.yml index 8856b7353bf..5547afe0401 100644 --- a/.github/workflows/build-old-docs.yml +++ b/.github/workflows/build-old-docs.yml @@ -36,7 +36,7 @@ jobs: - run: echo "Success!" if: "${{ github.event.inputs.release_token }} == ${{ env.release_token }}" env: - release_token: ${{ secrets.JINA_DEV_RELEASE_TOKEN }} + release_token: ${{ secrets.DOCARRAY_RELEASE_TOKEN }} - id: get_versions run: | printf "versions=" >> $GITHUB_OUTPUT @@ -121,5 +121,5 @@ jobs: git config --local user.email "${{ inputs.git_config_email }}" git config --local user.name "${{ inputs.git_config_name }}" git show --summary - git add . && git commit -m "chore(docs): update docs due to ${{github.event_name}} on ${{github.repository}}" + git add . && git commit -m "chore(docs): update old docs due to ${{github.event_name}} on ${{github.repository}}" git push origin From 401ccf826f541be3117fd9fc3d621da31481dc2f Mon Sep 17 00:00:00 2001 From: Jackmin801 Date: Mon, 24 Oct 2022 23:29:25 +0800 Subject: [PATCH 09/16] ci: update _versions.json when manual release --- .github/workflows/force-release.yml | 2 +- scripts/release.sh | 10 ++++++++++ docs/y2j.py => scripts/versions_yaml_2_json.py | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) rename docs/y2j.py => scripts/versions_yaml_2_json.py (53%) diff --git a/.github/workflows/force-release.yml b/.github/workflows/force-release.yml index 3951a4cd757..89b9ad85d67 100644 --- a/.github/workflows/force-release.yml +++ b/.github/workflows/force-release.yml @@ -34,7 +34,7 @@ jobs: - run: | git fetch --depth=1 origin +refs/tags/*:refs/tags/* npm install git-release-notes - pip install twine wheel + pip install twine wheel pyyaml ./scripts/release.sh final "${{ github.event.inputs.release_reason }}" "${{github.actor}}" env: TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} diff --git a/scripts/release.sh b/scripts/release.sh index 0a00cb7bda8..069335c5471 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -72,6 +72,16 @@ export RELEASE_VER=$(sed -n '/^__version__/p' $INIT_FILE | cut -d \' -f2) LAST_VER=$(git tag -l | sort -V | tail -n1) printf "last version: \e[1;32m$LAST_VER\e[0m\n" +# Update new _versions.yml and _versions.json if necessary +if [[ ! $(head -n1 ./docs/_versions.yml) == "- version: v$RELEASE_VER" ]]; then + printf -- "- version: v$RELEASE_VER\n" > ./docs/new_versions.yml + cat ./docs/_versions.yml >> ./docs/new_versions.yml + mv ./docs/new_versions.yml ./docs/_versions.yml + python ./scripts/versions_yaml_2_json.py + git add ./docs/_versions.yml + git add ./docs/_versions.json +fi + if [[ $1 == "final" ]]; then printf "this will be a final release: \e[1;33m$RELEASE_VER\e[0m\n" diff --git a/docs/y2j.py b/scripts/versions_yaml_2_json.py similarity index 53% rename from docs/y2j.py rename to scripts/versions_yaml_2_json.py index bd0ad092ca7..47aea776f74 100644 --- a/docs/y2j.py +++ b/scripts/versions_yaml_2_json.py @@ -1,7 +1,7 @@ import yaml import json -with open("_versions.yml") as versions_yml, open( - "_versions.json", "w" +with open("./docs/_versions.yml") as versions_yml, open( + "./docs/_versions.json", "w" ) as versions_json: json.dump(yaml.safe_load(versions_yml), versions_json) From 5204640814b54b748b5fb64ef32f302a49faad86 Mon Sep 17 00:00:00 2001 From: Jackmin801 Date: Mon, 24 Oct 2022 23:36:55 +0800 Subject: [PATCH 10/16] ci: add build_old_docs flag to manual docs build --- .github/workflows/force-docs-build.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/force-docs-build.yml b/.github/workflows/force-docs-build.yml index 22fe3f0c020..8f03707cead 100644 --- a/.github/workflows/force-docs-build.yml +++ b/.github/workflows/force-docs-build.yml @@ -10,6 +10,10 @@ on: description: 'CD | TAG | MANUAL' required: false default: MANUAL + build_old_docs: + description: 'TRUE | FALSE' + type: string + default: 'FALSE' package: description: The name of the repo to build documentation for. type: string @@ -96,3 +100,16 @@ jobs: git show --summary git add ./docs && git commit -m "chore(docs): update docs due to ${{github.event_name}} on ${{github.repository}}" git push origin ${{ inputs.pages_branch }} + + build-old-docs: + needs: build-and-push-latest-docs + runs-on: ubuntu-latest + if: inputs.build_old_docs == 'TRUE' + steps: + - uses: benc-uk/workflow-dispatch@v1 + with: + workflow: Build old docs + token: ${{ secrets.JINA_DEV_BOT }} + inputs: '{ "release_token": "${{ env.release_token }}", "triggered_by": "TAG"}' + env: + release_token: ${{ secrets.DOCARRAY_RELEASE_TOKEN }} From be5cf767d8fa17941d117a0c12404ab7c4aad002 Mon Sep 17 00:00:00 2001 From: Jackmin801 Date: Tue, 25 Oct 2022 00:20:54 +0800 Subject: [PATCH 11/16] ci: add better description for old docs flag --- .github/workflows/force-docs-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/force-docs-build.yml b/.github/workflows/force-docs-build.yml index 8f03707cead..c95e1cde1ce 100644 --- a/.github/workflows/force-docs-build.yml +++ b/.github/workflows/force-docs-build.yml @@ -11,7 +11,7 @@ on: required: false default: MANUAL build_old_docs: - description: 'TRUE | FALSE' + description: 'Whether to build old docs (TRUE | FALSE)' type: string default: 'FALSE' package: From 7af58e4ddb572b0d72cc36d6d21fc644369a6fcc Mon Sep 17 00:00:00 2001 From: Jackmin801 Date: Tue, 25 Oct 2022 00:23:03 +0800 Subject: [PATCH 12/16] ci: release CD builds old docs after a latest --- .github/workflows/tag.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index d6a270e6463..cd658781be6 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -18,7 +18,7 @@ jobs: with: workflow: Manual Docs Build token: ${{ secrets.JINA_DEV_BOT }} - inputs: '{ "release_token": "${{ env.release_token }}", "triggered_by": "TAG"}' + inputs: '{ "release_token": "${{ env.release_token }}", "triggered_by": "TAG", "build_old_docs": "TRUE"}' env: release_token: ${{ secrets.DOCARRAY_RELEASE_TOKEN }} From 207f38b7339e7e090b1b8a66001d220e501e1270 Mon Sep 17 00:00:00 2001 From: Jackmin801 Date: Tue, 25 Oct 2022 02:26:20 +0800 Subject: [PATCH 13/16] ci: remove old _versions.json correctly --- .github/workflows/build-old-docs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-old-docs.yml b/.github/workflows/build-old-docs.yml index 5547afe0401..8b7d36fef6e 100644 --- a/.github/workflows/build-old-docs.yml +++ b/.github/workflows/build-old-docs.yml @@ -115,6 +115,7 @@ jobs: run: | cd docs for i in $(ls /tmp/artifacts); do unzip "/tmp/artifacts/$i/build.zip"; done + rm _versions.json wget https://raw.githubusercontent.com/${{ inputs.repo_owner }}/${{ inputs.package }}/main/docs/_versions.json - name: Push it up! run: | From a8649fed4ddf2504e477e1f9943b9d03c6f2e7b7 Mon Sep 17 00:00:00 2001 From: Jackmin801 Date: Tue, 25 Oct 2022 15:02:16 +0800 Subject: [PATCH 14/16] ci: revert blacken in docs/conf.py --- docs/conf.py | 219 +++++++++++++++++++++++++-------------------------- 1 file changed, 107 insertions(+), 112 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 39c79d98dde..b1add3cb35c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -3,56 +3,56 @@ import sys from os import path -sys.path.insert(0, path.abspath("..")) - -project = "DocArray" -slug = re.sub(r"\W+", "-", project.lower()) -author = "Jina AI" -copyright = "Jina AI Limited. All rights reserved." -source_suffix = [".rst", ".md"] -master_doc = "index" -language = "en" -repo_dir = "../" +sys.path.insert(0, path.abspath('..')) + +project = 'DocArray' +slug = re.sub(r'\W+', '-', project.lower()) +author = 'Jina AI' +copyright = 'Jina AI Limited. All rights reserved.' +source_suffix = ['.rst', '.md'] +master_doc = 'index' +language = 'en' +repo_dir = '../' autodoc_default_options = {"members": True, "inherited-members": True} try: - if "DOCARRAY_VERSION" not in os.environ: - pkg_name = "docarray" - libinfo_py = path.join(repo_dir, pkg_name, "__init__.py") - libinfo_content = open(libinfo_py, "r").readlines() + if 'DOCARRAY_VERSION' not in os.environ: + pkg_name = 'docarray' + libinfo_py = path.join(repo_dir, pkg_name, '__init__.py') + libinfo_content = open(libinfo_py, 'r').readlines() version_line = [ - l.strip() for l in libinfo_content if l.startswith("__version__") + l.strip() for l in libinfo_content if l.startswith('__version__') ][0] exec(version_line) else: - __version__ = os.environ["DOCARRAY_VERSION"] + __version__ = os.environ['DOCARRAY_VERSION'] except FileNotFoundError: - __version__ = "0.0.0" + __version__ = '0.0.0' version = __version__ release = __version__ -templates_path = ["_templates"] +templates_path = ['_templates'] exclude_patterns = [ - "_build", - "Thumbs.db", - ".DS_Store", - "tests", - "page_templates", - ".github", + '_build', + 'Thumbs.db', + '.DS_Store', + 'tests', + 'page_templates', + '.github', ] -pygments_style = "rainbow_dash" -html_theme = "furo" +pygments_style = 'rainbow_dash' +html_theme = 'furo' -base_url = "/" -html_baseurl = "https://docarray.jina.ai" -sitemap_url_scheme = "{link}" +base_url = '/' +html_baseurl = 'https://docarray.jina.ai' +sitemap_url_scheme = '{link}' sitemap_locales = [None] sitemap_filename = "sitemap.xml" html_theme_options = { - "light_logo": "logo-light.svg", - "dark_logo": "logo-dark.svg", + 'light_logo': 'logo-light.svg', + 'dark_logo': 'logo-dark.svg', "sidebar_hide_name": True, "light_css_variables": { "color-brand-primary": "#009191", @@ -62,110 +62,111 @@ "color-brand-primary": "#FBCB67", "color-brand-content": "#FBCB67", }, + # PLEASE DO NOT DELETE the empty line between `start-announce` and `end-announce` # PLEASE DO NOT DELETE `start-announce`/ `end-announce` it is used for our dev bot to inject announcement from GH + # start-announce + # end-announce } -html_static_path = ["_static"] -html_extra_path = ["html_extra"] +html_static_path = ['_static'] +html_extra_path = ['html_extra'] html_css_files = [ - "main.css", - "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta2/css/all.min.css", + 'main.css', + 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta2/css/all.min.css', ] html_js_files = [ - "https://cdn.jsdelivr.net/npm/vue@2/dist/vue.min.js", - "https://cdn.jsdelivr.net/npm/qabot@0.4", -] + 'https://cdn.jsdelivr.net/npm/vue@2/dist/vue.min.js', + 'https://cdn.jsdelivr.net/npm/qabot@0.4' + ] htmlhelp_basename = slug html_show_sourcelink = False -html_favicon = "_static/favicon.png" +html_favicon = '_static/favicon.png' -latex_documents = [(master_doc, f"{slug}.tex", project, author, "manual")] +latex_documents = [(master_doc, f'{slug}.tex', project, author, 'manual')] man_pages = [(master_doc, slug, project, [author], 1)] texinfo_documents = [ - (master_doc, slug, project, author, slug, project, "Miscellaneous") + (master_doc, slug, project, author, slug, project, 'Miscellaneous') ] epub_title = project -epub_exclude_files = ["search.html"] +epub_exclude_files = ['search.html'] # -- Extension configuration ------------------------------------------------- extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.autosummary", - "sphinx_autodoc_typehints", - "sphinx.ext.viewcode", - "sphinx.ext.coverage", - "sphinxcontrib.apidoc", - "sphinxarg.ext", - "sphinx_copybutton", - "sphinx_sitemap", - "sphinx.ext.intersphinx", - "sphinxext.opengraph", - "notfound.extension", - "myst_parser", - "sphinx_design", - "sphinx_inline_tabs", + 'sphinx.ext.autodoc', + 'sphinx.ext.autosummary', + 'sphinx_autodoc_typehints', + 'sphinx.ext.viewcode', + 'sphinx.ext.coverage', + 'sphinxcontrib.apidoc', + 'sphinxarg.ext', + 'sphinx_copybutton', + 'sphinx_sitemap', + 'sphinx.ext.intersphinx', + 'sphinxext.opengraph', + 'notfound.extension', + 'myst_parser', + 'sphinx_design', + 'sphinx_inline_tabs', ] -myst_enable_extensions = ["colon_fence", "substitution"] +myst_enable_extensions = ['colon_fence', 'substitution'] # -- Custom 404 page # sphinx-notfound-page # https://github.com/readthedocs/sphinx-notfound-page notfound_context = { - "title": "Page Not Found", - "body": """ + 'title': 'Page Not Found', + 'body': '''

Page Not Found

Oops, we couldn't find that page.

You can try "asking our docs" on the right corner of the page to find answer.

Otherwise, please create a Github issue and one of our team will respond.

-""", +''', } notfound_no_urls_prefix = True apidoc_module_dir = repo_dir -apidoc_output_dir = "api" -apidoc_excluded_paths = ["tests", "legacy", "hub", "toy*", "setup.py"] +apidoc_output_dir = 'api' +apidoc_excluded_paths = ['tests', 'legacy', 'hub', 'toy*', 'setup.py'] apidoc_separate_modules = True -apidoc_extra_args = ["-t", "template/"] -autodoc_member_order = "bysource" -autodoc_mock_imports = ["argparse", "numpy", "np", "tensorflow", "torch", "scipy"] -autoclass_content = "both" +apidoc_extra_args = ['-t', 'template/'] +autodoc_member_order = 'bysource' +autodoc_mock_imports = ['argparse', 'numpy', 'np', 'tensorflow', 'torch', 'scipy'] +autoclass_content = 'both' set_type_checking_flag = False -html_last_updated_fmt = "" +html_last_updated_fmt = '' nitpicky = True -nitpick_ignore = [("py:class", "type")] +nitpick_ignore = [('py:class', 'type')] linkcheck_ignore = [ # Avoid link check on local uri - "http://0.0.0.0:*", - "pods/encode.yml", - "https://github.com/jina-ai/docarray/commit/*", - ".github/*", - "extra-requirements.txt", - "fastentrypoints.py" "../../101", - "../../102", - "http://www.twinsun.com/tz/tz-link.htm", # Broken link from pytz library - "https://urllib3.readthedocs.io/en/latest/contrib.html#google-app-engine", # Broken link from urllib3 library - "https://linuxize.com/post/how-to-add-swap-space-on-ubuntu-20-04/", + 'http://0.0.0.0:*', + 'pods/encode.yml', + 'https://github.com/jina-ai/docarray/commit/*', + '.github/*', + 'extra-requirements.txt', + 'fastentrypoints.py' '../../101', + '../../102', + 'http://www.twinsun.com/tz/tz-link.htm', # Broken link from pytz library + 'https://urllib3.readthedocs.io/en/latest/contrib.html#google-app-engine', # Broken link from urllib3 library + 'https://linuxize.com/post/how-to-add-swap-space-on-ubuntu-20-04/', # This link works but gets 403 error on linkcheck ] linkcheck_timeout = 20 linkcheck_retries = 2 linkcheck_anchors = False -ogp_site_url = "https://docarray.jina.ai/" -ogp_image = "https://docarray.jina.ai/_static/banner.png" +ogp_site_url = 'https://docarray.jina.ai/' +ogp_image = 'https://docarray.jina.ai/_static/banner.png' ogp_use_first_image = True ogp_description_length = 300 -ogp_type = "website" -ogp_site_name = ( - f'DocArray {os.environ.get("SPHINX_MULTIVERSION_VERSION", version)} Documentation' -) +ogp_type = 'website' +ogp_site_name = f'DocArray {os.environ.get("SPHINX_MULTIVERSION_VERSION", version)} Documentation' ogp_custom_meta_tags = [ '', @@ -173,7 +174,7 @@ '', '', '', - """ + ''' - """, + ''', ] def add_server_address(app): # This makes variable `server_address` available to docbot.js - server_address = app.config["server_address"] + server_address = app.config['server_address'] js_text = "var server_address = '%s';" % server_address app.add_js_file(None, body=js_text) - def configure_qa_bot_ui(app): # This sets the server address to - server_address = app.config["server_address"] - js_text = ( - """ + server_address = app.config['server_address'] + js_text = """ document.addEventListener('DOMContentLoaded', function() { document.querySelector('qa-bot').setAttribute('server', '%s'); }); - """ - % server_address - ) + """ % server_address app.add_js_file(None, body=js_text) @@ -216,31 +213,29 @@ def setup(app): from sphinx.locale import _ app.add_object_type( - "confval", - "confval", - objname="configuration value", - indextemplate="pair: %s; configuration value", + 'confval', + 'confval', + objname='configuration value', + indextemplate='pair: %s; configuration value', doc_field_types=[ PyField( - "type", - label=_("Type"), + 'type', + label=_('Type'), has_arg=False, - names=("type",), - bodyrolename="class", + names=('type',), + bodyrolename='class', ), Field( - "default", - label=_("Default"), + 'default', + label=_('Default'), has_arg=False, - names=("default",), + names=('default',), ), ], ) app.add_config_value( - name="server_address", - default=os.getenv( - "JINA_DOCSBOT_SERVER", "https://jina-ai-docarray.docsqa.jina.ai" - ), - rebuild="", + name='server_address', + default=os.getenv('JINA_DOCSBOT_SERVER', 'https://jina-ai-docarray.docsqa.jina.ai'), + rebuild='', ) - app.connect("builder-inited", configure_qa_bot_ui) + app.connect('builder-inited', configure_qa_bot_ui) \ No newline at end of file From 990b0ca5633c3c9cac5afd638980ea6905e8b2ce Mon Sep 17 00:00:00 2001 From: Jackmin801 Date: Tue, 25 Oct 2022 16:23:45 +0800 Subject: [PATCH 15/16] ci: consolidate doc version information to json --- .github/workflows/force-release.yml | 2 +- docs/_versions.yml | 34 ----------------------------- scripts/prepend_version_json.py | 21 ++++++++++++++++++ scripts/release.sh | 12 +++------- scripts/versions_yaml_2_json.py | 7 ------ 5 files changed, 25 insertions(+), 51 deletions(-) delete mode 100644 docs/_versions.yml create mode 100644 scripts/prepend_version_json.py delete mode 100644 scripts/versions_yaml_2_json.py diff --git a/.github/workflows/force-release.yml b/.github/workflows/force-release.yml index 89b9ad85d67..3951a4cd757 100644 --- a/.github/workflows/force-release.yml +++ b/.github/workflows/force-release.yml @@ -34,7 +34,7 @@ jobs: - run: | git fetch --depth=1 origin +refs/tags/*:refs/tags/* npm install git-release-notes - pip install twine wheel pyyaml + pip install twine wheel ./scripts/release.sh final "${{ github.event.inputs.release_reason }}" "${{github.actor}}" env: TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} diff --git a/docs/_versions.yml b/docs/_versions.yml deleted file mode 100644 index bcad5cf44e3..00000000000 --- a/docs/_versions.yml +++ /dev/null @@ -1,34 +0,0 @@ -- version: v0.18.0 -- version: v0.17.0 -- version: v0.16.5 -- version: v0.16.0 -- version: v0.15.4 -- version: v0.15.0 -- version: v0.14.11 -- version: v0.14.0 -- version: v0.13.33 -- version: v0.13.0 -- version: v0.12.9 -- version: v0.12.0 -- version: v0.11.3 -- version: v0.11.0 -- version: v0.10.5 -- version: v0.10.0 -- version: v0.9.18 -- version: v0.9.0 -- version: v0.8.11 -- version: v0.8.0 -- version: v0.7.3 -- version: v0.7.0 -- version: v0.6.3 -- version: v0.6.0 -- version: v0.5.3 -- version: v0.5.0 -- version: v0.4.3 -- version: v0.4.0 -- version: v0.3.3 -- version: v0.3.0 -- version: v0.2.0 -- version: v0.1.7 -- version: v0.1.1 -- version: v0.0.0 \ No newline at end of file diff --git a/scripts/prepend_version_json.py b/scripts/prepend_version_json.py new file mode 100644 index 00000000000..2036fbfa305 --- /dev/null +++ b/scripts/prepend_version_json.py @@ -0,0 +1,21 @@ +from typing import List +import argparse +import json + +parser = argparse.ArgumentParser(prog="Prepender docs/_versions.json") +parser.add_argument( + "--version", + type=str, + help="The version we wish to prepend (e.g. v0.18.0)", + required=True, +) +args = parser.parse_args() + +with open("./docs/_versions.json") as f: + versions: List[dict] = json.load(f) + element = {k: v for k, v in args._get_kwargs()} + if element != versions[0]: + versions.insert(0, element) + +with open("./docs/_versions.json", "w") as f: + json.dump(versions, f) diff --git a/scripts/release.sh b/scripts/release.sh index 069335c5471..bddea6b78f3 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -72,15 +72,9 @@ export RELEASE_VER=$(sed -n '/^__version__/p' $INIT_FILE | cut -d \' -f2) LAST_VER=$(git tag -l | sort -V | tail -n1) printf "last version: \e[1;32m$LAST_VER\e[0m\n" -# Update new _versions.yml and _versions.json if necessary -if [[ ! $(head -n1 ./docs/_versions.yml) == "- version: v$RELEASE_VER" ]]; then - printf -- "- version: v$RELEASE_VER\n" > ./docs/new_versions.yml - cat ./docs/_versions.yml >> ./docs/new_versions.yml - mv ./docs/new_versions.yml ./docs/_versions.yml - python ./scripts/versions_yaml_2_json.py - git add ./docs/_versions.yml - git add ./docs/_versions.json -fi +# Update new _versions.json if necessary +python ./scripts/prepend_version_json.py --version "v$RELEASE_VER" +git add ./docs/_versions.json if [[ $1 == "final" ]]; then printf "this will be a final release: \e[1;33m$RELEASE_VER\e[0m\n" diff --git a/scripts/versions_yaml_2_json.py b/scripts/versions_yaml_2_json.py deleted file mode 100644 index 47aea776f74..00000000000 --- a/scripts/versions_yaml_2_json.py +++ /dev/null @@ -1,7 +0,0 @@ -import yaml -import json - -with open("./docs/_versions.yml") as versions_yml, open( - "./docs/_versions.json", "w" -) as versions_json: - json.dump(yaml.safe_load(versions_yml), versions_json) From d695c90f95cd9039486936d08f8391154a98d6ee Mon Sep 17 00:00:00 2001 From: Jackmin801 Date: Tue, 25 Oct 2022 16:56:01 +0800 Subject: [PATCH 16/16] docs: add new release to _versions.json --- docs/_versions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_versions.json b/docs/_versions.json index 0c7e993aa06..88b3e650252 100644 --- a/docs/_versions.json +++ b/docs/_versions.json @@ -1 +1 @@ -[{"version": "v0.18.0"}, {"version": "v0.17.0"}, {"version": "v0.16.5"}, {"version": "v0.16.0"}, {"version": "v0.15.4"}, {"version": "v0.15.0"}, {"version": "v0.14.11"}, {"version": "v0.14.0"}, {"version": "v0.13.33"}, {"version": "v0.13.0"}, {"version": "v0.12.9"}, {"version": "v0.12.0"}, {"version": "v0.11.3"}, {"version": "v0.11.0"}, {"version": "v0.10.5"}, {"version": "v0.10.0"}, {"version": "v0.9.18"}, {"version": "v0.9.0"}, {"version": "v0.8.11"}, {"version": "v0.8.0"}, {"version": "v0.7.3"}, {"version": "v0.7.0"}, {"version": "v0.6.3"}, {"version": "v0.6.0"}, {"version": "v0.5.3"}, {"version": "v0.5.0"}, {"version": "v0.4.3"}, {"version": "v0.4.0"}, {"version": "v0.3.3"}, {"version": "v0.3.0"}, {"version": "v0.2.0"}, {"version": "v0.1.7"}, {"version": "v0.1.1"}, {"version": "v0.0.0"}] \ No newline at end of file +[{"version": "v0.18.1"}, {"version": "v0.18.0"}, {"version": "v0.17.0"}, {"version": "v0.16.5"}, {"version": "v0.16.0"}, {"version": "v0.15.4"}, {"version": "v0.15.0"}, {"version": "v0.14.11"}, {"version": "v0.14.0"}, {"version": "v0.13.33"}, {"version": "v0.13.0"}, {"version": "v0.12.9"}, {"version": "v0.12.0"}, {"version": "v0.11.3"}, {"version": "v0.11.0"}, {"version": "v0.10.5"}, {"version": "v0.10.0"}, {"version": "v0.9.18"}, {"version": "v0.9.0"}, {"version": "v0.8.11"}, {"version": "v0.8.0"}, {"version": "v0.7.3"}, {"version": "v0.7.0"}, {"version": "v0.6.3"}, {"version": "v0.6.0"}, {"version": "v0.5.3"}, {"version": "v0.5.0"}, {"version": "v0.4.3"}, {"version": "v0.4.0"}, {"version": "v0.3.3"}, {"version": "v0.3.0"}, {"version": "v0.2.0"}, {"version": "v0.1.7"}, {"version": "v0.1.1"}, {"version": "v0.0.0"}] \ No newline at end of file