mirror of
https://github.com/deepset-ai/haystack.git
synced 2026-01-01 09:37:36 +00:00
* Test readme_integration.yml * Test readme_integration.yml * Test variables * Test variables * Test variables * Test variables * Test commit * Test commit * Test commit * Trigger action * Add v * Trigger action * Trigger action * Trigger action * Trigger action * Update API docs headers * Revert "Update API docs headers" This reverts commit 34e665063f4de29854befe575a795dbfef04415c. * Trigger action * Trigger action * Trigger action * Update release * Update release * Update release * Delete File * Split steps into own files * Edit action names * Start making changes * Start implementing version bump * Implement minor version release * Fix github action * Test action * Test action * Test action * Test action * Test action * Change back to main * Add comments * Remove line * Format docstring * Incorporate reviewer feedback * Fix variable name * Print version.txt * Incorporate Reviewer feedback * Rename variables for clarity * Add fetch * Change branch * Change branch * Change branch * Change branch * Change branch * Revert docstring changes * Incorporate reviewer feedback * Run black Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
56 lines
1.9 KiB
Python
56 lines
1.9 KiB
Python
"""
|
|
Change the category id of the API pydoc configs so that they point to the correct category in Readme.
|
|
"""
|
|
|
|
import requests
|
|
import pprint
|
|
import base64
|
|
import argparse
|
|
import os
|
|
from pprint import pprint
|
|
|
|
PYDOC_CONFIGS_DIR = "./docs/_src/api/pydoc"
|
|
|
|
|
|
def get_category_id(version):
|
|
url = "https://dash.readme.com/api/v1/categories/haystack-classes"
|
|
headers = {"accept": "application/json", "x-readme-version": version, "authorization": api_key_b64}
|
|
ret = requests.get(url, headers=headers)
|
|
pprint(ret.text)
|
|
return ret.json()["id"]
|
|
|
|
|
|
def change_api_category_id(new_version, docs_dir):
|
|
print(new_version)
|
|
category_id = get_category_id(new_version)
|
|
print(category_id)
|
|
## Replace the category id in the yaml headers
|
|
for root, dirs, files in os.walk(docs_dir):
|
|
for file in files:
|
|
if file.endswith(".yml"):
|
|
file_path = os.path.join(root, file)
|
|
lines = [l for l in open(file_path, "r")]
|
|
for l in lines:
|
|
if "category: " in l:
|
|
lines[lines.index(l)] = " category: {}\n".format(category_id)
|
|
content = "".join(lines)
|
|
with open(file_path, "w") as f:
|
|
f.write(content)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument(
|
|
"-v", "--version", help="The new minor version that is being released (e.g. v1.9.1).", required=True
|
|
)
|
|
parser.add_argument("-k", "--key", help="The Readme API key for Haystack documentation.", required=True)
|
|
args = parser.parse_args()
|
|
new_version = args.version
|
|
|
|
api_key = args.key
|
|
api_key += ":"
|
|
api_key_b64 = "Basic " + base64.b64encode(api_key.encode("utf-8")).decode("utf-8")
|
|
|
|
# edit the category id in the yaml headers of pydoc configs
|
|
change_api_category_id(new_version, PYDOC_CONFIGS_DIR)
|