source: orange/docs/conf.py @ 11036:9b5efef1d9a2

Revision 11036:9b5efef1d9a2, 10.7 KB checked in by Miha Stajdohar <miha.stajdohar@…>, 17 months ago (diff)

Mock more modules.

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