source: orange/docs/conf.py @ 11034:2605ad9d7000

Revision 11034:2605ad9d7000, 10.6 KB checked in by Miha Stajdohar <miha.stajdohar@…>, 18 months ago (diff)

Extended Mock.

Line 
1# -*- coding: utf-8 -*-
2#
3# reference documentation build configuration file, created by
4# sphinx-quickstart on Wed Nov 17 12:52:23 2010.
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
14import imp, inspect, sys, os
15
16class Mock(object):
17    __all__ = []
18
19    def __init__(self, *args, **kwargs):
20        pass
21
22    def __call__(self, *args, **kwargs):
23        return Mock()
24
25    @classmethod
26    def __getattr__(cls, name):
27        if name in ('__file__', '__path__'):
28            return '/dev/null'
29        elif name[0] == name[0].upper():
30            mockType = type(name, (), {})
31            mockType.__module__ = __name__
32            return mockType
33        else:
34            return Mock()
35
36MOCK_MODULES = ['orange', 'orangeom', 'scipy', 'scipy.stats', 'scipy.sparse', 'scipy.optimize', 'scipy.linalg']
37for mod_name in MOCK_MODULES:
38    sys.modules[mod_name] = Mock()
39
40#rewrite formatargs function with different defaults
41PATH = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
42
43sys.path.insert(0, PATH)
44import myinspect
45import sphinx.ext.autodoc
46import numpydoc
47sphinx.ext.autodoc.inspect = myinspect
48numpydoc.docscrape.inspect = myinspect
49
50module_setup = imp.load_source('module_setup', os.path.join(PATH, '..', 'setup.py'))
51VERSION = module_setup.VERSION
52AUTHOR = module_setup.AUTHOR
53NAME = module_setup.NAME
54
55TITLE = "%s Documentation v%s" % (NAME, VERSION)
56
57#disable deprecation decorators for the documentation
58os.environ["orange_no_deprecated_members"] = "1"
59
60# If extensions (or modules to document with autodoc) are in another directory,
61# add these directories to sys.path here. If the directory is relative to the
62# documentation root, use os.path.abspath to make it absolute, like shown here.
63sys.path.append(os.path.abspath(os.path.join(PATH, "..")))
64import Orange
65
66# -- General configuration -----------------------------------------------------
67
68# Add any Sphinx extension module names here, as strings. They can be extensions
69# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
70extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.pngmath', 'sphinx.ext.ifconfig', 'numpydoc']
71
72
73# Numpydoc generates autosummary directives for all undocumented members. Orange documentation only includes documented
74# member, so _str_member_list is modified to return [] where a list of undocumented members is originally returned.
75numpydoc.docscrape_sphinx.SphinxDocString._str_member_list # if numpydoc changes, this line will cause an error
76numpydoc.docscrape_sphinx.SphinxDocString._str_member_list = lambda x, y : []
77
78
79# Add any paths that contain templates here, relative to this directory.
80templates_path = ['_templates']
81
82# The suffix of source filenames.
83source_suffix = '.rst'
84
85# The encoding of source files.
86#source_encoding = 'utf-8'
87
88# The master toctree document.
89master_doc = 'index'
90
91# General information about the project.
92project = TITLE
93copyright = AUTHOR
94
95# The version info for the project you're documenting, acts as replacement for
96# |version| and |release|, also used in various other places throughout the
97# built documents.
98#
99# The short X.Y version.
100version = VERSION
101# The full version, including alpha/beta/rc tags.
102release = VERSION
103
104# The language for content autogenerated by Sphinx. Refer to documentation
105# for a list of supported languages.
106#language = None
107
108# There are two options for replacing |today|: either, you set today to some
109# non-false value, then it is used:
110#today = ''
111# Else, today_fmt is used as the format for a strftime call.
112#today_fmt = '%B %d, %Y'
113
114# List of documents that shouldn't be included in the build.
115#unused_docs = []
116
117# List of directories, relative to source directory, that shouldn't be searched
118# for source files.
119exclude_trees = ['build', 'sphinx-ext']
120
121# The reST default role (used for this markup: `text`) to use for all documents.
122#default_role = None
123
124# If true, '()' will be appended to :func: etc. cross-reference text.
125#add_function_parentheses = True
126
127# If true, the current module name will be prepended to all description
128# unit titles (such as .. function::).
129#add_module_names = True
130
131# If true, sectionauthor and moduleauthor directives will be shown in the
132# output. They are ignored by default.
133#show_authors = False
134
135# The name of the Pygments (syntax highlighting) style to use.
136pygments_style = 'sphinx'
137
138# A list of ignored prefixes for module index sorting.
139#modindex_common_prefix = []
140
141
142# -- Options for HTML output ---------------------------------------------------
143
144# The theme to use for HTML and HTML Help pages.  Major themes that come with
145# Sphinx are currently 'default' and 'sphinxdoc'.
146html_theme = 'orange_theme'
147
148# Theme options are theme-specific and customize the look and feel of a theme
149# further.  For a list of options available for each theme, see the
150# documentation.
151html_theme_options = {"collapsiblesidebar": "false"}
152
153if html_theme == "orange_theme":
154    html_theme_options.update({"orangeheaderfooter": "false"})
155
156# Add any paths that contain custom themes here, relative to this directory.
157html_theme_path = [os.path.join(PATH, "sphinx-ext", "themes")]
158
159# The name for this set of Sphinx documents.  If None, it defaults to
160# "<project> v<release> documentation".
161html_title = TITLE
162
163# A shorter title for the navigation bar.  Default is the same as html_title.
164#html_short_title = None
165
166# The name of an image file (relative to this directory) to place at the top
167# of the sidebar.
168#html_logo = None
169
170# The name of an image file (within the static path) to use as favicon of the
171# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
172# pixels large.
173#html_favicon = None
174
175# Add any paths that contain custom static files (such as style sheets) here,
176# relative to this directory. They are copied after the builtin static files,
177# so a file named "default.css" will overwrite the builtin "default.css".
178html_static_path = []
179
180# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
181# using the given strftime format.
182#html_last_updated_fmt = '%b %d, %Y'
183
184# If true, SmartyPants will be used to convert quotes and dashes to
185# typographically correct entities.
186#html_use_smartypants = True
187
188# Custom sidebar templates, maps document names to template names.
189#html_sidebars = {}
190
191# Additional templates that should be rendered to pages, maps page names to
192# template names.
193#html_additional_pages = {}
194
195# If false, no module index is generated.
196#html_use_modindex = True
197
198# If false, no index is generated.
199#html_use_index = True
200
201# If true, the index is split into individual pages for each letter.
202#html_split_index = False
203
204# If true, links to the reST sources are added to the pages.
205#html_show_sourcelink = True
206
207# If true, an OpenSearch description file will be output, and all pages will
208# contain a <link> tag referring to it.  The value of this option must be the
209# base URL from which the finished HTML is served.
210#html_use_opensearch = ''
211
212# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
213#html_file_suffix = ''
214
215# Output file base name for HTML help builder.
216htmlhelp_basename = 'referencedoc'
217
218
219# -- Options for LaTeX output --------------------------------------------------
220
221# The paper size ('letter' or 'a4').
222#latex_paper_size = 'letter'
223
224# The font size ('10pt', '11pt' or '12pt').
225#latex_font_size = '10pt'
226
227# Grouping the document tree into LaTeX files. List of tuples
228# (source start file, target name, title, author, documentclass [howto/manual]).
229latex_documents = [
230  ('index', 'reference.tex', TITLE,
231   AUTHOR, 'manual'),
232]
233
234# The name of an image file (relative to this directory) to place at the top of
235# the title page.
236#latex_logo = None
237
238# For "manual" documents, if this is true, then toplevel headings are parts,
239# not chapters.
240#latex_use_parts = False
241
242# Additional stuff for the LaTeX preamble.
243#latex_preamble = ''
244
245# Documents to append as an appendix to all manuals.
246#latex_appendices = []
247
248# If false, no module index is generated.
249#latex_use_modindex = True
250
251# -- Options for Epub output ---------------------------------------------------
252
253# Bibliographic Dublin Core info.
254epub_title = TITLE
255epub_author = AUTHOR
256epub_publisher = AUTHOR
257epub_copyright = AUTHOR
258
259# The language of the text. It defaults to the language option
260# or en if the language is not set.
261epub_language = 'en'
262
263# The scheme of the identifier. Typical schemes are ISBN or URL.
264#epub_scheme = ''
265
266# The unique identifier of the text. This can be a ISBN number
267# or the project homepage.
268#epub_identifier = ''
269
270# A unique identification for the text.
271#epub_uid = ''
272
273# HTML files that should be inserted before the pages created by sphinx.
274# The format is a list of tuples containing the path and title.
275#epub_pre_files = []
276
277# HTML files that should be inserted after the pages created by sphinx.
278# The format is a list of tuples containing the path and title.
279#epub_post_files = []
280
281# A list of files that should not be packed into the epub file.
282epub_exclude_files = ["index.html", "genindex.html", "py-modindex.html", "search.html"]
283
284# The depth of the table of contents in toc.ncx.
285#epub_tocdepth = 3
286
287# Allow duplicate toc entries.
288#epub_tocdup = True
289
290# Example configuration for intersphinx: refer to the Python standard library.
291intersphinx_mapping = {'http://docs.python.org/': None}
292
293import types
294from sphinx.ext import autodoc
295
296def maybe_skip_member(app, what, name, obj, skip, options):
297    #print app, what, name, obj, skip, options
298
299    #allow class methods that begin with __ and end with __
300    if isinstance(obj, types.MethodType) \
301        and not isinstance(options.members, list) \
302        and name.startswith("__") \
303        and name.endswith("__") \
304        and (obj.__doc__ != None or options.get("undoc-members", False)):
305            return False
306
307class SingletonDocumenter(autodoc.ModuleLevelDocumenter):
308    """
309    Specialized Documenter subclass for singleton items.
310    """
311    objtype = 'singleton'
312    directivetype = 'data'
313
314    member_order = 40
315
316    @classmethod
317    def can_document_member(cls, member, membername, isattr, parent):
318        return isinstance(parent, autodoc.ModuleDocumenter) and isattr
319
320    def document_members(self, all_members=False):
321        pass
322
323    def add_content(self, more_content, no_docstring=False):
324        self.add_line(u'Singleton instance of :py:class:`~%s`.' % (self.object.__class__.__name__,), '<autodoc>')
325
326def setup(app):
327    app.connect('autodoc-skip-member', maybe_skip_member)
328    app.add_autodocumenter(SingletonDocumenter)
Note: See TracBrowser for help on using the repository browser.