/conf.py

https://github.com/ZoomQuiet/sphinx-doc-zh · Python · 100 lines · 75 code · 19 blank · 6 comment · 2 complexity · 203363398743225468a86a728d1a4238 MD5 · raw file

  1. # -*- coding: utf-8 -*-
  2. #
  3. # Sphinx documentation build configuration file
  4. import re
  5. import sphinx
  6. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo',
  7. 'sphinx.ext.autosummary', 'sphinx.ext.extlinks']
  8. master_doc = 'contents'
  9. templates_path = ['_templates']
  10. exclude_patterns = ['_build']
  11. project = 'Sphinx'
  12. copyright = '2007-2010, Georg Brandl'
  13. version = sphinx.__released__
  14. release = version
  15. show_authors = True
  16. html_theme = 'sphinxdoc'
  17. modindex_common_prefix = ['sphinx.']
  18. html_static_path = ['_static']
  19. html_index = 'index.html'
  20. html_sidebars = {'index': ['indexsidebar.html', 'searchbox.html']}
  21. html_additional_pages = {'index': 'index.html'}
  22. html_use_opensearch = 'http://sphinx.pocoo.org'
  23. htmlhelp_basename = 'Sphinxdoc'
  24. epub_theme = 'epub'
  25. epub_basename = 'sphinx'
  26. epub_author = 'Georg Brandl'
  27. epub_publisher = 'http://sphinx.pocoo.org/'
  28. epub_scheme = 'url'
  29. epub_identifier = epub_publisher
  30. epub_pre_files = [('index.html', 'Welcome')]
  31. epub_exclude_files = ['_static/opensearch.xml', '_static/doctools.js',
  32. '_static/jquery.js', '_static/searchtools.js', '_static/underscore.js',
  33. '_static/basic.css', 'search.html']
  34. latex_documents = [('contents', 'sphinx.tex', 'Sphinx Documentation',
  35. 'Georg Brandl', 'manual', 1)]
  36. latex_logo = '_static/sphinx.png'
  37. latex_elements = {
  38. 'fontpkg': '\\usepackage{palatino}',
  39. }
  40. autodoc_member_order = 'groupwise'
  41. todo_include_todos = True
  42. extlinks = {'duref': ('http://docutils.sourceforge.net/docs/ref/rst/'
  43. 'restructuredtext.html#%s', ''),
  44. 'durole': ('http://docutils.sourceforge.net/docs/ref/rst/'
  45. 'roles.html#%s', ''),
  46. 'dudir': ('http://docutils.sourceforge.net/docs/ref/rst/'
  47. 'directives.html#%s', '')}
  48. man_pages = [
  49. ('contents', 'sphinx-all', 'Sphinx documentation generator system manual',
  50. 'Georg Brandl', 1),
  51. ('man/sphinx-build', 'sphinx-build', 'Sphinx documentation generator tool',
  52. '', 1),
  53. ('man/sphinx-quickstart', 'sphinx-quickstart', 'Sphinx documentation '
  54. 'template generator', '', 1),
  55. ]
  56. # We're not using intersphinx right now, but if we did, this would be part of
  57. # the mapping:
  58. intersphinx_mapping = {'python': ('http://docs.python.org/dev', None)}
  59. # -- Extension interface -------------------------------------------------------
  60. from sphinx import addnodes
  61. event_sig_re = re.compile(r'([a-zA-Z-]+)\s*\((.*)\)')
  62. def parse_event(env, sig, signode):
  63. m = event_sig_re.match(sig)
  64. if not m:
  65. signode += addnodes.desc_name(sig, sig)
  66. return sig
  67. name, args = m.groups()
  68. signode += addnodes.desc_name(name, name)
  69. plist = addnodes.desc_parameterlist()
  70. for arg in args.split(','):
  71. arg = arg.strip()
  72. plist += addnodes.desc_parameter(arg, arg)
  73. signode += plist
  74. return name
  75. def setup(app):
  76. from sphinx.ext.autodoc import cut_lines
  77. app.connect('autodoc-process-docstring', cut_lines(4, what=['module']))
  78. app.add_description_unit('confval', 'confval',
  79. objname='configuration value',
  80. indextemplate='pair: %s; configuration value')
  81. app.add_description_unit('event', 'event', 'pair: %s; event', parse_event)