~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tools/generate_docs.py

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil
  • Date: 2017-01-30 14:42:05 UTC
  • mfrom: (6620.1.1 trunk)
  • Revision ID: tarmac-20170130144205-r8fh2xpmiuxyozpv
Merge  2.7 into trunk including fix for bug #1657238 [r=vila]

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
    # Don't remove the following import, it triggers a format registration that
 
45
    # avoid http://pad.lv/956860
 
46
    branch,
 
47
    doc_generate,
 
48
    )
 
49
 
40
50
 
41
51
def main(argv):
42
52
    parser = OptionParser(usage="""%prog [options] OUTPUT_FORMAT
69
79
        parser.print_help()
70
80
        sys.exit(1)
71
81
 
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
 
        sys.stdout.write(outfilename)
87
 
        sys.stdout.write('\n')
88
 
    
89
 
    infogen_mod.infogen(options, outfile)
 
82
    with bzrlib.initialize():
 
83
        commands.install_bzr_command_hooks()
 
84
        infogen_type = args[1]
 
85
        infogen_mod = doc_generate.get_module(infogen_type)
 
86
        if options.filename:
 
87
            outfilename = options.filename
 
88
        else:
 
89
            outfilename = infogen_mod.get_filename(options)
 
90
        if outfilename == "-":
 
91
            outfile = sys.stdout
 
92
        else:
 
93
            outfile = open(outfilename,"w")
 
94
        if options.show_filename and (outfilename != "-"):
 
95
            sys.stdout.write(outfilename)
 
96
            sys.stdout.write('\n')
 
97
        infogen_mod.infogen(options, outfile)
 
98
 
90
99
 
91
100
def print_extended_help(option, opt, value, parser):
92
101
    """ Program help examples