#! /usr/bin/env bash

DOC_DIR=doc

maturin develop && pdoc --math pyadess -o $DOC_DIR

# Replace ugly numpy type hints

sed -i -e 's~<span class="n">Union<\/span><span class="p">\[<\/span><span class="n">numpy<\/span><span class="o">\.<\/span><span class="n">_typing<\/span><span class="o">\.<\/span><span class="n">_array_like<\/span><span class="o">\.<\/span><span class="n">_Buffer<\/span><span class="p">,<\/span> <span class="n">numpy<\/span><span class="o">\.<\/span><span class="n">_typing<\/span><span class="o">\.<\/span><span class="n">_array_like<\/span><span class="o">\.<\/span><span class="n">_SupportsArray<\/span><span class="p">\[<\/span><span class="n">numpy<\/span><span class="o">\.<\/span><span class="n">dtype<\/span><span class="p">\[<\/span><span class="n">Any<\/span><span class="p">\]\],<\/span> <span class="n">numpy<\/span><span class="o">\.<\/span><span class="n">_typing<\/span><span class="o">\.<\/span><span class="n">_nested_sequence<\/span><span class="o">\.<\/span><span class="n">_NestedSequence<\/span><span class="p">\[<\/span><span class="n">numpy<\/span><span class="o">\.<\/span><span class="n">_typing<\/span><span class="o">\.<\/span><span class="n">_array_like<\/span><span class="o">\.<\/span><span class="n">_SupportsArray<\/span><span class="p">\[<\/span><span class="n">numpy<\/span><span class="o">\.<\/span><span class="n">dtype<\/span><span class="p">\[<\/span><span class="n">Any<\/span><span class="p">\]\]\],<\/span> <span class="nb">complex<\/span><span class="p">,<\/span> <span class="nb">bytes<\/span><span class="p">,<\/span> <span class="nb">str<\/span><span class="p">,<\/span> <span class="n">numpy<\/span><span class="o">\.<\/span><span class="n">_typing<\/span><span class="o">\.<\/span><span class="n">_nested_sequence<\/span><span class="o">\.<\/span><span class="n">_NestedSequence<\/span><span class="p">\[<\/span><span class="nb">complex<\/span> <span class="o">|<\/span> <span class="nb">bytes<\/span> <span class="o">|<\/span> <span class="nb">str<\/span><span class="p">\]\]<\/span>~<span class="n">numpy.ArrayLike<\/span>~g' "$DOC_DIR/pyadess.html"

sed -i -e 's~<span class="n">numpy<\/span><span class="o">\.<\/span><span class="n">ndarray<\/span><span class="p">\[<\/span><span class="nb">tuple<\/span><span class="p">\[<\/span><span class="n">typing<\/span><span class="o">\.<\/span><span class="n">Any<\/span><span class="p">,<\/span> <span class="o">\.\.\.<\/span><span class="p">\],<\/span> <span class="n">numpy<\/span><span class="o">\.<\/span><span class="n">dtype<\/span>\(.*\)\]<\/span>~numpy.ndarray\1~g' "$DOC_DIR/pyadess.html"

