Commits

Miha Stajdohar committed 8ad0a5f

Fixed docs.

  • Participants
  • Parent commits 5a10665

Comments (0)

Files changed (5)

 # All configuration values have a default; values that are commented out
 # serve to show the default.
 
-import sys, os, os.path
-import mock
+import imp, sys, os
+import numpydoc
 
-MOCK_MODULES = ['numpy', 'numpy.core', 'numpy.core.ma', 'scipy', 'scipy.stats', 'ma', 'linalg']
+class Mock(object):
+    def __init__(self, *args, **kwargs):
+        pass
+
+    def __call__(self, *args, **kwargs):
+        return Mock()
+
+    @classmethod
+    def __getattr__(cls, name):
+        if name in ('__file__', '__path__'):
+            return '/dev/null'
+        elif name[0] == name[0].upper():
+            mockType = type(name, (), {})
+            mockType.__module__ = __name__
+            return mockType
+        else:
+            return Mock()
+
+
+MOCK_MODULES = ['scipy', 'scipy.stats', 'scipy.sparse', 'scipy.optimize', 'scipy.linalg']
 for mod_name in MOCK_MODULES:
-    sys.modules[mod_name] = mock.Mock()
+    sys.modules[mod_name] = Mock()
 
-#rewrite formatargs function with different defaults
-sys.path.insert(0, os.path.dirname(__file__))
-import myinspect
-import sphinx.ext.autodoc
-import numpydoc
-sphinx.ext.autodoc.inspect = myinspect
-numpydoc.docscrape.inspect = myinspect
+module_setup = imp.load_source('module_setup', os.path.join(os.path.dirname(__file__), '..', '..', 'setup.py'))
+VERSION = module_setup.VERSION
+AUTHOR = module_setup.AUTHOR
+DOCUMENTATION_NAME = module_setup.DOCUMENTATION_NAME
 
-#disable deprecation decorators for the documentation
-os.environ["orange_no_deprecated_members"] = "1"
+TITLE = "%s v%s documentation" % (DOCUMENTATION_NAME, VERSION)
 
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
-sys.path.append(os.path.abspath('../../mm'))
+#sys.path.append(os.path.abspath('../../_modelmaps'))
 
 # -- General configuration -----------------------------------------------------
 
 master_doc = 'index'
 
 # General information about the project.
-project = u'Model Map'
-copyright = u'Miha Stajdohar, FRI UL'
+project = TITLE
+copyright = AUTHOR
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
 # built documents.
 #
 # The short X.Y version.
-version = '0.1'
+version = VERSION
 # The full version, including alpha/beta/rc tags.
-release = '0.1 beta'
+release = VERSION
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
 # documentation.
 #html_theme_options = {"collapsiblesidebar": "false"}
 
-if html_theme == "orange_theme":
-    html_theme_options.update({"orangeheaderfooter": "false"})
-
 # Add any paths that contain custom themes here, relative to this directory.
 #html_theme_path = ["../../sphinx-ext/themes"]
 
 # The name for this set of Sphinx documents.  If None, it defaults to
 # "<project> v<release> documentation".
-html_title = "Model Map Reference"
+html_title = TITLE
 
 # A shorter title for the navigation bar.  Default is the same as html_title.
 #html_short_title = None
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title, author, documentclass [howto/manual]).
 latex_documents = [
-  ('index', 'reference.tex', u'Reference',
-   u't', 'manual'),
+  ('index', 'addon.tex', TITLE,
+   AUTHOR, 'manual'),
 ]
 
 # The name of an image file (relative to this directory) to place at the top of
 # -- Options for Epub output ---------------------------------------------------
 
 # Bibliographic Dublin Core info.
-epub_title = u'Model Map Reference'
-epub_author = u'Miha Stajdohar'
-epub_publisher = u'Miha Stajdohar'
-epub_copyright = u'Miha Stajdohar, FRI UL'
+epub_title = TITLE
+epub_author = AUTHOR
 
 # The language of the text. It defaults to the language option
 # or en if the language is not set.
 
 # Example configuration for intersphinx: refer to the Python standard library.
 intersphinx_mapping = {'http://docs.python.org/': None}
