conf.py 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. # -*- coding: utf-8 -*-
  2. #
  3. # Configuration file for the Sphinx documentation builder.
  4. #
  5. # This file does only contain a selection of the most common options. For a
  6. # full list see the documentation:
  7. # http://www.sphinx-doc.org/en/stable/config
  8. import os
  9. import shutil
  10. from datetime import datetime
  11. from pkg_resources import get_distribution
  12. import sphinx_fontawesome
  13. # If extensions (or modules to document with autodoc) are in another directory,
  14. # add these directories to sys.path here. If the directory is relative to the
  15. # documentation root, use os.path.abspath to make it absolute, like shown here.
  16. #
  17. # -- Project information -----------------------------------------------------
  18. project = "FlexMeasures"
  19. copyright = f"{datetime.now().year}, Seita Energy Flexibility, developed in partnership with A1 Engineering, South Korea"
  20. author = "Seita B.V."
  21. # The full version, including alpha/beta/rc tags
  22. release = get_distribution("flexmeasures").version
  23. # The short X.Y.Z version
  24. version = ".".join(release.split(".")[:3])
  25. rst_prolog = sphinx_fontawesome.prolog
  26. # -- General configuration ---------------------------------------------------
  27. # If your documentation needs a minimal Sphinx version, state it here.
  28. #
  29. # needs_sphinx = '1.0'
  30. # Add any Sphinx extension module names here, as strings. They can be
  31. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
  32. # ones.
  33. extensions = [
  34. "sphinx_rtd_theme",
  35. "sphinx.ext.intersphinx",
  36. "sphinx.ext.coverage",
  37. "sphinx.ext.mathjax",
  38. "sphinx.ext.ifconfig",
  39. "sphinx.ext.todo",
  40. "sphinx_copybutton",
  41. "sphinx_tabs.tabs",
  42. "sphinx_fontawesome",
  43. "sphinxcontrib.autohttp.flask",
  44. "sphinxcontrib.autohttp.flaskqref",
  45. ]
  46. autodoc_default_options = {}
  47. # Add any paths that contain templates here, relative to this directory.
  48. templates_path = ["_templates"]
  49. # if GEN_CODE_DOCS is not found, the default is gen_code_docs=True
  50. gen_code_docs = not bool(
  51. os.environ.get("GEN_CODE_DOCS", "True").lower() in ("f", "false", "0")
  52. )
  53. # Generate code docs
  54. if gen_code_docs:
  55. # Add dependencies
  56. extensions.extend(
  57. [
  58. "sphinx.ext.autosummary",
  59. "sphinx.ext.autodoc.typehints",
  60. "sphinx.ext.autodoc",
  61. ]
  62. )
  63. else:
  64. if os.path.exists("_autosummary"):
  65. shutil.rmtree("_autosummary")
  66. # The suffix(es) of source filenames.
  67. # You can specify multiple suffix as a list of string:
  68. #
  69. # source_suffix = ['.rst', '.md']
  70. source_suffix = ".rst"
  71. # The master toctree document.
  72. master_doc = "index"
  73. # The language for content autogenerated by Sphinx. Refer to documentation
  74. # for a list of supported languages.
  75. #
  76. # This is also used if you do content translation via gettext catalogs.
  77. # Usually you set "language" from the command line for these cases.
  78. language = "en"
  79. # List of patterns, relative to source directory, that match files and
  80. # directories to ignore when looking for source files.
  81. # This pattern also affects html_static_path and html_extra_path .
  82. exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "_templates"]
  83. # Todo: these are not mature enough yet for release, or should be removed
  84. exclude_patterns.append("int/*.rst")
  85. exclude_patterns.append("concepts/assets.rst")
  86. exclude_patterns.append("concepts/markets.rst")
  87. exclude_patterns.append("concepts/users.rst")
  88. exclude_patterns.append("api/aggregator.rst")
  89. exclude_patterns.append("api/mdc.rst")
  90. exclude_patterns.append("api/prosumer.rst")
  91. exclude_patterns.append("api/supplier.rst")
  92. # Whether to show todo notes in the documentation
  93. todo_include_todos = True
  94. # The name of the Pygments (syntax highlighting) style to use.
  95. pygments_style = "sphinx"
  96. # -- Options for HTML output -------------------------------------------------
  97. # The theme to use for HTML and HTML Help pages. See the documentation for
  98. # a list of builtin themes.
  99. #
  100. html_theme = "sphinx_rtd_theme"
  101. html_logo = "https://artwork.lfenergy.org/projects/flexmeasures/horizontal/white/flexmeasures-horizontal-white.png"
  102. # Theme options are theme-specific and customize the look and feel of a theme
  103. # further. For a list of options available for each theme, see the
  104. # documentation.
  105. #
  106. html_theme_options = {
  107. "logo_only": True,
  108. }
  109. # Add any paths that contain custom _static files (such as style sheets) here,
  110. # relative to this directory. They are copied after the builtin _static files,
  111. # so a file named "default.css" will overwrite the builtin "default.css".
  112. html_static_path = ["_static"]
  113. html_css_files = ["css/custom.css"]
  114. # Custom sidebar templates, must be a dictionary that maps document names
  115. # to template names.
  116. #
  117. # The default sidebars (for documents that don't match any pattern) are
  118. # defined by theme itself. Builtin themes are using these templates by
  119. # default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
  120. # 'searchbox.html']``.
  121. #
  122. # html_sidebars = {}
  123. # -- Options for HTMLHelp output ---------------------------------------------
  124. # Output file base name for HTML help builder.
  125. htmlhelp_basename = "FLEXMEASURESdoc"
  126. # -- Options for LaTeX output ------------------------------------------------
  127. latex_elements = {
  128. # The paper size ('letterpaper' or 'a4paper').
  129. #
  130. # 'papersize': 'letterpaper',
  131. # The font size ('10pt', '11pt' or '12pt').
  132. #
  133. # 'pointsize': '10pt',
  134. # Additional stuff for the LaTeX preamble.
  135. #
  136. # 'preamble': '',
  137. # Latex figure (float) alignment
  138. #
  139. # 'figure_align': 'htbp',
  140. }
  141. # Grouping the document tree into LaTeX files. List of tuples
  142. # (source start file, target name, title,
  143. # author, documentclass [howto, manual, or own class]).
  144. latex_documents = [
  145. (
  146. master_doc,
  147. f"{project}.tex",
  148. f"{project} Documentation",
  149. author,
  150. "manual",
  151. )
  152. ]
  153. # -- Options for manual page output ------------------------------------------
  154. # One entry per manual page. List of tuples
  155. # (source start file, name, description, authors, manual section).
  156. man_pages = [(master_doc, project, f"{project} Documentation", [author], 1)]
  157. # -- Options for Texinfo output ----------------------------------------------
  158. # Grouping the document tree into Texinfo files. List of tuples
  159. # (source start file, target name, title, author,
  160. # dir menu entry, description, category)
  161. texinfo_documents = [
  162. (
  163. master_doc,
  164. project,
  165. f"{project} Documentation",
  166. author,
  167. project,
  168. f"The {project} Platform is a tool for scheduling energy flexibility activations on behalf of the connected asset owners.",
  169. "Miscellaneous",
  170. )
  171. ]
  172. # -- Extension configuration -------------------------------------------------
  173. # -- Options for intersphinx extension ---------------------------------------
  174. # Example configuration for intersphinx: refer to the Python standard library.
  175. intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
  176. # -- Options for copybytton extension ---------------------------------------
  177. copybutton_prompt_is_regexp = True
  178. copybutton_prompt_text = r">>> |\.\.\. |\$ " # Python Repl + continuation + Bash
  179. copybutton_line_continuation_character = "\\"
  180. # -- Options for ifconfig extension ---------------------------------------
  181. def setup(sphinx_app):
  182. """
  183. Here you can set config variables for Sphinx or even pass config variables from FlexMeasures to Sphinx.
  184. For example, to display content depending on FLEXMEASURES_MODE (specified in the FlexMeasures app's config.py),
  185. place this in one of the rst files:
  186. .. ifconfig:: FLEXMEASURES_MODE == "play"
  187. We are in play mode.
  188. """
  189. # sphinx_app.add_config_value('RELEASE_LEVEL', 'alpha', 'env')
  190. sphinx_app.add_config_value(
  191. "FLEXMEASURES_MODE",
  192. "live",
  193. "env", # hard-coded, documentation is not server-specific for the time being
  194. )
  195. if gen_code_docs:
  196. from flexmeasures.app import create
  197. create(
  198. env="documentation"
  199. ) # we need to create the app for when sphinx imports modules that use current_app