|
| 1 | +# Configuration file for the Sphinx documentation builder. |
| 2 | +# |
| 3 | +# This file only contains a selection of the most common options. For a full |
| 4 | +# list see the documentation: |
| 5 | +# https://www.sphinx-doc.org/en/master/usage/configuration.html |
| 6 | + |
| 7 | +from datetime import datetime |
| 8 | +import os |
| 9 | +import sys |
| 10 | +from sphinx.util import logging |
| 11 | +logger = logging.getLogger(__name__) |
| 12 | + |
| 13 | + |
| 14 | +# -- Path setup -------------------------------------------------------------- |
| 15 | + |
| 16 | +# If extensions (or modules to document with autodoc) are in another directory, |
| 17 | +# add these directories to sys.path here. If the directory is relative to the |
| 18 | +# documentation root, use os.path.abspath to make it absolute, like shown here. |
| 19 | +# |
| 20 | +def get_scripts(directory): |
| 21 | + """ |
| 22 | + Find all the scripts available |
| 23 | + """ |
| 24 | + scripts = [] |
| 25 | + |
| 26 | + # Walk the tree. |
| 27 | + for root, directories, files in os.walk(directory): |
| 28 | + for filename in files: |
| 29 | + if filename.endswith(".py") and "_init_" not in filename: |
| 30 | + scripts.append(filename.replace('\n', '').replace(".py", "")) |
| 31 | + |
| 32 | + return scripts |
| 33 | + |
| 34 | + |
| 35 | +def find_scripts_entry(file_name): |
| 36 | + """ |
| 37 | + Find the entries corresponding to the scripts. |
| 38 | + """ |
| 39 | + |
| 40 | + with open(file_name) as file: |
| 41 | + lines = file.readlines() |
| 42 | + |
| 43 | + entries = [] |
| 44 | + for line in lines: |
| 45 | + if "automodule" in line: |
| 46 | + values = line.split(".. automodule::") |
| 47 | + entries.append(values[1].replace('\n', '').strip()) |
| 48 | + return entries |
| 49 | + |
| 50 | + |
| 51 | +def compare(list1, list2): |
| 52 | + """ |
| 53 | + Return the elements not common to both lists |
| 54 | + """ |
| 55 | + return [i for i in list1 + list2 if i not in list1 or i not in list2] |
| 56 | + |
| 57 | + |
| 58 | +# List of directories to scan and add the path. |
| 59 | +directories = ['../omero/analysis_scripts', '../omero/export_scripts', |
| 60 | + '../omero/figure_scripts', '../omero/import_scripts', |
| 61 | + '../omero/util_scripts'] |
| 62 | + |
| 63 | +scripts = [] |
| 64 | +entries = [] |
| 65 | +for d in directories: |
| 66 | + sys.path.insert(0, d) |
| 67 | + scripts.extend(get_scripts(d)) |
| 68 | + p = d.split("/") |
| 69 | + name = "%s.rst" % (p[len(p) - 1]) |
| 70 | + entries.extend(find_scripts_entry(name)) |
| 71 | + |
| 72 | +# Indicate the scripts not listed for documentation |
| 73 | +if len(entries) < len(scripts): |
| 74 | + common = compare(scripts, entries) |
| 75 | + logger.warning("automodule entries missing for:\n" + '\n'.join(common)) |
| 76 | + |
| 77 | +# -- Project information ----------------------------------------------------- |
| 78 | + |
| 79 | +# The master toctree document. |
| 80 | +master_doc = 'index' |
| 81 | + |
| 82 | +project = u'omero scripts' |
| 83 | +now = datetime.now() |
| 84 | +author = u'Open Microscopy Environment' |
| 85 | +copyright = u'2016-%d, %s ' % (now.year, author) |
| 86 | + |
| 87 | +# The full version, including alpha/beta/rc tags |
| 88 | +# The short X.Y version. |
| 89 | +version = '5.6.2.dev0' |
| 90 | +release = version |
| 91 | + |
| 92 | + |
| 93 | +# -- General configuration --------------------------------------------------- |
| 94 | + |
| 95 | +extlinks = {} |
| 96 | + |
| 97 | +# Add any Sphinx extension module names here, as strings. They can be |
| 98 | +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom |
| 99 | +# ones. |
| 100 | +extensions = [ |
| 101 | + 'sphinx.ext.autodoc', |
| 102 | + 'sphinx.ext.extlinks', |
| 103 | + 'sphinx_rtd_theme', |
| 104 | +] |
| 105 | + |
| 106 | +# Add any paths that contain templates here, relative to this directory. |
| 107 | +templates_path = ['_templates'] |
| 108 | + |
| 109 | +# List of patterns, relative to source directory, that match files and |
| 110 | +# directories to ignore when looking for source files. |
| 111 | +# This pattern also affects html_static_path and html_extra_path. |
| 112 | +exclude_patterns = [u'_build', 'Thumbs.db', '.DS_Store'] |
| 113 | + |
| 114 | +# Build docs without external dependencies |
| 115 | +autodoc_mock_imports = ['numpy', 'omero-py', 'omero', "PIL"] |
| 116 | + |
| 117 | +# The name of the Pygments (syntax highlighting) style to use. |
| 118 | +pygments_style = 'sphinx' |
| 119 | + |
| 120 | +# -- Options for HTML output ------------------------------------------------- |
| 121 | + |
| 122 | +# The theme to use for HTML and HTML Help pages. See the documentation for |
| 123 | +# a list of builtin themes. |
| 124 | +# |
| 125 | +html_theme = 'default' |
| 126 | + |
| 127 | +# Add any paths that contain custom static files (such as style sheets) here, |
| 128 | +# relative to this directory. They are copied after the builtin static files, |
| 129 | +# so a file named "default.css" will overwrite the builtin "default.css". |
| 130 | +html_static_path = [] |
| 131 | + |
| 132 | +# Grouping the document tree into LaTeX files. List of tuples |
| 133 | +# (source start file, target name, title, |
| 134 | +# author, documentclass [howto, manual, or own class]). |
| 135 | +latex_documents = [ |
| 136 | + (master_doc, 'OMEROScripts.tex', u'OMERO Scripts Documentation', |
| 137 | + author, 'manual'), |
| 138 | +] |
| 139 | + |
| 140 | + |
| 141 | +# -- Options for manual page output ------------------------------------------ |
| 142 | + |
| 143 | +# One entry per manual page. List of tuples |
| 144 | +# (source start file, name, description, authors, manual section). |
| 145 | +man_pages = [ |
| 146 | + (master_doc, 'omeroscripts', u'OMERO Scripts Documentation', |
| 147 | + [author], 1) |
| 148 | +] |
| 149 | + |
| 150 | + |
| 151 | +# -- Options for Texinfo output ---------------------------------------------- |
| 152 | + |
| 153 | +# Grouping the document tree into Texinfo files. List of tuples |
| 154 | +# (source start file, target name, title, author, |
| 155 | +# dir menu entry, description, category) |
| 156 | +texinfo_documents = [ |
| 157 | + (master_doc, 'OMEROScripts', u'OMERO Script Documentation', |
| 158 | + author, 'OMEROScripts', 'One line description of project.', |
| 159 | + 'Miscellaneous'), |
| 160 | +] |
| 161 | + |
| 162 | + |
| 163 | +# -- Options for Epub output ------------------------------------------------- |
| 164 | + |
| 165 | +# Bibliographic Dublin Core info. |
| 166 | +epub_title = project |
| 167 | + |
| 168 | +# The unique identifier of the text. This can be a ISBN number |
| 169 | +# or the project homepage. |
| 170 | +# |
| 171 | +# epub_identifier = '' |
| 172 | + |
| 173 | +# A unique identification for the text. |
| 174 | +# |
| 175 | +# epub_uid = '' |
| 176 | + |
| 177 | +# A list of files that should not be packed into the epub file. |
| 178 | +epub_exclude_files = ['search.html'] |
0 commit comments