conf.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. # -- Path setup --------------------------------------------------------------
  7. # If extensions (or modules to document with autodoc) are in another directory,
  8. # add these directories to sys.path here. If the directory is relative to the
  9. # documentation root, use os.path.abspath to make it absolute, like shown here.
  10. import os
  11. import sphinx_rtd_theme
  12. import sys
  13. import datetime
  14. from pygments.lexers.web import PhpLexer
  15. from sphinx.highlighting import lexers
  16. from subprocess import Popen, PIPE
  17. def get_version():
  18. if os.environ.get('READTHEDOCS') == 'True':
  19. return os.environ.get('READTHEDOCS_VERSION')
  20. pipe = Popen('git branch | 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. # -- Project information -----------------------------------------------------
  27. project = 'ramsey/uuid'
  28. copyright = '2012-{year}, Ben Ramsey'.format(year = datetime.date.today().strftime('%Y'))
  29. author = 'Ben Ramsey'
  30. version = get_version().strip()
  31. release = version
  32. today = datetime.date.today().strftime('%Y-%m-%d')
  33. # -- General configuration ---------------------------------------------------
  34. master_doc = 'index'
  35. highlight_language = 'php'
  36. # enable highlighting for PHP code not between ``<?php ... ?>`` by default
  37. lexers['php'] = PhpLexer(startinline=True)
  38. lexers['php-annotations'] = PhpLexer(startinline=True)
  39. # Add any Sphinx extension module names here, as strings. They can be
  40. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
  41. # ones.
  42. extensions = [
  43. 'sphinx.ext.autodoc',
  44. 'sphinx.ext.todo',
  45. 'sphinxcontrib.phpdomain',
  46. ]
  47. # Add any paths that contain templates here, relative to this directory.
  48. templates_path = ['_templates']
  49. # List of patterns, relative to source directory, that match files and
  50. # directories to ignore when looking for source files.
  51. # This pattern also affects html_static_path and html_extra_path.
  52. exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
  53. pygments_style = 'sphinx'
  54. # -- Options for HTML output -------------------------------------------------
  55. # The theme to use for HTML and HTML Help pages. See the documentation for
  56. # a list of builtin themes.
  57. #
  58. html_theme = "sphinx_rtd_theme"
  59. html_theme_options = {
  60. 'collapse_navigation': False,
  61. 'display_version': False
  62. }
  63. # Add any paths that contain custom static files (such as style sheets) here,
  64. # relative to this directory. They are copied after the builtin static files,
  65. # so a file named "default.css" will overwrite the builtin "default.css".
  66. html_static_path = ['_static']
  67. html_title = "ramsey/uuid %s Manual" % get_version()
  68. html_show_sphinx = False
  69. htmlhelp_basename = 'ramsey-uuid-doc'
  70. html_context = {
  71. "display_github": True,
  72. "github_user": "ramsey",
  73. "github_repo": "uuid",
  74. "github_version": version,
  75. "conf_py_path": "/docs/",
  76. }
  77. current_year = datetime.date.today().strftime('%Y')
  78. rst_prolog = """
  79. .. |current_year| replace:: {0}
  80. """.format(current_year)