~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tools/generate_docs.py

  • Committer: John Arbash Meinel
  • Date: 2013-05-19 14:29:37 UTC
  • mfrom: (6437.63.9 2.5)
  • mto: (6437.63.10 2.5)
  • mto: This revision was merged to the branch mainline in revision 6575.
  • Revision ID: john@arbash-meinel.com-20130519142937-21ykz2n2y2f22za9
Merge in the actual 2.5 branch. It seems I failed before

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
#
15
15
# You should have received a copy of the GNU General Public License
16
16
# along with this program; if not, write to the Free Software
17
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
 
19
19
"""%(prog)s - generate information from built-in bzr help
20
20
 
32
32
 
33
33
Run "%(prog)s --help" for the option reference.
34
34
"""
35
 
 
 
35
import os
36
36
import sys
37
37
from optparse import OptionParser
38
38
 
39
 
import tools.doc_generate
 
39
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
 
40
 
 
41
import bzrlib
 
42
from bzrlib import (
 
43
    commands,
 
44
    doc_generate,
 
45
    )
 
46
 
40
47
 
41
48
def main(argv):
42
49
    parser = OptionParser(usage="""%prog [options] OUTPUT_FORMAT
69
76
        parser.print_help()
70
77
        sys.exit(1)
71
78
 
72
 
    infogen_type = args[1]
73
 
    infogen_mod = tools.doc_generate.get_module(infogen_type)
74
 
 
75
 
    if options.filename:
76
 
        outfilename = options.filename
77
 
    else:
78
 
        outfilename = infogen_mod.get_filename(options)
79
 
 
80
 
    if outfilename == "-":
81
 
        outfile = sys.stdout
82
 
    else:
83
 
        outfile = open(outfilename,"w")
84
 
 
85
 
    if options.show_filename and (outfilename != "-"):
86
 
        print >>sys.stdout, outfilename
87
 
    
88
 
    infogen_mod.infogen(options, outfile)
 
79
    with bzrlib.initialize():
 
80
        commands.install_bzr_command_hooks()
 
81
        infogen_type = args[1]
 
82
        infogen_mod = doc_generate.get_module(infogen_type)
 
83
        if options.filename:
 
84
            outfilename = options.filename
 
85
        else:
 
86
            outfilename = infogen_mod.get_filename(options)
 
87
        if outfilename == "-":
 
88
            outfile = sys.stdout
 
89
        else:
 
90
            outfile = open(outfilename,"w")
 
91
        if options.show_filename and (outfilename != "-"):
 
92
            sys.stdout.write(outfilename)
 
93
            sys.stdout.write('\n')
 
94
        infogen_mod.infogen(options, outfile)
 
95
 
89
96
 
90
97
def print_extended_help(option, opt, value, parser):
91
98
    """ Program help examples
93
100
    Prints out the examples stored in the docstring. 
94
101
 
95
102
    """
96
 
    print >>sys.stdout, __doc__ % {"prog":sys.argv[0]}
 
103
    sys.stdout.write(__doc__ % {"prog":sys.argv[0]})
 
104
    sys.stdout.write('\n')
97
105
    sys.exit(0)
98
106
 
99
107
if __name__ == '__main__':