Exemplo n.º 1
0
    def test(self):
        trie = Trie()
        map = ResultMap()

        trie.insert("math", map.add("Math", "namespaceMath.html", flags=ResultFlag.NAMESPACE))
        index = map.add("Math::Vector", "classMath_1_1Vector.html", flags=ResultFlag.CLASS)
        trie.insert("math::vector", index)
        trie.insert("vector", index)
        index = map.add("Math::Range", "classMath_1_1Range.html", flags=ResultFlag.CLASS)
        trie.insert("math::range", index)
        trie.insert("range", index)

        serialized = serialize_search_data(trie, map, 3)
        self.compare(serialized, """
3 symbols
math [0]
|   ::vector [1]
|     range [2]
vector [1]
range [2]
0: Math [type=NAMESPACE] -> namespaceMath.html
1: ::Vector [prefix=0[:0], type=CLASS] -> classMath_1_1Vector.html
2: ::Range [prefix=0[:0], type=CLASS] -> classMath_1_1Range.html
""")
        self.assertEqual(len(serialized), 241)
Exemplo n.º 2
0
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)),
                             '..'))

from dox2html5 import Trie, ResultMap, ResultFlag, serialize_search_data

basedir = pathlib.Path(os.path.dirname(
    os.path.realpath(__file__))) / 'js-test-data'

with open(basedir / 'short.bin', 'wb') as f:
    f.write(b'')
with open(basedir / 'wrong-magic.bin', 'wb') as f:
    f.write(b'MOS\0                ')
with open(basedir / 'wrong-version.bin', 'wb') as f:
    f.write(b'MCS\1                ')
with open(basedir / 'empty.bin', 'wb') as f:
    f.write(serialize_search_data(Trie(), ResultMap(), 0))

trie = Trie()
map = ResultMap()

trie.insert("math",
            map.add("Math", "namespaceMath.html", flags=ResultFlag.NAMESPACE))
index = map.add("Math::min(int, int)",
                "namespaceMath.html#min",
                suffix_length=8,
                flags=ResultFlag.FUNC)
trie.insert("math::min()", index, lookahead_barriers=[4])
trie.insert("min()", index)
index = map.add("Math::Vector",
                "classMath_1_1Vector.html",
                flags=ResultFlag.CLASS | ResultFlag.DEPRECATED)
Exemplo n.º 3
0
    map = ResultMap()
    map.add("Magnum", "namespaceMagnum.html", flags=ResultFlag.NAMESPACE)
    map.add("Magnum::Math",
            "namespaceMagnum_1_1Math.html",
            flags=ResultFlag.NAMESPACE)
    map.add("Magnum::Math::Vector",
            "classMagnum_1_1Math_1_1Vector.html",
            flags=ResultFlag.CLASS)
    map.add(
        "Magnum::Math::Vector::min()",
        "classMagnum_1_1Math_1_1Vector.html#af029f9f7810201f0bd8d9580af273bde",
        flags=ResultFlag.FUNC)
    map.add("Magnum::Math::Range",
            "classMagnum_1_1Math_1_1Range.html",
            flags=ResultFlag.CLASS)
    map.add(
        "Magnum::Math::Range::min()",
        "classMagnum_1_1Math_1_1Range.html#ad4919361a2086212fac96da0221e4dcd",
        flags=ResultFlag.FUNC)
    map.add("Magnum::Math::min()",
            "namespaceMagnum_1_1Math.html#ae22ef0cb2a5a5e4c5e626a3df670be21",
            flags=ResultFlag.FUNC)

    with open(args.output, 'wb') as f:
        f.write(
            serialize_search_data(Trie() if args.map else trie,
                                  map if args.map else ResultMap(),
                                  merge_subtrees=not args.no_subtree_merging,
                                  merge_prefixes=not args.no_prefix_merging))