mirror of
https://github.com/deepset-ai/haystack.git
synced 2026-01-05 11:38:20 +00:00
chore: Remove Update API documentation hook (#3271)
* Remove Update API documentation hook * Remove .github/utils/pydoc-markdown.py file
This commit is contained in:
parent
05a86b9d3d
commit
eba7cf51b1
58
.github/utils/pydoc-markdown.py
vendored
58
.github/utils/pydoc-markdown.py
vendored
@ -1,58 +0,0 @@
|
||||
import argparse
|
||||
import sys
|
||||
import os
|
||||
import glob
|
||||
import pathlib
|
||||
import subprocess
|
||||
from typing import Sequence
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
def load_search_paths():
|
||||
"""
|
||||
Load the search path for each pydoc configuration file and return
|
||||
a map {search_path -> config_file}
|
||||
"""
|
||||
paths = dict()
|
||||
for fname in glob.glob("docs/_src/api/pydoc/*.yml"):
|
||||
with open(fname) as f:
|
||||
config = yaml.safe_load(f.read())
|
||||
# we always have only one loader in Haystack
|
||||
loader = config["loaders"][0]
|
||||
# `search_path` is a list but we always have only one item in Haystack
|
||||
search_path = loader["search_path"][0]
|
||||
# we only need the relative path from the root, let's get rid of
|
||||
# the `../../` prefix
|
||||
search_path = search_path.replace("../", "")
|
||||
paths[search_path] = fname
|
||||
return paths
|
||||
|
||||
|
||||
def main(argv: Sequence[str] = sys.argv):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("filenames", nargs="*", help="Filenames to check.")
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
search_paths = load_search_paths()
|
||||
|
||||
for filename in args.filenames:
|
||||
# for each file in the commit queue, check if its path belongs
|
||||
# to any search path known to pydoc. If not, skip to the next one.
|
||||
search_path = str(pathlib.Path(filename).parent)
|
||||
if search_path not in search_paths:
|
||||
continue
|
||||
|
||||
# if we get here, we need to build the docs: get the full path to the
|
||||
# config file and shell out `pydoc-markdown` after changing the current
|
||||
# working dir to the destination path.
|
||||
config_yml = os.path.abspath(pathlib.Path(search_paths[search_path]))
|
||||
res = subprocess.run(["pydoc-markdown", config_yml], cwd="docs/_src/api/api/")
|
||||
if res.returncode != 0:
|
||||
return res.returncode
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@ -21,14 +21,5 @@ repos:
|
||||
hooks:
|
||||
- id: black-jupyter
|
||||
|
||||
# These can fail if some dependencies are missing. Also untested on Windows.
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: pydoc-markdown
|
||||
name: Update API documentation
|
||||
entry: python .github/utils/pydoc-markdown.py
|
||||
language: system
|
||||
types: [python]
|
||||
|
||||
|
||||
# TODO we can make mypy and pylint run at this stage too, once their execution gets normalized
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user