conf.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 os
  7. import pathlib
  8. import re
  9. import sys
  10. import time
  11. # -- Path setup --------------------------------------------------------------
  12. # If extensions (or modules to document with autodoc) are in another directory,
  13. # add these directories to sys.path here. If the directory is relative to the
  14. # documentation root, use os.path.abspath to make it absolute, like shown here.
  15. pathobj_docs_dir = pathlib.Path(__file__).parent.absolute()
  16. pathobj_rootdir = pathobj_docs_dir.parent.absolute()
  17. # -- Project information -----------------------------------------------------
  18. try:
  19. cmakelists_contents = pathobj_rootdir.joinpath("CMakeLists.txt").read_text()
  20. versiontext_match = re.search(r"PROFINET VERSION ([\d.]*)", cmakelists_contents)
  21. version = versiontext_match.group(1)
  22. except:
  23. version = "unknown version"
  24. project = 'p-net'
  25. copyright = '2023, RT-Labs'
  26. author = 'RT-Labs'
  27. # -- General configuration ---------------------------------------------------
  28. # Add any Sphinx extension module names here, as strings. They can be
  29. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
  30. # ones.
  31. extensions = [
  32. "breathe",
  33. "recommonmark",
  34. "sphinx_copybutton",
  35. "sphinx_jinja",
  36. "sphinx.ext.autosectionlabel",
  37. "sphinx.ext.graphviz",
  38. "sphinxcontrib.kroki",
  39. "sphinxcontrib.programoutput",
  40. "sphinxcontrib.spelling",
  41. ]
  42. needs_sphinx = "1.8"
  43. # Add any paths that contain templates here, relative to this directory.
  44. templates_path = ["../../_templates"]
  45. # List of patterns, relative to source directory, that match files and
  46. # directories to ignore when looking for source files.
  47. # This pattern also affects html_static_path and html_extra_path.
  48. exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
  49. spelling_word_list_filename = "spelling_wordlist.txt"
  50. source_suffix = {
  51. '.rst': 'restructuredtext',
  52. '.md': 'markdown',
  53. }
  54. breathe_projects = {project: "../build/doc/xml/"}
  55. breathe_default_project = project
  56. # -- Options for HTML output -------------------------------------------------
  57. html_context = {
  58. "default_mode": "light"
  59. }
  60. html_theme = "sphinx_book_theme"
  61. html_theme_options = {
  62. "show_nav_level": 3,
  63. "home_page_in_toc": True,
  64. "use_repository_button": True,
  65. "use_fullscreen_button": False,
  66. "navbar_end": ["navbar-icon-links"],
  67. "use_download_button": False,
  68. "repository_url": "https://github.com/rtlabs-com/p-net",
  69. }
  70. html_last_updated_fmt = "%Y-%m-%d %H:%M"
  71. html_static_path = ["static"]
  72. html_logo = "static/i/p-net.svg"
  73. html_show_sourcelink = False
  74. if os.getenv("USE_EXTERNAL_CSS") is not None:
  75. html_css_files = [
  76. "https://rt-labs.com/content/themes/rtlabs2020/assets/css/style.css",
  77. "https://rt-labs.com/content/themes/rtlabs2020/assets/css/rt_custom_sphinx.css",
  78. ]
  79. # -- Options for PDF output -------------------------------------------------
  80. pdf_filename = "{}_{}".format(project.replace("-", ""), time.strftime("%Y-%m-%d"))
  81. pdf_title = "{} Profinet device stack".format(project)
  82. pdf_documents = [
  83. ("index", pdf_filename, pdf_title, author),
  84. ]
  85. pdf_break_level = 2