From ffa3f6b12999776b68702437de8ad42c8a4313d0 Mon Sep 17 00:00:00 2001 From: SebastianGode <70581801+SebastianGode@users.noreply.github.com> Date: Fri, 15 Nov 2024 12:19:37 +0100 Subject: [PATCH] Update Confpy for Docs (#364) Update Confpy for Docs Reviewed-by: Tino Schr --- doc/requirements.txt | 6 ++ doc/source/_static/.placeholder | 0 doc/source/conf.py | 105 ++++++++++++++++++++++++++++++-- 3 files changed, 106 insertions(+), 5 deletions(-) create mode 100644 doc/source/_static/.placeholder diff --git a/doc/requirements.txt b/doc/requirements.txt index 1439b2c2..feec3026 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1 +1,7 @@ otcdocstheme # Ansible-2.0 +sphinx +otc-sphinx-directives>=0.1.0 +sphinx-minify>=0.0.1 # Apache-2.0 +git+https://gitea.eco.tsi-dev.otc-service.com/infra/otc-metadata.git#egg=otc_metadata +setuptools +gitpython diff --git a/doc/source/_static/.placeholder b/doc/source/_static/.placeholder new file mode 100644 index 00000000..e69de29b diff --git a/doc/source/conf.py b/doc/source/conf.py index 9ff8c6c1..d9438146 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -14,6 +14,11 @@ # import sys # sys.path.insert(0, os.path.abspath('.')) +import os +import sys +from git import Repo +from datetime import datetime + # -- Project information ----------------------------------------------------- project = 'Open Telekom Cloud Ansible Modules Documentation' @@ -28,6 +33,7 @@ # ones. extensions = [ 'otcdocstheme', + 'otc_sphinx_directives', 'sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx_antsibull_ext' @@ -35,9 +41,6 @@ antsibull_ext_color_scheme = 'default-autodark' -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. @@ -46,11 +49,103 @@ # -- Options for HTML output ------------------------------------------------- -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. +otcdocs_auto_name = False +otcdocs_auto_version = False + +otcdocs_repo_name = 'opentelekomcloud/ansible-collection-cloud' +# Those variables are required for edit/bug links + +# Those variables are needed for indexing into OpenSearch +otcdocs_doc_environment = '' +otcdocs_doc_link = '' +otcdocs_doc_title = '' +otcdocs_doc_type = '' +otcdocs_service_category = '' +otcdocs_service_title = 'Ansible Collection opentelekomcloud.cloud' +otcdocs_service_type = '' +otcdocs_search_environment = 'hc_de' +otcdocs_search_url = "https://opensearch.eco.tsi-dev.otc-service.com/" + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath('../../')) +sys.path.insert(0, os.path.abspath('../')) +sys.path.insert(0, os.path.abspath('./')) + +# -- General configuration ---------------------------------------------------- +# https://docutils.sourceforge.io/docs/user/smartquotes.html - it does not +# what it is expected +smartquotes = False + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. # +source_encoding = 'utf-8' + +# The master toctree document. +master_doc = 'index' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +language = 'en' + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +show_authors = False + +# -- Options for HTML output -------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +# html_theme_path = ["."] html_theme = 'otcdocs' +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +html_theme_options = { +} + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". + +html_title = "Open Telekom Cloud Ansible Modules Documentation" + + # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] +templates_path = ['_templates'] + +# Do not include sources into the rendered results +html_copy_source = False + +# -- Options for PDF output -------------------------------------------------- +latex_documents = [] + +# Get the Git commit values for last updated timestamp on each page +repo = Repo(search_parent_directories=True) +commit = repo.head.commit +current_commit_hash = commit.hexsha +current_commit_time = commit.committed_datetime.strftime('%Y-%m-%d %H:%M') + +latex_elements = { + 'papersize': 'a4paper', + 'pointsize': '12pt', + 'figure_align': 'H', + 'preamble': rf''' + \newcommand{{\githash}}{{{current_commit_hash}}} + \newcommand{{\gitcommittime}}{{{current_commit_time}}} + \newcommand{{\doctitle}}{{{otcdocs_doc_title}}} + \newcommand{{\servicetitle}}{{{otcdocs_service_title}}} + ''', + 'sphinxsetup': 'hmargin={15mm,15mm}, vmargin={20mm,30mm}, marginpar=10mm' +}