|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | +# --------------------------------------------------------------------------- |
| 4 | +# Copyright 2024 Diamond Light Source Ltd. |
| 5 | +# |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +# you may not use this file except in compliance with the License. |
| 8 | +# You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either ecpress or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | +# --------------------------------------------------------------------------- |
| 18 | +# Created By : Tomography Team at DLS <[email protected]> |
| 19 | + |
| 20 | +# -- General configuration ------------------------------------------------ |
| 21 | +# https://www.sphinx-doc.org/en/master/usage/configuration.html |
| 22 | + |
| 23 | +import os |
| 24 | +import sys |
| 25 | +from datetime import date |
| 26 | +from unittest import mock |
| 27 | + |
| 28 | +# If extensions (or modules to document with autodoc) are in another directory, |
| 29 | +# add these directories to sys.path here. If the directory is relative to the |
| 30 | +# documentation root, use os.path.abspath to make it absolute, like shown here. |
| 31 | + |
| 32 | +sys.path.insert(0, os.path.abspath("../..")) |
| 33 | + |
| 34 | +# -- Mock imports ------------------------------------------------------------- |
| 35 | + |
| 36 | + |
| 37 | +# Mock imports instead of full environment in readthedocs |
| 38 | +MOCK_MODULES = [ |
| 39 | + "click", |
| 40 | + "yaml", |
| 41 | +] |
| 42 | + |
| 43 | +for mod_name in MOCK_MODULES: |
| 44 | + sys.modules[mod_name] = mock.Mock() |
| 45 | + |
| 46 | +# ------------------------------------------------------------------------------ |
| 47 | + |
| 48 | +project = "httomo-backends" |
| 49 | +copyright = f"{date.today().year}, Diamond Light Source" |
| 50 | + |
| 51 | +# Specify a base language to help assistive technology |
| 52 | +language = "en" |
| 53 | + |
| 54 | +# Save the commit hash, this is displayed in the page title |
| 55 | +release = os.popen('git log -1 --format="%H"').read().strip() |
| 56 | + |
| 57 | +# Set version as the latest tag in the current branch |
| 58 | +version = os.popen("git describe --tags --abbrev=0").read().strip() |
| 59 | + |
| 60 | +# Add any Sphinx extension module names here, as strings. They can be extensions |
| 61 | +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. |
| 62 | +extensions = [ |
| 63 | + # Generates api files |
| 64 | + "sphinx.ext.autodoc", |
| 65 | + # Generates a short summary from docstring |
| 66 | + "sphinx.ext.autosummary", |
| 67 | + # Allows parsing of google style docstrings |
| 68 | + "sphinx.ext.napoleon", |
| 69 | + # Add links to highlighted source code |
| 70 | + "sphinx.ext.viewcode", |
| 71 | + # Allows a grid layout and dropdown boxes |
| 72 | + "sphinx_panels", |
| 73 | + # copy to clipboard button |
| 74 | + "sphinx_copybutton", |
| 75 | + # use jupyter notebooks |
| 76 | + "nbsphinx", |
| 77 | + #'IPython.sphinxext.ipython_console_highlighting', |
| 78 | + "sphinx.ext.githubpages", |
| 79 | + # Generate .nojekyll file for git pages build |
| 80 | +] |
| 81 | + |
| 82 | +autosummary_generate = True |
| 83 | +numfig = True |
| 84 | +template_patterns = ["_templates"] |
| 85 | + |
| 86 | +# The name of the Pygments (syntax highlighting) style to use. |
| 87 | +pygments_style = "sphinx" |
| 88 | + |
| 89 | +# -- Options for HTML output -------------------------------------------------- |
| 90 | + |
| 91 | +html_theme = "sphinx_book_theme" |
| 92 | +html_title = "httomo-backends documentation page" |
| 93 | +html_copy_source = True |
| 94 | +html_last_updated_fmt = "" |
| 95 | +html_use_smartypants = True |
| 96 | + |
| 97 | +html_theme_options = { |
| 98 | + "show_toc_level": 1, |
| 99 | + "navbar_align": "left", # [left, content, right] For testing that the navbar items align properly |
| 100 | +} |
| 101 | + |
| 102 | + |
| 103 | +html_context = { |
| 104 | + "github_user": "HTTomo", |
| 105 | + "github_repo": "https://github.com/DiamondLightSource/httomo-backends", |
| 106 | + "github_version": "main", |
| 107 | + "doc_path": "docs", |
| 108 | +} |
| 109 | + |
| 110 | + |
| 111 | +def setup(app): |
| 112 | + app.add_css_file("css/general.css") |
0 commit comments