Skip to content

Commit

Permalink
Remove unnecessary code and speed up build docs script (#595)
Browse files Browse the repository at this point in the history
* Us multiprocessing to reduce api docs build time

* Remove griffe related code to speed up build docs script
  • Loading branch information
kumaranvpl authored Sep 11, 2023
1 parent a991165 commit 50857ec
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 139 deletions.
125 changes: 0 additions & 125 deletions docs/api_docs_helper.py

This file was deleted.

30 changes: 17 additions & 13 deletions docs/create_api_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from types import FunctionType, ModuleType
from typing import Any, List, Optional, Tuple, Type, Union

from api_docs_helper import get_formatted_docstring_for_symbol


def _get_submodules(package_name: str) -> List[str]:
"""Get all submodules of a package.
Expand Down Expand Up @@ -169,21 +167,27 @@ def _load_submodules(
return names


def _update_single_api_doc(
symbol: Union[FunctionType, Type[Any]], docs_path: Path
) -> None:
en_docs_path = docs_path / "docs" / "en"

module = f"{symbol.__module__}.{symbol.__qualname__}"
content = f"\n\n::: {module}\n"

target_file_path = (
"/".join(f"{symbol.__module__}.{symbol.__name__}".split(".")) + ".md"
)

with open((en_docs_path / "api" / target_file_path), "w", encoding="utf-8") as f:
f.write(content)


def _update_api_docs(
symbols: List[Union[FunctionType, Type[Any]]], docs_path: Path
) -> None:
en_docs_path = docs_path / "docs" / "en"
for symbol in symbols:
content = ""
content += get_formatted_docstring_for_symbol(symbol, docs_path)
target_file_path = (
"/".join(f"{symbol.__module__}.{symbol.__name__}".split(".")) + ".md"
)

with open(
(en_docs_path / "api" / target_file_path), "w", encoding="utf-8"
) as f:
f.write(content)
_update_single_api_doc(symbol=symbol, docs_path=docs_path)


def _generate_api_docs_for_module(root_path: str, module_name: str) -> str:
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ devdocs = [
"mdx-include>=1.4.1,<2.0.0",
"mkdocstrings[python]>=0.23.0",
"mkdocs-literate-nav>=0.6.0",
"griffe>=0.24.1",
"mkdocs-git-revision-date-localized-plugin>=1.2.0",
"mike>=1.1.0", # versioning
"mkdocs-macros-plugin>=1.0.0", # includes with variables
Expand Down

0 comments on commit 50857ec

Please sign in to comment.