Added Sphinx based documentation.

(cherry picked from commit f9f5dd5117a14ba31a3a9113a1de2c12c624dffb)
This commit is contained in:
Patrick Lehmann
2022-10-29 22:40:27 +02:00
parent 88175d0d21
commit c78c1c8503
34 changed files with 1524 additions and 0 deletions

253
doc/conf.py Normal file
View File

@@ -0,0 +1,253 @@
# 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.
from importlib.util import find_spec
from sys import path as sys_path
from os.path import abspath
from pathlib import Path
from json import loads
from pyTooling.Packaging import extractVersionInformation
ROOT = Path(__file__).resolve().parent
sys_path.insert(0, abspath("."))
sys_path.insert(0, abspath(".."))
#sys_path.insert(0, abspath("../pyTooling"))
sys_path.insert(0, abspath("_extensions"))
# ==============================================================================
# Project information and versioning
# ==============================================================================
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
project = "Actions"
packageInformationFile = Path(f"../{project}/__init__.py")
versionInformation = extractVersionInformation(packageInformationFile)
author = versionInformation.Author
copyright = versionInformation.Copyright
version = ".".join(versionInformation.Version.split(".")[:2]) # e.g. 2.3 The short X.Y version.
release = versionInformation.Version
# ==============================================================================
# Miscellaneous settings
# ==============================================================================
# The master toctree document.
master_doc = "index"
# 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.
exclude_patterns = [
"_build",
"_theme",
"Thumbs.db",
".DS_Store"
]
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "manni"
# ==============================================================================
# Restructured Text settings
# ==============================================================================
prologPath = "prolog.inc"
try:
with open(prologPath, "r") as prologFile:
rst_prolog = prologFile.read()
except Exception as ex:
print(f"[ERROR:] While reading '{prologPath}'.")
print(ex)
rst_prolog = ""
# ==============================================================================
# Options for HTML output
# ==============================================================================
html_context = {}
ctx = ROOT / "context.json"
if ctx.is_file():
html_context.update(loads(ctx.open('r').read()))
if (ROOT / "_theme").is_dir():
html_theme_path = ["."]
html_theme = "_theme"
html_theme_options = {
"logo_only": True,
"home_breadcrumbs": False,
"vcs_pageview_mode": 'blob',
# "body_max_width": None
# "navigation_depth": 5,
}
elif find_spec("sphinx_rtd_theme") is not None:
html_theme = "sphinx_rtd_theme"
html_theme_options = {
"logo_only": True,
"vcs_pageview_mode": 'blob',
# "navigation_depth": 5,
}
else:
html_theme = "alabaster"
# 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"]
html_logo = str(Path(html_static_path[0]) / "logo.png")
html_favicon = str(Path(html_static_path[0]) / "icon.png")
# Output file base name for HTML help builder.
htmlhelp_basename = "ActionsDoc"
# If not None, a 'Last updated on:' timestamp is inserted at every page
# bottom, using the given strftime format.
# The empty string is equivalent to '%b %d, %Y'.
html_last_updated_fmt = "%d.%m.%Y"
# ==============================================================================
# Python settings
# ==============================================================================
modindex_common_prefix = [
f"{project}."
]
# ==============================================================================
# Options for LaTeX / PDF output
# ==============================================================================
from textwrap import dedent
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
"papersize": "a4paper",
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
"preamble": dedent(r"""
% ================================================================================
% User defined additional preamble code
% ================================================================================
% Add more Unicode characters for pdfLaTeX.
% - Alternatively, compile with XeLaTeX or LuaLaTeX.
% - https://GitHub.com/sphinx-doc/sphinx/issues/3511
%
\ifdefined\DeclareUnicodeCharacter
\DeclareUnicodeCharacter{2265}{$\geq$}
\DeclareUnicodeCharacter{21D2}{$\Rightarrow$}
\fi
% ================================================================================
"""),
# Latex figure (float) alignment
#'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
( master_doc,
"Actions.tex",
"The pyTooling Actions Documentation",
"Patrick Lehmann",
"manual"
),
]
# ==============================================================================
# Extensions
# ==============================================================================
extensions = [
# Standard Sphinx extensions
"sphinx.ext.coverage",
"sphinx.ext.extlinks",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
"sphinx.ext.graphviz",
"sphinx.ext.mathjax",
"sphinx.ext.ifconfig",
"sphinx.ext.viewcode",
# SphinxContrib extensions
"sphinxcontrib.mermaid",
# Other extensions
"sphinx_fontawesome",
]
# ==============================================================================
# Sphinx.Ext.InterSphinx
# ==============================================================================
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
}
# ==============================================================================
# Sphinx.Ext.AutoDoc
# ==============================================================================
# see: https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#configuration
#autodoc_default_options = {
# "private-members": True,
# "special-members": True,
# "inherited-members": True,
# "exclude-members": "__weakref__"
#}
#autodoc_class_signature = "separated"
autodoc_member_order = "bysource" # alphabetical, groupwise, bysource
autodoc_typehints = "both"
#autoclass_content = "both"
# ==============================================================================
# Sphinx.Ext.ExtLinks
# ==============================================================================
extlinks = {
"gh": ("https://GitHub.com/%s", "gh:"),
"ghissue": ("https://GitHub.com/pyTooling/Actions/issues/%s", "issue #"),
"ghpull": ("https://GitHub.com/pyTooling/Actions/pull/%s", "pull request #"),
"ghsrc": ("https://GitHub.com/pyTooling/Actions/blob/main/%s", ""),
"wiki": ("https://en.wikipedia.org/wiki/%s", ""),
}
# ==============================================================================
# Sphinx.Ext.Graphviz
# ==============================================================================
graphviz_output_format = "svg"
# ==============================================================================
# SphinxContrib.Mermaid
# ==============================================================================
mermaid_params = [
'--backgroundColor', 'transparent',
]
mermaid_verbose = True
# ==============================================================================
# Sphinx.Ext.ToDo
# ==============================================================================
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
todo_link_only = True
# ==============================================================================
# Sphinx.Ext.Coverage
# ==============================================================================
coverage_show_missing_items = True