source: orange/docs/conf.py @ 11033:02f5ea354188

Revision 11033:02f5ea354188, 10.6 KB checked in by Miha Stajdohar <miha.stajdohar@…>, 17 months ago (diff)

Mock core.

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