conf.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. import logging
  7. import os
  8. import sys
  9. from datetime import datetime
  10. # -- Path setup --------------------------------------------------------------
  11. # If extensions (or modules to document with autodoc) are in another directory,
  12. # add these directories to sys.path here. If the directory is relative to the
  13. # documentation root, use os.path.abspath to make it absolute, like shown here.
  14. #
  15. sys.path.insert(0, os.path.abspath("../../"))
  16. from olmocr import VERSION, VERSION_SHORT # noqa: E402
  17. # -- Project information -----------------------------------------------------
  18. project = "olmocr"
  19. copyright = f"{datetime.today().year}, Allen Institute for Artificial Intelligence"
  20. author = "Allen Institute for Artificial Intelligence"
  21. version = VERSION_SHORT
  22. release = VERSION
  23. # -- General configuration ---------------------------------------------------
  24. # Add any Sphinx extension module names here, as strings. They can be
  25. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
  26. # ones.
  27. extensions = [
  28. "sphinx.ext.autodoc",
  29. "sphinx.ext.napoleon",
  30. "myst_parser",
  31. "sphinx.ext.intersphinx",
  32. "sphinx.ext.viewcode",
  33. "sphinx.ext.doctest",
  34. "sphinx_copybutton",
  35. "sphinx_autodoc_typehints",
  36. ]
  37. # Tell myst-parser to assign header anchors for h1-h3.
  38. myst_heading_anchors = 3
  39. suppress_warnings = ["myst.header"]
  40. # Add any paths that contain templates here, relative to this directory.
  41. templates_path = ["_templates"]
  42. # List of patterns, relative to source directory, that match files and
  43. # directories to ignore when looking for source files.
  44. # This pattern also affects html_static_path and html_extra_path.
  45. exclude_patterns = ["_build"]
  46. source_suffix = [".rst", ".md"]
  47. intersphinx_mapping = {
  48. "python": ("https://docs.python.org/3", None),
  49. # Uncomment these if you use them in your codebase:
  50. # "torch": ("https://pytorch.org/docs/stable", None),
  51. # "datasets": ("https://huggingface.co/docs/datasets/master/en", None),
  52. # "transformers": ("https://huggingface.co/docs/transformers/master/en", None),
  53. }
  54. # By default, sort documented members by type within classes and modules.
  55. autodoc_member_order = "groupwise"
  56. # Include default values when documenting parameter types.
  57. typehints_defaults = "comma"
  58. # -- Options for HTML output -------------------------------------------------
  59. # The theme to use for HTML and HTML Help pages. See the documentation for
  60. # a list of builtin themes.
  61. #
  62. html_theme = "furo"
  63. html_title = f"olmocr v{VERSION}"
  64. # Add any paths that contain custom static files (such as style sheets) here,
  65. # relative to this directory. They are copied after the builtin static files,
  66. # so a file named "default.css" will overwrite the builtin "default.css".
  67. html_static_path = ["_static"]
  68. html_css_files = ["css/custom.css"]
  69. html_favicon = "_static/favicon.ico"
  70. html_theme_options = {
  71. "footer_icons": [
  72. {
  73. "name": "GitHub",
  74. "url": "https://github.com/allenai/olmocr",
  75. "html": """
  76. <svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
  77. <path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
  78. </svg>
  79. """, # noqa: E501
  80. "class": "",
  81. },
  82. ],
  83. }
  84. # -- Hack to get rid of stupid warnings from sphinx_autodoc_typehints --------
  85. class ShutupSphinxAutodocTypehintsFilter(logging.Filter):
  86. def filter(self, record: logging.LogRecord) -> bool:
  87. if "Cannot resolve forward reference" in record.msg:
  88. return False
  89. return True
  90. logging.getLogger("sphinx.sphinx_autodoc_typehints").addFilter(ShutupSphinxAutodocTypehintsFilter())