-
-import types
-from sphinx.ext import autodoc
-
-def maybe_skip_member(app, what, name, obj, skip, options):
-    #print app, what, name, obj, skip, options
-
-    #allow class methods that begin with __ and end with __
-    if isinstance(obj, types.MethodType) \
-        and not isinstance(options.members, list) \
-        and name.startswith("__") \
-        and name.endswith("__") \
-        and (obj.__doc__ != None or options.get("undoc-members", False)):
-            return False
-
-class SingletonDocumenter(autodoc.ModuleLevelDocumenter):
-    """
-    Specialized Documenter subclass for singleton items.
-    """
-    objtype = 'singleton'
-    directivetype = 'data'
-
-    member_order = 40
-
-    @classmethod
-    def can_document_member(cls, member, membername, isattr, parent):
-        return isinstance(parent, autodoc.ModuleDocumenter) and isattr
-
-    def document_members(self, all_members=False):
-        pass
-
-    def add_content(self, more_content, no_docstring=False):
-        self.add_line(u'Singleton instance of :py:class:`~%s`.' % (self.object.__class__.__name__,), '<autodoc>')
-
-def setup(app):
-    app.connect('autodoc-skip-member', maybe_skip_member)
-    app.add_autodocumenter(SingletonDocumenter)

docs/rst/myinspect.py

-from inspect import *
-ofas = formatargspec
-
-def delete_while_accurate(s, accuracy=0.0000001):
-    """ Shortens a string containing a float
-    while still keeping the desired accuracy. """
-    orig = float(s)
-    cur = s
-    try:
-        while abs((float(cur[:-1])-orig)/orig) < accuracy:
-            cur = cur[:-1]
-    except:
-        pass
-    return cur
-
-def nfas(*args, **kwargs):
-
-    def fv(value):
-        if isinstance(value, float):
-            cand = str(value)
-            value = delete_while_accurate(cand)
-        return "=" + str(value)
-
-    if "formatvalue" not in kwargs and len(args) < 8:
-        kwargs["formatvalue"] = fv
-
-    return ofas(*args, **kwargs)
-
-formatargspec = nfas
-
-# inspect.getmembers from Python 2.7
-# In Python 2.6 there is try/except missing and function fails on C++-based classes if they define attributes
-# Example: AttributeError: 'Plot' object attribute 'animate_points' is an instance attribute
-def getmembers27(object, predicate=None):
-    """Return all members of an object as (name, value) pairs sorted by name.
-    Optionally, only return members that satisfy a given predicate."""
-    results = []
-    for key in dir(object):
-        try:
-            value = getattr(object, key)
-        except AttributeError:
-            continue
-        if not predicate or predicate(value):
-            results.append((key, value))
-    results.sort()
-    return results
-
-getmembers = getmembers27
-
-if __name__ == "__main__":
-    for a in [ "0", "0.", "-1.3", "1.30000000001" ]:
-        print a, "shorter:", delete_while_accurate(a)

examples/ensemble/parse_mm_forest.py

 from itertools import groupby
 from operator import itemgetter
 
-ROOT = "/home/miha/work/res/modelmaps"
-ROOT = "C:\\Users\\Miha\\work\\res\\modelmaps"
+ROOT = "/Users/miha/work/res/modelmaps"
+#ROOT = "C:\\Users\\Miha\\work\\res\\modelmaps"
 #ROOT = "/Network/Servers/xgridcontroller.private/lab/mihas/modelmaps"
 
 scores = {}

rtd_requirements.txt

-mock
+numpy
 numpydoc
--e hg+http://bitbucket.org/biolab/orange#egg=Orange
+-e hg+https://bitbucket.org/biolab/orange#egg=Orange
 
 DESCRIPTION = 'Orange Model Maps (space of prediction models) add-on for Orange data mining software package.'
 LONG_DESCRIPTION  = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read()
-AUTHOR = 'Miha Stajdohar, FRI UL'
+AUTHOR = 'Miha Stajdohar, University of Ljubljana, FRI'
 AUTHOR_EMAIL = 'miha.stajdohar@gmail.com'
 URL = 'http://orange.biolab.si/addons/'
 DOWNLOAD_URL = 'https://bitbucket.org/mstajdohar/orange-modelmaps/downloads'
     'Orange',
     'setuptools',
     'numpy',
-    'scipy',      # Requires Fortran compiler
+#    'scipy',      # Requires Fortran compiler
     'orange-network',
 ),
 
         'PyQt4',
     ),
     'reST': (
-        'mock',
         'numpydoc',
     ),
 }