|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import os |
|
|
import subprocess |
|
|
import sys |
|
|
|
|
|
def install(package): |
|
|
subprocess.check_call([sys.executable, "-m", "pip", "install", package]) |
|
|
|
|
|
|
|
|
requirements_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'requirements.txt')) |
|
|
if os.path.exists(requirements_path): |
|
|
with open(requirements_path) as f: |
|
|
packages = f.readlines() |
|
|
for package in packages: |
|
|
install(package.strip()) |
|
|
|
|
|
from sphinx.ext import autodoc |
|
|
sys.path.insert(0, os.path.abspath('../..')) |
|
|
|
|
|
|
|
|
|
|
|
project = 'PDF-Extract-Kit' |
|
|
copyright = '2024, OpenDataLab' |
|
|
author = 'PDF-Extract-Kit Contributors' |
|
|
|
|
|
|
|
|
version_file = '../../pdf_extract_kit/version.py' |
|
|
with open(version_file) as f: |
|
|
exec(compile(f.read(), version_file, 'exec')) |
|
|
__version__ = locals()['__version__'] |
|
|
|
|
|
version = __version__ |
|
|
|
|
|
release = __version__ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extensions = [ |
|
|
'sphinx.ext.napoleon', |
|
|
'sphinx.ext.viewcode', |
|
|
'sphinx.ext.intersphinx', |
|
|
'sphinx_copybutton', |
|
|
'sphinx.ext.autodoc', |
|
|
'sphinx.ext.autosummary', |
|
|
'myst_parser', |
|
|
'sphinxarg.ext', |
|
|
] |
|
|
|
|
|
|
|
|
templates_path = ['_templates'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] |
|
|
|
|
|
|
|
|
copybutton_prompt_text = r'\$ ' |
|
|
copybutton_prompt_is_regexp = True |
|
|
|
|
|
language = 'zh_CN' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
html_theme = 'sphinx_book_theme' |
|
|
html_logo = '_static/image/logo.png' |
|
|
html_theme_options = { |
|
|
'path_to_docs': 'docs/zh_cn', |
|
|
'repository_url': 'https://github.com/opendatalab/PDF-Extract-Kit', |
|
|
'use_repository_button': True, |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
autodoc_mock_imports = [ |
|
|
'cpuinfo', |
|
|
'torch', |
|
|
'transformers', |
|
|
'psutil', |
|
|
'prometheus_client', |
|
|
'sentencepiece', |
|
|
'vllm.cuda_utils', |
|
|
'vllm._C', |
|
|
'numpy', |
|
|
'tqdm', |
|
|
] |
|
|
|
|
|
|
|
|
class MockedClassDocumenter(autodoc.ClassDocumenter): |
|
|
"""Remove note about base class when a class is derived from object.""" |
|
|
|
|
|
def add_line(self, line: str, source: str, *lineno: int) -> None: |
|
|
if line == ' Bases: :py:class:`object`': |
|
|
return |
|
|
super().add_line(line, source, *lineno) |
|
|
|
|
|
|
|
|
autodoc.ClassDocumenter = MockedClassDocumenter |
|
|
|
|
|
navigation_with_keys = False |