conf.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. # Configuration file for the Sphinx documentation builder.
  2. #
  3. # This file only contains a selection of the most common options. For a full
  4. # list see the documentation:
  5. # https://www.sphinx-doc.org/en/master/usage/configuration.html
  6. # -- Path setup --------------------------------------------------------------
  7. # If extensions (or modules to document with autodoc) are in another directory,
  8. # add these directories to sys.path here. If the directory is relative to the
  9. # documentation root, use os.path.abspath to make it absolute, like shown here.
  10. import os
  11. import subprocess
  12. import sys
  13. from sphinx.ext import autodoc
  14. def install(package):
  15. subprocess.check_call([sys.executable, '-m', 'pip', 'install', package])
  16. requirements_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'requirements.txt'))
  17. if os.path.exists(requirements_path):
  18. with open(requirements_path) as f:
  19. packages = f.readlines()
  20. for package in packages:
  21. install(package.strip())
  22. sys.path.insert(0, os.path.abspath('../..'))
  23. # -- Project information -----------------------------------------------------
  24. project = 'MinerU'
  25. copyright = '2024, OpenDataLab'
  26. author = 'MinerU Contributors'
  27. # The full version, including alpha/beta/rc tags
  28. version_file = '../../magic_pdf/libs/version.py'
  29. with open(version_file) as f:
  30. exec(compile(f.read(), version_file, 'exec'))
  31. __version__ = locals()['__version__']
  32. # The short X.Y version
  33. version = __version__
  34. # The full version, including alpha/beta/rc tags
  35. release = __version__
  36. # -- General configuration ---------------------------------------------------
  37. # Add any Sphinx extension module names here, as strings. They can be
  38. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
  39. # ones.
  40. extensions = [
  41. 'sphinx.ext.napoleon',
  42. 'sphinx.ext.viewcode',
  43. 'sphinx.ext.intersphinx',
  44. 'sphinx_copybutton',
  45. 'sphinx.ext.autodoc',
  46. 'sphinx.ext.autosummary',
  47. 'myst_parser',
  48. 'sphinxarg.ext',
  49. ]
  50. # Add any paths that contain templates here, relative to this directory.
  51. templates_path = ['_templates']
  52. # List of patterns, relative to source directory, that match files and
  53. # directories to ignore when looking for source files.
  54. # This pattern also affects html_static_path and html_extra_path.
  55. exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
  56. # Exclude the prompt "$" when copying code
  57. copybutton_prompt_text = r'\$ '
  58. copybutton_prompt_is_regexp = True
  59. language = 'zh_CN'
  60. # -- Options for HTML output -------------------------------------------------
  61. # The theme to use for HTML and HTML Help pages. See the documentation for
  62. # a list of builtin themes.
  63. #
  64. html_theme = 'sphinx_book_theme'
  65. html_logo = '_static/image/logo.png'
  66. html_theme_options = {
  67. 'path_to_docs': 'docs/zh_cn',
  68. 'repository_url': 'https://github.com/opendatalab/MinerU',
  69. 'use_repository_button': True,
  70. }
  71. # Add any paths that contain custom static files (such as style sheets) here,
  72. # relative to this directory. They are copied after the builtin static files,
  73. # so a file named "default.css" will overwrite the builtin "default.css".
  74. # html_static_path = ['_static']
  75. # Mock out external dependencies here.
  76. autodoc_mock_imports = [
  77. 'cpuinfo',
  78. 'torch',
  79. 'transformers',
  80. 'psutil',
  81. 'prometheus_client',
  82. 'sentencepiece',
  83. 'vllm.cuda_utils',
  84. 'vllm._C',
  85. 'numpy',
  86. 'tqdm',
  87. ]
  88. class MockedClassDocumenter(autodoc.ClassDocumenter):
  89. """Remove note about base class when a class is derived from object."""
  90. def add_line(self, line: str, source: str, *lineno: int) -> None:
  91. if line == ' Bases: :py:class:`object`':
  92. return
  93. super().add_line(line, source, *lineno)
  94. autodoc.ClassDocumenter = MockedClassDocumenter
  95. navigation_with_keys = False