File: docs.py

package info (click to toggle)
gtsam 4.2.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 46,108 kB
  • sloc: cpp: 127,191; python: 14,312; xml: 8,442; makefile: 252; sh: 119; ansic: 101
file content (72 lines) | stat: -rw-r--r-- 1,763 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import xml.etree.ElementTree as ET


class Doc():
    def __init__(self, tree):
        self.tree = tree

    def get_tree(self):
        """Get this Doc's tree.

        Returns:
            The xml.etree.ElementTree object of the documentation.
        """
        return self.tree

    def __eq__(self, other):
        if other is None or other.get_tree() is None:
            return None

        return ET.tostring(self.tree.getroot()) == \
            ET.tostring(other.get_tree().getroot())


class ClassDoc(Doc):
    pass


class FreeDoc(Doc):
    pass


class Docs():
    def __init__(self, class_docs, free_docs):
        # These are dicts that map file_path -> Doc
        self.class_docs = class_docs
        self.free_docs = free_docs

    def get_class_docs(self, class_name):
        '''Get the documentation for the class.

        Arguments:
        class_name -- the name of the class

        Returns:
        The ClassDoc with the class's documentation. None if the class does not
        exist.
        '''
        return self.class_docs.get(class_name)

    def get_free_docs(self, free_func_name):
        '''Get the documentation for a free function.

        Arguments:
        free_func_name -- the name of the free function

        Returns:
        The FreeDoc with the free function's documentation. None if the class
        does not exist.
        '''
        return self.free_docs.get(free_func_name)

    def get_class_docs_keys_list(self):
        return list(self.class_docs)

    def get_free_docs_keys_list(self):
        return list(self.free_docs)

    def get_class_docs_values_list(self):
        return list(self.class_docs.values())

    def get_free_docs_values_list(self):
        return list(self.free_docs.values())