Skip to content

Commit

Permalink
update docs script
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsteers committed Feb 16, 2024
1 parent ea4cfe4 commit f800e81
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 34 deletions.
31 changes: 0 additions & 31 deletions docs.py

This file was deleted.

1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
generated
44 changes: 44 additions & 0 deletions docs/generate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
from __future__ import annotations

import os
import pathlib
import shutil

import pdoc

import airbyte as ab

import typing

typing.TYPE_CHECKING = True


def run() -> None:
"""Generate docs for all public modules in airbyte_lib and save them to docs/generated.
Public modules are:
* The main airbyte_lib module
* All directory modules in airbyte_lib that don't start with an underscore.
"""
public_modules = ["airbyte"]

# recursively delete the docs/generated folder if it exists
if pathlib.Path("docs/generated").exists():
shutil.rmtree("docs/generated")

# All files and folders in `airbyte_lib` that don't start with "_" are treated as public.
for submodule in os.listdir("airbyte"):
submodule_path = pathlib.Path(f"airbyte/{submodule}")
if not submodule.startswith("_"):
public_modules.append(submodule_path)

pdoc.render.configure(
template_directory="docs",
show_source=False,
search=False,
)
pdoc.pdoc(
*public_modules,
output_directory=pathlib.Path("docs/generated"),
)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ module = [
ignore_missing_imports = true # No stubs yet (😢)

[tool.poetry.scripts]
generate-docs = "docs:run"
generate-docs = "docs.generate:run"
airbyte-lib-validate-source = "airbyte.validate:run"

[tool.poe.tasks]
Expand Down
4 changes: 2 additions & 2 deletions tests/docs_tests/test_docs_checked_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import os

import docs
import docs.generate as generate


def test_docs_checked_in():
Expand All @@ -13,7 +13,7 @@ def test_docs_checked_in():
It will fail if there are any differences.
"""

docs.run()
generate.run()

# compare the generated docs with the checked in docs
diff = os.system("git diff --exit-code docs/generated")
Expand Down

0 comments on commit f800e81

Please sign in to comment.