File: formatter_XPyDoc.py

package info (click to toggle)
python-happydoc 2.0-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 4,176 kB
  • ctags: 3,347
  • sloc: python: 11,321; makefile: 88; sh: 77
file content (146 lines) | stat: -rw-r--r-- 3,658 bytes parent folder | download | duplicates (3)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#
# Structured docset and formatters for HappyDoc.
# 
# Copyright (C) 2001 by wrobell <wrobell@ite.pl>.
# 
# This software comes with ABSOLUTELY NO WARRANTY.
# This is free software, and you are welcome to redistribute it
# under certain conditions. For details see COPYING file.
#

"""Xpydoc formatter.

"""

import happydoclib.formatter.xmlformatterbase

__rcs_info__ = {
    #
    #  Creation Information
    #
    'module_name': '$RCSfile: formatter_XPyDoc.py,v $',
    'creator':     'wrobell <wrobell@ite.pl>',
    'project':     'HappyDoc',
    'created':     '24-08-2001',
    #
    #  Current Information
    #
    'author':      '$Author: doughellmann $',
    'version':     '$Revision: 1.1 $',
    'date':        '$Date: 2001/10/24 21:27:35 $',
}


def entryPoint():
    "Return information about this module to the dynamic loader."
    return {
        'name':    'xpydoc',
        'factory':  XPyDocFormatter,
    }


class XPyDocFormatter(happydoclib.formatter.xmlformatterbase.XMLFormatter):
    """Xpydoc formatter.

    """

    def __init__(self, docSet, **configuration):
        """Initialize the XMLStructFormatter.

        Parameters

            'docSet' -- the DocSet instance containing global cross-reference
                      information
            
            '**configuration' -- additional, optional, configuration values

        """
        
        apply(hdformatter_xml.XMLFormatter.__init__, (self, docSet), configuration)
        self.filename_ext='xpd'


    def rootTag(self, output, end=0):
        if end:
            self.endTag('xpydoc', output)
        else:
            self.tag('xpydoc', output)


    def moduleTag(self, info, output, end=0):
        if end:
            self.endTag('module', output)
        else:
            self.tag('module', output, { 'name': info.getName() })


    def descriptionTag(self, output, end=0):
        if end:
            self.endTag('description', output)
        else:
            self.tag('description', output)


    def importTag(self, module, output, end=0):
        if end:
            self.endTag('import', output)
        else:
            self.tag('import', output, { 'module': module })


    def symbolTag(self, output, end=0):
        if end:
            self.endTag('symbol', output)
        else:
            self.tag('symbol', output)


    def classTag(self, info, output, end=0):
        if end:
            self.endTag('class', output)
        else:
            self.tag('class', output, { 'name': info.getName() })


    def exceptionTag(self, finfo, name, output, end=0):
        if end:
            self.endTag('exception', output)
        else:
            self.tag('exception', output, { 'name': name })


    def functionTag(self, info, output, end=0):
        if end:
            self.endTag('function', output)
        else:
            self.tag('function', output, { 'name': info.getName() })


    def baseTag(self, info, name, output, end=0):
        if end: return

        self.emptyTag('base', output, { 'class': name })


    def paramTag(self, info, name, output, end=0):
        if end: return

        default_specified, default_value, default_value_type=info
        attr={ 'name': name }

        if default_specified:
            attr['default']=default_value

        self.emptyTag('param', output, attrs=attr)


    def classIndex(self, class_info, output, end=0):
        self.emptyTag('class', output, { 'name': class_info.getName() })


    def moduleIndex(self, module_info, output, end=0):
        self.emptyTag('module', output, { 'name': module_info.getName() })


    def getEncoding(self):
        return self.encoding