1"""This module cooks up a docstring when imported. Its only purpose is to
2be displayed in the sphinx documentation.
3"""
4
5from __future__ import annotations
6
7import typing
8from collections import defaultdict
9
10from ..core import Add, Eq, Symbol
11from ..printing import latex
12from ..utilities import default_sort_key
13from .meijerint import _create_lookup_table
14
15
16t: dict[tuple[type, ...], list[typing.Any]] = defaultdict(list)
17_create_lookup_table(t)
18
19doc = ''
20
21for about, category in sorted(t.items(), key=default_sort_key):
22    if about == ():
23        doc += 'Elementary functions:\n\n'
24    else:
25        doc += ('Functions involving ' +
26                ', '.join(f'`{latex(list(category[0][0].atoms(func))[0])}`'
27                          for func in about) + ':\n\n')
28    for formula, gs, cond, hint in category:
29        if not isinstance(gs, list):
30            g = Symbol('\\text{generated}')
31        else:
32            g = Add(*[fac*f for (fac, f) in gs])
33        obj = Eq(formula, g)
34        if cond is True:
35            cond = ''
36        else:
37            cond = f',\\text{{ if }} {latex(cond)}'
38        doc += f'.. math::\n  {latex(obj)}{cond}\n\n'
39
40__doc__ = doc
41