You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

conf.py 9.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. # -*- coding: utf-8 -*-
  2. #
  3. # django-oscar documentation build configuration file, created by
  4. # sphinx-quickstart on Mon Feb 7 13:16:33 2011.
  5. #
  6. # This file is execfile()d with the current directory set to its containing dir.
  7. #
  8. # Note that not all possible configuration values are present in this
  9. # autogenerated file.
  10. #
  11. # All configuration values have a default; values that are commented out
  12. # serve to show the default.
  13. # If extensions (or modules to document with autodoc) are in another directory,
  14. # add these directories to sys.path here. If the directory is relative to the
  15. # documentation root, use os.path.abspath to make it absolute, like shown here.
  16. #sys.path.insert(0, os.path.abspath('.'))
  17. # Add the project root and sandbox root to the path
  18. import sys
  19. import os
  20. oscar_folder = os.path.realpath(
  21. os.path.join(os.path.dirname(__file__), '../..'))
  22. sandbox_folder = os.path.realpath(
  23. os.path.join(os.path.dirname(__file__), '../../sandbox'))
  24. sys.path.append(oscar_folder)
  25. sys.path.append(sandbox_folder)
  26. # Specify settings module (which will be picked up from the sandbox)
  27. os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings_sphinx')
  28. import django
  29. django.setup()
  30. # -- General configuration -----------------------------------------------------
  31. # If your documentation needs a minimal Sphinx version, state it here.
  32. #needs_sphinx = '1.0'
  33. # Add any Sphinx extension module names here, as strings. They can be extensions
  34. # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
  35. extensions = [
  36. 'sphinx.ext.autodoc',
  37. 'sphinx.ext.todo',
  38. 'sphinx.ext.coverage',
  39. 'sphinx.ext.viewcode',
  40. 'sphinxcontrib.napoleon',
  41. 'sphinx_issues',
  42. ]
  43. # Add any paths that contain templates here, relative to this directory.
  44. templates_path = ['_templates']
  45. # The suffix of source filenames.
  46. source_suffix = '.rst'
  47. # The encoding of source files.
  48. #source_encoding = 'utf-8-sig'
  49. # The master toctree document.
  50. master_doc = 'index'
  51. # General information about the project.
  52. project = 'django-oscar'
  53. # The version info for the project you're documenting, acts as replacement for
  54. # |version| and |release|, also used in various other places throughout the
  55. # built documents.
  56. #
  57. # The short X.Y version.
  58. from oscar import get_version, get_short_version
  59. version = get_version()
  60. release = get_short_version()
  61. # The language for content autogenerated by Sphinx. Refer to documentation
  62. # for a list of supported languages.
  63. #language = None
  64. # There are two options for replacing |today|: either, you set today to some
  65. # non-false value, then it is used:
  66. #today = ''
  67. # Else, today_fmt is used as the format for a strftime call.
  68. #today_fmt = '%B %d, %Y'
  69. # List of patterns, relative to source directory, that match files and
  70. # directories to ignore when looking for source files.
  71. exclude_patterns = ['_draft']
  72. # The reST default role (used for this markup: `text`) to use for all documents.
  73. #default_role = None
  74. # If true, '()' will be appended to :func: etc. cross-reference text.
  75. #add_function_parentheses = True
  76. # If true, the current module name will be prepended to all description
  77. # unit titles (such as .. function::).
  78. #add_module_names = True
  79. # If true, sectionauthor and moduleauthor directives will be shown in the
  80. # output. They are ignored by default.
  81. #show_authors = False
  82. # The name of the Pygments (syntax highlighting) style to use.
  83. pygments_style = 'sphinx'
  84. # A list of ignored prefixes for module index sorting.
  85. #modindex_common_prefix = []
  86. # Github repo for sphinx-issues
  87. issues_github_path = 'django-oscar/django-oscar'
  88. # -- Options for HTML output ---------------------------------------------------
  89. # The theme to use for HTML and HTML Help pages. See the documentation for
  90. # a list of builtin themes.
  91. on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
  92. # Use RTD theme locally
  93. html_theme = 'default'
  94. if not on_rtd:
  95. import sphinx_rtd_theme
  96. html_theme = 'sphinx_rtd_theme'
  97. html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
  98. # Theme options are theme-specific and customize the look and feel of a theme
  99. # further. For a list of options available for each theme, see the
  100. # documentation.
  101. #html_theme_options = {}
  102. # Add any paths that contain custom themes here, relative to this directory.
  103. #html_theme_path = []
  104. # The name for this set of Sphinx documents. If None, it defaults to
  105. # "<project> v<release> documentation".
  106. #html_title = None
  107. # A shorter title for the navigation bar. Default is the same as html_title.
  108. #html_short_title = None
  109. # The name of an image file (relative to this directory) to place at the top
  110. # of the sidebar.
  111. #html_logo = None
  112. # The name of an image file (within the static path) to use as favicon of the
  113. # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
  114. # pixels large.
  115. #html_favicon = None
  116. # Add any paths that contain custom static files (such as style sheets) here,
  117. # relative to this directory. They are copied after the builtin static files,
  118. # so a file named "default.css" will overwrite the builtin "default.css".
  119. #html_static_path = ['_static']
  120. # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
  121. # using the given strftime format.
  122. #html_last_updated_fmt = '%b %d, %Y'
  123. # If true, SmartyPants will be used to convert quotes and dashes to
  124. # typographically correct entities.
  125. #html_use_smartypants = True
  126. # Custom sidebar templates, maps document names to template names.
  127. #html_sidebars = {}
  128. # Additional templates that should be rendered to pages, maps page names to
  129. # template names.
  130. #html_additional_pages = {}
  131. # If false, no module index is generated.
  132. #html_domain_indices = True
  133. # If false, no index is generated.
  134. #html_use_index = True
  135. # If true, the index is split into individual pages for each letter.
  136. #html_split_index = False
  137. # If true, links to the reST sources are added to the pages.
  138. #html_show_sourcelink = True
  139. # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
  140. #html_show_sphinx = True
  141. # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
  142. #html_show_copyright = True
  143. # If true, an OpenSearch description file will be output, and all pages will
  144. # contain a <link> tag referring to it. The value of this option must be the
  145. # base URL from which the finished HTML is served.
  146. #html_use_opensearch = ''
  147. # This is the file name suffix for HTML files (e.g. ".xhtml").
  148. #html_file_suffix = None
  149. # Output file base name for HTML help builder.
  150. htmlhelp_basename = 'django-oscardoc'
  151. # -- Options for LaTeX output --------------------------------------------------
  152. # The paper size ('letter' or 'a4').
  153. #latex_paper_size = 'letter'
  154. # The font size ('10pt', '11pt' or '12pt').
  155. #latex_font_size = '10pt'
  156. # Grouping the document tree into LaTeX files. List of tuples
  157. # (source start file, target name, title, author, documentclass [howto/manual]).
  158. latex_documents = [
  159. ('index', 'django-oscar.tex', 'django-oscar Documentation',
  160. 'David Winterbottom', 'manual'),
  161. ]
  162. # The name of an image file (relative to this directory) to place at the top of
  163. # the title page.
  164. #latex_logo = None
  165. # For "manual" documents, if this is true, then toplevel headings are parts,
  166. # not chapters.
  167. #latex_use_parts = False
  168. # If true, show page references after internal links.
  169. #latex_show_pagerefs = False
  170. # If true, show URL addresses after external links.
  171. #latex_show_urls = False
  172. # Additional stuff for the LaTeX preamble.
  173. #latex_preamble = ''
  174. # Documents to append as an appendix to all manuals.
  175. #latex_appendices = []
  176. # If false, no module index is generated.
  177. #latex_domain_indices = True
  178. # -- Options for manual page output --------------------------------------------
  179. # One entry per manual page. List of tuples
  180. # (source start file, name, description, authors, manual section).
  181. man_pages = [
  182. ('index', 'django-oscar', 'django-oscar Documentation',
  183. ['David Winterbottom'], 1)
  184. ]
  185. # Autodoc settings
  186. autoclass_content = 'class'
  187. # Better documenting of Django models
  188. # See http://djangosnippets.org/snippets/2533/
  189. import inspect
  190. from django.utils.html import strip_tags
  191. from django.utils.encoding import force_text
  192. def process_docstring(app, what, name, obj, options, lines):
  193. # This causes import errors if left outside the function
  194. from django.db import models
  195. # Only look at objects that inherit from Django's base model class
  196. if inspect.isclass(obj) and issubclass(obj, models.Model):
  197. # Ignore abstract models
  198. if not hasattr(obj._meta, '_fields'):
  199. return lines
  200. # Grab the field list from the meta class
  201. fields = obj._meta._fields()
  202. for field in fields:
  203. # Decode and strip any html out of the field's help text
  204. help_text = strip_tags(force_text(field.help_text))
  205. # Decode and capitalize the verbose name, for use if there isn't
  206. # any help text
  207. verbose_name = force_text(field.verbose_name).capitalize()
  208. if help_text:
  209. # Add the model field to the end of the docstring as a param
  210. # using the help text as the description
  211. lines.append(':param %s: %s' % (field.attname, help_text))
  212. else:
  213. # Add the model field to the end of the docstring as a param
  214. # using the verbose name as the description
  215. lines.append(':param %s: %s' % (field.attname, verbose_name))
  216. # Add the field's type to the docstring
  217. lines.append(':type %s: %s' % (field.attname, type(field).__name__))
  218. # Return the extended docstring
  219. return lines
  220. def setup(app):
  221. # Register the docstring processor with sphinx
  222. app.connect('autodoc-process-docstring', process_docstring)