conf.py 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. # -*- coding: utf-8 -*-
  2. #
  3. # Configuration file for the Sphinx documentation builder.
  4. #
  5. # For the full list of built-in configuration values, see the documentation:
  6. # https://www.sphinx-doc.org/en/master/usage/configuration.html
  7. # ----------------------------------------------------------------------------
  8. import os
  9. import platform
  10. import re
  11. import shlex
  12. import sys
  13. from subprocess import Popen, PIPE
  14. def get_version():
  15. if os.environ.get('READTHEDOCS') == 'True':
  16. return os.environ.get('READTHEDOCS_VERSION')
  17. if os.environ.get('GITHUB_ACTIONS') == 'True':
  18. return os.environ.get('GITHUB_REF_NAME')
  19. grep = 'git branch | findstr \*' if platform.system() == 'Windows' else 'git branch | grep \*'
  20. pipe = Popen(grep, stdout=PIPE, shell=True, universal_newlines=True)
  21. version = pipe.stdout.read()
  22. if version:
  23. return version[2:]
  24. else:
  25. return 'unknown'
  26. # ----------------------------------------------------------------------------
  27. # loading PhpLexer
  28. from sphinx.highlighting import lexers
  29. from pygments.lexers.web import PhpLexer
  30. # enable highlighting for PHP code not between ``<?php ... ?>`` by default
  31. lexers['php'] = PhpLexer(startinline=True)
  32. lexers['php-annotations'] = PhpLexer(startinline=True)
  33. # -- Project information -----------------------------------------------------
  34. # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
  35. project = u'PHP-QRCode'
  36. copyright = u'2023, smiley'
  37. author = u'smiley'
  38. epub_author = u'smiley'
  39. # The version info for the project you're documenting, acts as replacement for
  40. # |version| and |release|, also used in various other places throughout the
  41. # built documents.
  42. #
  43. # The short X.Y version.
  44. version = get_version().strip()
  45. # The full version, including alpha/beta/rc tags.
  46. release = version
  47. # There are two options for replacing |today|: either, you set today to some
  48. # non-false value, then it is used:
  49. #today = ''
  50. # Else, today_fmt is used as the format for a strftime call.
  51. #today_fmt = '%B %d, %Y'
  52. # -- General configuration ---------------------------------------------------
  53. # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
  54. # If your documentation needs a minimal Sphinx version, state it here.
  55. needs_sphinx = '6.0.0'
  56. # Add any Sphinx extension module names here, as strings. They can be
  57. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
  58. # ones.
  59. extensions = [
  60. 'myst_parser',
  61. 'sphinx.ext.autodoc',
  62. ]
  63. # Add any paths that contain templates here, relative to this directory.
  64. #templates_path = ['_templates']
  65. # The suffix(es) of source filenames.
  66. # You can specify multiple suffix as a list of string:
  67. source_suffix = ['.rst', '.md']
  68. # The encoding of source files.
  69. #source_encoding = 'utf-8-sig'
  70. # The master toctree document.
  71. master_doc = 'index'
  72. # The language for content autogenerated by Sphinx. Refer to documentation
  73. # for a list of supported languages.
  74. #
  75. # This is also used if you do content translation via gettext catalogs.
  76. # Usually you set "language" from the command line for these cases.
  77. language = 'en'
  78. # List of patterns, relative to source directory, that match files and
  79. # directories to ignore when looking for source files.
  80. exclude_patterns = ['_build', 'Readme.md']
  81. # The reST default role (used for this markup: `text`) to use for all
  82. # documents.
  83. #default_role = None
  84. # If true, '()' will be appended to :func: etc. cross-reference text.
  85. #add_function_parentheses = True
  86. # If true, the current module name will be prepended to all description
  87. # unit titles (such as .. function::).
  88. #add_module_names = True
  89. # If true, sectionauthor and moduleauthor directives will be shown in the
  90. # output. They are ignored by default.
  91. #show_authors = False
  92. # The default language to highlight source code in. The default is 'default'.
  93. # It is similar to 'python3'; it is mostly a superset of 'python' but it
  94. # fallbacks to 'none' without warning if failed.
  95. highlight_language = 'none'
  96. # The name of the Pygments (syntax highlighting) style to use.
  97. pygments_style = 'sphinx'
  98. # A list of ignored prefixes for module index sorting.
  99. #modindex_common_prefix = []
  100. # If true, keep warnings as "system message" paragraphs in the built documents.
  101. #keep_warnings = False
  102. # If true, `todo` and `todoList` produce output, else they produce nothing.
  103. todo_include_todos = False
  104. # -- Options for HTML output -------------------------------------------------
  105. # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
  106. html_theme = 'sphinx_rtd_theme'
  107. html_theme_options = {
  108. 'collapse_navigation': False,
  109. 'display_version': False
  110. }
  111. html_context = {
  112. 'display_github': True,
  113. 'github_user': 'chillerlan',
  114. 'github_repo': 'php-qrcode',
  115. 'github_version': version,
  116. 'conf_py_path': '/docs/',
  117. }
  118. # Add any paths that contain custom themes here, relative to this directory.
  119. #html_theme_path = ['_templates']
  120. #html_add_permalinks = ''
  121. # The name for this set of Sphinx documents. If None, it defaults to
  122. # "<project> v<release> documentation".
  123. html_title = "PHP-QRCode %s Manual" % get_version()
  124. # A shorter title for the navigation bar. Default is the same as html_title.
  125. #html_short_title = None
  126. # The name of an image file (relative to this directory) to place at the top
  127. # of the sidebar.
  128. #html_logo = None
  129. # The name of an image file (within the static path) to use as favicon of the
  130. # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
  131. # pixels large.
  132. #html_favicon = None
  133. # Add any paths that contain custom static files (such as style sheets) here,
  134. # relative to this directory. They are copied after the builtin static files,
  135. # so a file named "default.css" will overwrite the builtin "default.css".
  136. #html_static_path = ['_static']
  137. # Add any extra paths that contain custom files (such as robots.txt or
  138. # .htaccess) here, relative to this directory. These files are copied
  139. # directly to the root of the documentation.
  140. #html_extra_path = []
  141. # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
  142. # using the given strftime format.
  143. #html_last_updated_fmt = '%b %d, %Y'
  144. # If true, SmartyPants will be used to convert quotes and dashes to
  145. # typographically correct entities.
  146. #html_use_smartypants = True
  147. # Custom sidebar templates, maps document names to template names.
  148. #html_sidebars = {}
  149. # Additional templates that should be rendered to pages, maps page names to
  150. # template names.
  151. #html_additional_pages = {}
  152. # If false, no module index is generated.
  153. #html_domain_indices = True
  154. # If false, no index is generated.
  155. #html_use_index = True
  156. # If true, the index is split into individual pages for each letter.
  157. #html_split_index = False
  158. # If true, links to the reST sources are added to the pages.
  159. #html_show_sourcelink = True
  160. # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
  161. html_show_sphinx = False
  162. # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
  163. #html_show_copyright = True
  164. # If true, an OpenSearch description file will be output, and all pages will
  165. # contain a <link> tag referring to it. The value of this option must be the
  166. # base URL from which the finished HTML is served.
  167. #html_use_opensearch = ''
  168. # This is the file name suffix for HTML files (e.g. ".xhtml").
  169. #html_file_suffix = None
  170. # Language to be used for generating the HTML full-text search index.
  171. # Sphinx supports the following languages:
  172. # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
  173. # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
  174. #html_search_language = 'en'
  175. # A dictionary with options for the search language support, empty by default.
  176. # Now only 'ja' uses this config value
  177. #html_search_options = {'type': 'default'}
  178. # The name of a javascript file (relative to the configuration directory) that
  179. # implements a search results scorer. If empty, the default will be used.
  180. #html_search_scorer = 'scorer.js'
  181. # Output file base name for HTML help builder.
  182. #htmlhelp_basename = ''
  183. # https://myst-parser.readthedocs.io/en/latest/syntax/cross-referencing.html#handling-invalid-references
  184. suppress_warnings = ["myst.xref_missing"]