/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/doc_generate/autodoc_rstx.py

  • Committer: Ian Clatworthy
  • Date: 2010-01-08 07:34:31 UTC
  • mto: (4944.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4945.
  • Revision ID: ian.clatworthy@canonical.com-20100108073431-qtxf2unw83f6d43n
fix test failures

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
import bzrlib.osutils
32
32
 
33
33
 
34
 
# Set this to True to generate a file per topic.
35
 
# This probably ought to be an option. The files probably
36
 
# ought to be prefixed with their section name as well so
37
 
# there's zero risk of clashing with a standard sphinx
38
 
# topic (like search.html).
39
 
FILE_PER_TOPIC = True
40
 
 
41
 
 
42
34
def get_filename(options):
43
35
    """Provides name of manual"""
44
36
    return "%s_man.txt" % (options.bzr_name)
85
77
    If output_dir is not None, topics are dumped into text files there
86
78
    during processing, as well as being included in the return result.
87
79
    """
 
80
    file_per_topic = output_dir is not None
88
81
    lines = [title, hdg_level1 * len(title), ""]
89
 
    if FILE_PER_TOPIC:
 
82
    if file_per_topic:
90
83
        lines.extend([".. toctree::", "   :maxdepth: 1", ""])
91
84
 
92
 
    # docutils treats section heading as implicit link target.
93
 
    # But in some cases topic and heading are different, e.g.:
94
 
    #
95
 
    # `bugs' vs. `Bug Trackers'
96
 
    # `working-tree' vs. `Working Trees'
97
 
    #
98
 
    # So for building proper cross-reference between topic names
99
 
    # and corresponding sections in document, we need provide
100
 
    # simple glue in the form:
101
 
    #
102
 
    # .. _topic: `heading`_
103
 
    links_glue = []
104
 
 
105
85
    topics = sorted(registry.get_topics_for_section(section))
106
86
    for topic in topics:
107
87
        help = registry.get_detail(topic)
111
91
            help = "%s\n%s\n\n%s\n\n" % (heading, underline, text)
112
92
        else:
113
93
            help = "%s\n%s\n\n" % (heading, text)
114
 
        if FILE_PER_TOPIC:
 
94
        if file_per_topic:
115
95
            topic_id = _dump_text(output_dir, topic, help)
116
96
            lines.append("   %s" % topic_id)
117
97
        else:
118
98
            lines.append(help)
119
99
 
120
 
        # check that topic match heading
121
 
        if topic != heading.lower():
122
 
            links_glue.append((topic, heading))
123
 
 
124
 
    # provide links glue for topics that don't match headings
125
 
    #lines.append('')
126
 
    #lines.extend([".. _%s: `%s`_" % i for i in links_glue])
127
 
    #lines.append('')
128
 
 
129
100
    return "\n" + "\n".join(lines) + "\n"
130
101
 
131
102
 
132
103
def _get_commands_section(registry, title="Commands", hdg_level1="#",
133
104
        hdg_level2="=", output_dir=None):
134
105
    """Build the commands reference section of the manual."""
 
106
    file_per_topic = output_dir is not None
135
107
    lines = [title, hdg_level1 * len(title), ""]
136
 
    if FILE_PER_TOPIC:
 
108
    if file_per_topic:
137
109
        lines.extend([".. toctree::", "   :maxdepth: 1", ""])
138
110
 
139
111
    cmds = sorted(bzrlib.commands.builtin_command_names())
145
117
        underline = hdg_level2 * len(heading)
146
118
        text = cmd_object.get_help_text(plain=False, see_also_as_links=True)
147
119
        help = "%s\n%s\n\n%s\n\n" % (heading, underline, text)
148
 
        if FILE_PER_TOPIC:
 
120
        if file_per_topic:
149
121
            topic_id = _dump_text(output_dir, cmd_name, help)
150
122
            lines.append("   %s" % topic_id)
151
123
        else: