Changeset 4213 for trunk/docs/source


Ignore:
Timestamp:
Dec 19, 2019 11:04:03 PM (2 years ago)
Author:
toby
Message:

multiple small changes to allow docs build under 3.x

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/source/conf.py

    r4205 r4213  
    1212
    1313import sys, os
    14 # set up dummy packages for misc imports not on readthedocs
    15 from mock import Mock as MagicMock
    16 class wx(MagicMock):
    17     #@classmethod
    18     #def __getattr__(cls, name):
    19     #    return wx()
    20     Frame = Menu = Panel = Dialog = CheckBox = Choice = ComboBox = object
    21     Button = PyValidator = TextCtrl = TreeCtrl = object
    22     DEFAULT_DIALOG_STYLE = RESIZE_BORDER = CENTRE = OK = CANCEL = True
    23     ID_ANY = -1
    24     def __getitem__(self,*args):
    25         return '3.0.0'
    26     class grid(object):
    27         PyGridTableBase = PyGridCellEditor = Grid = object
    28     class html(object):
    29         HtmlWindow = object
    30     class aui(MagicMock):
    31         AuiNotebook = HtmlWindow = object
    32     class lib(MagicMock):
    33         class scrolledpanel(MagicMock):
    34             ScrolledPanel = object
    35         class gridmovers(MagicMock): pass
    36         class colourselect(MagicMock): pass
    37         class resizewidget(MagicMock): pass
    38         class mixins(MagicMock):
    39             class listctrl(MagicMock):
    40                 ListCtrlAutoWidthMixin = object
    41                 TextEditMixin = object
    42 
    43 sys.modules.update({'wx':wx(),
    44     'wx.aui':wx.aui(),
    45     'wx.html':wx.html(),
    46         'wx.grid':wx.grid(),
    47         'wx.lib':wx.lib(),
    48         'wx.wizard':wx.grid(),
    49         'wx.glcanvas':wx.lib(),
    50         'wx.lib.scrolledpanel':wx.lib.scrolledpanel(),
    51         'wx.lib.gridmovers':wx.lib.gridmovers(),
    52         'wx.lib.colourselect':wx.lib.gridmovers(),
    53         'wx.lib.resizewidget':wx.lib.resizewidget(),
    54         'wx.lib.mixins':wx.lib.mixins(),
    55         'wx.lib.mixins.listctrl':wx.lib.mixins.listctrl()})
    56 wx.aui.AUI_NB_TOP = 0
    57 wx.aui.AUI_NB_SCROLL_BUTTONS = 0
    58 
    59 class numpy(MagicMock):
    60     pi = 3.0
    61     def log(self,*args): return 0
    62     def sqrt(self,*args): return 1
    63     class ma(MagicMock):pass
    64     class linalg(MagicMock):pass
    65 sys.modules.update({'numpy':numpy()})
    66 sys.modules.update({'numpy.ma':numpy.ma()})
    67 sys.modules.update({'numpy.linalg':numpy.linalg()})
    68 sys.modules.update({'numpy.fft':numpy.linalg()})
    69 
    70 class scipy(MagicMock):
    71     class optimize(MagicMock):pass
    72 sys.modules.update({'scipy':scipy()})
    73 sys.modules.update({'scipy.optimize':scipy.optimize()})
    74 sys.modules.update({'scipy.stats':scipy.optimize()})
    75 sys.modules.update({'scipy.interpolate':scipy.optimize()})
    76 sys.modules.update({'scipy.special':scipy.optimize()})
    77 sys.modules.update({'scipy.misc':scipy.optimize()})
    78 sys.modules.update({'scipy.signal':scipy.optimize()})
    79 sys.modules.update({'scipy.cluster':scipy.optimize()})
    80 sys.modules.update({'scipy.cluster.vq':scipy.optimize()})
    81 
    82 class OpenGL(MagicMock):
    83     class GL(MagicMock):pass
    84     class GLU(MagicMock):pass
    85 sys.modules.update({'OpenGL':OpenGL()})
    86 sys.modules.update({'OpenGL.GL':OpenGL.GL()})
    87 sys.modules.update({'OpenGL.GLU':OpenGL.GLU()})
    88 sys.modules.update({'OpenGL.GLE':OpenGL.GL()})
    89 
    90 class Mock(MagicMock):
    91     @classmethod
    92     def __getattr__(cls, name):
    93         return Mock()
    94 
    95 MOCK_MODULES = [
    96                 'pypowder', 'pyspg', 'pytexture', 'polymask', 'fellipse',
    97                 'matplotlib', 'matplotlib.backends', 'matplotlib.backends.backend_wx',
    98                 'matplotlib.colors',
    99                 'matplotlib.backends.backend_wxagg','pylab','matplotlib.collections',
    100                 'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.mplot3d.axes3d',
    101                 'winreg','unpack_cbf','h5py'
    102                 ]
    103 sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
    10414
    10515# If extensions (or modules to document with autodoc) are in another directory,
     
    11121sys.path.insert(1, os.path.abspath(os.path.join('..', '..','imports')))
    11222#print(sys.path)
    113 # import all files to set version number
     23# scan all files to get version number
    11424import glob
    115 for fil in glob.glob(os.path.abspath(os.path.join('..', '..','*.py'))):
    116     pkg = os.path.splitext(os.path.split(fil)[1])[0]
     25version = 0
     26for fil in (glob.glob(os.path.abspath(os.path.join('..', '..','*.py')))+
     27    glob.glob(os.path.abspath(os.path.join('..', '..','exports','*.py')))+
     28    glob.glob(os.path.abspath(os.path.join('..', '..','imports','*.py')))):
     29    fp = open(fil,'r')
     30    c = fp.read()
     31    fp.close()
     32    s = c.find('SetVersionNumber')
     33    if s<0: continue
     34    if c.find('$Revision:',s,s+50)<0: continue
    11735    try:
    118         exec('import '+pkg)
     36        v = int(c[c.find('(',s,s+40):c.find(')',s,s+50)].split()[1])
     37        version = max(version,v)
    11938    except:
    12039        pass
    121 import GSASIIpath
    122 version = GSASIIpath.GetVersionNumber()
    12340print('Found highest version as {}'.format(version))
    12441# -- General configuration -----------------------------------------------------
     
    351268# How to display URL addresses: 'footnote', 'no', or 'inline'.
    352269#texinfo_show_urls = 'footnote'
     270
     271# set up dummy packages for misc imports not on readthedocs
     272autodoc_mock_imports = "wx numpy scipy matplotlib pillow OpenGL h5py".split()
Note: See TracChangeset for help on using the changeset viewer.