/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: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

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