#!/usr/bin/env python # # Copyright 2008, Red Hat, Inc # Steve 'Ashcrow' Milner # John Eckersberg # # This software may be freely redistributed under the terms of the GNU # general public license. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. TEMPLATE = """\ # # Copyright %s # %s <%s> # # This software may be freely redistributed under the terms of the GNU # general public license. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. import func_module class %s(func_module.FuncModule): # Update these if need be. version = "0.0.1" api_version = "0.0.1" description = "%s" %s """ METHOD_TEMPLATE = '''\ def %s(self): """ TODO: Document me ... """ pass ''' def populate_template(author_name, author_email, module_name, desc, methods): """ Makes the method strings and populates the template. """ from datetime import datetime actual_methods = "" for method in methods: actual_methods += METHOD_TEMPLATE % method return TEMPLATE % (datetime.now().strftime("%Y"), author_name, author_email, module_name, desc, actual_methods[:-2]) if __name__ == '__main__': module_name = raw_input("Module Name: ").capitalize() desc = raw_input("Description: ") author_name = raw_input("Author: ") author_email = raw_input("Email: ") methods = [] print "\nLeave blank to finish." while True: method = raw_input("Method: ") if method == '': break methods.append(method) # Write it out to a file file_name = "%s.py" % module_name.lower() file_obj = open(file_name, "w") file_obj.write(populate_template(author_name, author_email, module_name, desc, methods)) file_obj.close() print "Your module is ready to be hacked on. Wrote out to %s." % file_name til/reference.rb'>stats
blob: ce3d6550cbea6dcfb4bc53d90e85bd1e0d6a0f9a (plain)
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
require 'puppet/util/instance_loader'

# Manage Reference Documentation.
class Puppet::Util::Reference
    include Puppet::Util
    include Puppet::Util::Docs

    extend Puppet::Util::InstanceLoader

    autoload(:reference, 'puppet/reference')

    def self.footer
        "\n\n----------------\n\n*This page autogenerated on %s*\n" % Time.now
    end

    def self.modes
        %w{pdf trac text}
    end

    def self.newreference(name, options = {}, &block)
        ref = self.new(name, options, &block)
        instance_hash(:reference)[symbolize(name)] = ref

        ref
    end

    def self.page(*sections)
        depth = 4
        # Use the minimum depth
        sections.each do |name|
            section = reference(name) or raise "Could not find section %s" % name
            depth = section.depth if section.depth < depth
        end
        text = ".. contents:: :depth: 2\n\n"
    end

    def self.pdf(text)
        puts "creating pdf"
        File.open("/tmp/puppetdoc.txt", "w") do |f|
            f.puts text
        end
        rst2latex = %x{which rst2latex}
        if $? != 0 or rst2latex =~ /no /
            rst2latex = %x{which rst2latex.py}
        end
        if $? != 0 or rst2latex =~ /no /
            raise "Could not find rst2latex"
        end
        rst2latex.chomp!