conf.py 7.8 KB

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