/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 breezy/doc_generate/autodoc_rstx.py

  • Committer: Jelmer Vernooij
  • Date: 2020-03-22 01:35:14 UTC
  • mfrom: (7490.7.6 work)
  • mto: This revision was merged to the branch mainline in revision 7499.
  • Revision ID: jelmer@jelmer.uk-20200322013514-7vw1ntwho04rcuj3
merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Generate reStructuredText source for the User Reference Manual.
18
18
Loosely based on the manpage generator autodoc_man.py.
19
19
 
20
 
Written by the Bazaar community.
 
20
Written by the Bazaar/Breezy community.
21
21
"""
22
22
 
23
 
from __future__ import absolute_import
24
 
 
25
23
import time
26
24
 
27
25
import breezy
41
39
    t = time.time()
42
40
    tt = time.gmtime(t)
43
41
    params = \
44
 
           { "brzcmd": options.brz_name,
45
 
             "datestamp": time.strftime("%Y-%m-%d", tt),
46
 
             "timestamp": time.strftime("%Y-%m-%d %H:%M:%S +0000", tt),
47
 
             "version": breezy.__version__,
48
 
             }
 
42
        {"brzcmd": options.brz_name,
 
43
         "datestamp": time.strftime("%Y-%m-%d", tt),
 
44
         "timestamp": time.strftime("%Y-%m-%d %H:%M:%S +0000", tt),
 
45
         "version": breezy.__version__,
 
46
         }
49
47
    nominated_filename = getattr(options, 'filename', None)
50
48
    if nominated_filename is None:
51
49
        topic_dir = None
63
61
    registry = breezy.help_topics.topic_registry
64
62
    result = []
65
63
    result.append(_get_section(registry, SECT_CONCEPT, "Concepts",
66
 
        output_dir=topic_dir))
 
64
                               output_dir=topic_dir))
67
65
    result.append(_get_section(registry, SECT_LIST, "Lists",
68
 
        output_dir=topic_dir))
 
66
                               output_dir=topic_dir))
69
67
    result.append(_get_commands_section(registry, output_dir=topic_dir))
70
68
    return "\n".join(result)
71
69
 
72
70
 
73
71
def _get_section(registry, section, title, hdg_level1="#", hdg_level2="=",
74
 
        output_dir=None):
 
72
                 output_dir=None):
75
73
    """Build the manual part from topics matching that section.
76
 
    
 
74
 
77
75
    If output_dir is not None, topics are dumped into text files there
78
76
    during processing, as well as being included in the return result.
79
77
    """
101
99
 
102
100
 
103
101
def _get_commands_section(registry, title="Commands", hdg_level1="#",
104
 
        hdg_level2="=", output_dir=None):
 
102
                          hdg_level2="=", output_dir=None):
105
103
    """Build the commands reference section of the manual."""
106
104
    file_per_topic = output_dir is not None
107
105
    lines = [title, hdg_level1 * len(title), ""]
130
128
    """Dump text for a topic to a file."""
131
129
    topic_id = "%s-%s" % (topic, "help")
132
130
    filename = breezy.osutils.pathjoin(output_dir, topic_id + ".txt")
133
 
    f =  open(filename, "w")
134
 
    f.write(text.encode('utf-8'))
135
 
    f.close()
 
131
    with open(filename, "wb") as f:
 
132
        f.write(text.encode('utf-8'))
136
133
    return topic_id
137
134
 
138
135
 
150
147
 
151
148
rstx_head = """\
152
149
#####################
153
 
Bazaar User Reference
 
150
Breezy User Reference
154
151
#####################
155
152
 
156
153
About This Manual
157
154
#################
158
155
 
159
 
This manual is generated from Bazaar's online help. To use
 
156
This manual is generated from Breezy's online help. To use
160
157
the online help system, try the following commands.
161
158
 
162
159
    Introduction including a list of commonly used commands::
175
172
 
176
173
        brz help topic-or-command-name
177
174
 
178
 
The following web sites provide further information on Bazaar:
 
175
The following web sites provide further information on Breezy:
179
176
 
180
177
:Home page:                     http://www.breezy-vcs.org/
181
 
:Bazaar docs:                   http://doc.bazaar.canonical.com/
 
178
:Breezy docs:                   http://www.breezy-vcs.org/doc/
182
179
:Launchpad:                     https://launchpad.net/brz/
183
180
"""
184
181