1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
|
# tifffile/docs/make.py
"""Make documentation for tifffile package using Sphinx."""
import os
import sys
from sphinx.cmd.build import main
here = os.path.dirname(__file__)
sys.path.insert(0, os.path.split(here)[0])
path = os.environ.get('PATH')
if path:
os.environ['PATH'] = os.path.join(sys.exec_prefix, 'Scripts') + ';' + path
import tifffile # noqa
members = [
'imread',
'imwrite',
'memmap',
'TiffWriter',
'TiffFile',
# 'TiffFileError',
'TiffFormat',
'TiffPage',
'TiffFrame',
'TiffPages',
'TiffTag',
'TiffTags',
'TiffTagRegistry',
'TiffPageSeries',
'TiffSequence',
'FileSequence',
'zarr.ZarrStore',
'zarr.ZarrTiffStore',
'zarr.ZarrFileSequenceStore',
# Constants
'DATATYPE',
'SAMPLEFORMAT',
'PLANARCONFIG',
'COMPRESSION',
'PREDICTOR',
'EXTRASAMPLE',
'FILETYPE',
'PHOTOMETRIC',
'RESUNIT',
'CHUNKMODE',
'TIFF',
# classes
'FileHandle',
'OmeXml',
# 'OmeXmlError',
'Timer',
'NullContext',
'StoredShape',
'TiledSequence',
# functions
'logger',
'repeat_nd',
'natural_sorted',
'parse_filenames',
'matlabstr2py',
'strptime',
'imagej_metadata_tag',
'imagej_description',
# 'read_scanimage_metadata',
'read_micromanager_metadata',
'read_ndtiff_index',
'create_output',
'hexdump',
'xml2dict',
'tiffcomment',
'tiff2fsspec',
'lsm2bin',
'validate_jhove',
'imshow',
'.geodb',
]
title = f'tifffile {tifffile.__version__}'
underline = '=' * len(title)
members_ = []
for name in members:
if not name:
continue
if '.' in name[1:]:
name = name.rsplit('.', 1)[-1]
members_.append(name.replace('.', '').lower())
memberlist = '\n '.join(members_)
with open(here + '/index.rst', 'w') as fh:
fh.write(f""".. tifffile documentation
.. currentmodule:: tifffile
{title}
{underline}
.. automodule:: tifffile
.. toctree::
:hidden:
:maxdepth: 2
genindex
license
revisions
examples
.. toctree::
:hidden:
:maxdepth: 2
{memberlist}
""")
with open(here + '/genindex.rst', 'w') as fh:
fh.write("""
Index
=====
""")
with open(here + '/license.rst', 'w') as fh:
fh.write("""
License
=======
.. include:: ../LICENSE
""")
with open(here + '/examples.rst', 'w') as fh:
fh.write("""
Examples
========
See `#examples <index.html#examples>`_.
""")
with open(here + '/revisions.rst', 'w') as fh:
fh.write(""".. include:: ../CHANGES.rst""")
with open('tiff.rst', 'w') as fh:
fh.write("""
.. currentmodule:: tifffile
TIFF
====
.. autoclass:: tifffile.TIFF
:members:
.. autoclass:: tifffile._TIFF
:members:
""")
automodule = """.. currentmodule:: {module}
{name}
{size}
.. automodule:: {module}.{name}
:members:
"""
autoclass = """.. currentmodule:: {module}
{name}
{size}
.. autoclass:: {module}.{name}
:members:
"""
automethod = """.. currentmodule:: {module}
{name}
{size}
.. autofunction:: {name}
"""
for name in members:
if not name or name == 'TIFF':
continue
if '.' in name[1:]:
module, name = name.rsplit('.', 1)
module = f'tifffile.{module}'
else:
module = 'tifffile'
if name[0] == '.':
template = automodule
name = name[1:]
elif name[0].isupper():
template = autoclass
else:
template = automethod
size = '=' * len(name)
with open(f'{here}/{name.lower()}.rst', 'w') as fh:
fh.write(template.format(module=module, name=name, size=size))
main(['-b', 'html', here, here + '/html'])
os.system('start html/index.html')
|