From a724c9482009e3749b0377e376ce64763c3437ec Mon Sep 17 00:00:00 2001 From: Tom Eulenfeld Date: Thu, 19 Sep 2024 13:44:33 +0200 Subject: [PATCH] docs: populate autodock_mock_imports with all modules --- anchorna/io.py | 4 +--- docs/conf.py | 40 ++++++++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/anchorna/io.py b/anchorna/io.py index 0e1dc12..ffe3657 100644 --- a/anchorna/io.py +++ b/anchorna/io.py @@ -165,14 +165,12 @@ def _make_rgb_transparent(rgb, bg_rgb, alpha): for (c1, c2) in zip(to_rgb(rgb), to_rgb(bg_rgb))] -cols = list(mcolors.TABLEAU_COLORS.values()) -to_hex(cols[0], 0.3) - def jalview_features(anchors, mode='aa', score_use_fluke=None): """ Write anchors to Jalview feature file """ assert mode in ('nt', 'cds', 'aa') + cols = list(mcolors.TABLEAU_COLORS.values()) anchors = sorted(anchors, key=lambda a: a.guide.start) content = [] header = [] diff --git a/docs/conf.py b/docs/conf.py index 71027e9..b4bfc79 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,36 +1,44 @@ # Configuration file for the Sphinx documentation builder. -# Build doc locally with with +# Build doc locally with # sphinx-build -anE -c . src _build -import sys -import os - -os.environ['SPHINX_BUILD'] = '1' - - -def version(): +def parse_version(): from pathlib import Path import re init_path = Path(__file__).parent.parent / 'anchorna/__init__.py' with open(init_path) as f: content = f.read() - match = re.search("""__version__\s*=\s*['"]([^\s]+)['"]""", content) + regex = r"""__version__\s*=\s*['"]([^\s]+)['"]""" + match = re.search(regex, content) if match: return match.group(1) +def parse_imports(): + from pathlib import Path + import re + root_path = Path(__file__).parent.parent / 'anchorna/' + root_path = Path('/home/gi48zar/dev/anchorna/anchorna/') + regex = r'^\s*import\s+(\w+)(?:.\w+)*|^\s*from\s+(\w+)(?:.\w+)*\s+import' + modules = set() + for fname in root_path.glob('**/*.py'): + with open(fname) as f: + content = f.read() + for match in re.finditer(regex, content, flags=re.MULTILINE): + modules |= set(match.groups()) + modules -= {None, 'anchorna'} + return sorted(modules) + + project = 'AnchoRNA' copyright = '2024, Tom Eulenfeld' author = 'Tom Eulenfeld' -version = version() +version = parse_version() -### General configuration -# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration default_role = 'py:obj' templates_path = ['_templates'] exclude_patterns = ['_build'] -# Add any Sphinx extension module names here extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.intersphinx', @@ -43,11 +51,11 @@ def version(): 'private-members': True, 'show-inheritance': True, } +autodoc_mock_imports = parse_imports() +print(f'set {autodoc_mock_imports=}') -autodoc_mock_imports = ['sugar', 'tqdm'] - -html_theme = 'furo' html_title = f'AnchoRNA
v{version}
documentation' +html_theme = 'furo' html_theme_options = { 'footer_icons' : [], 'top_of_page_buttons': [],