Rev 2685: IE-safe bzr_man.html, cross-reference links for `see also' topics in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Aug 8 12:31:13 BST 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 2685
revision-id: pqm at pqm.ubuntu.com-20070808113110-acathx9d9mpfo80z
parent: pqm at pqm.ubuntu.com-20070808055516-ml9ucjsb4idmpmww
parent: bialix at ukr.net-20070807193311-76klhk4sldylzucs
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2007-08-08 12:31:10 +0100
message:
  IE-safe bzr_man.html, cross-reference links for `see also' topics
   (bialix,r=john,r=ian)
modified:
  Makefile                       Makefile-20050805140406-d96e3498bb61c5bb
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/commands.py             bzr.py-20050309040720-d10f4714595cf8c3
  doc/default.css                default.css-20060622101119-tgwtdci8z769bjb9-1
  tools/doc_generate/autodoc_rstx.py autodoc_rstx.py-20060420024836-3e0d4a526452193c
  tools/rst2html.py              rst2html.py-20060817120932-gn177u8v0008txhu-1
    ------------------------------------------------------------
    revno: 2677.1.5
    merged: bialix at ukr.net-20070807193311-76klhk4sldylzucs
    parent: bialix at ukr.net-20070807191838-1jk304202cbcmu55
    parent: pqm at pqm.ubuntu.com-20070807191900-kuqpkgh4sq9fczil
    committer: Alexander Belchenko <bialix at ukr.net>
    branch nick: bzr_man
    timestamp: Tue 2007-08-07 22:33:11 +0300
    message:
      merge bzr.dev
    ------------------------------------------------------------
    revno: 2677.1.4
    merged: bialix at ukr.net-20070807191838-1jk304202cbcmu55
    parent: bialix at ukr.net-20070807153415-6eb61r4qxcqbo82n
    committer: Alexander Belchenko <bialix at ukr.net>
    branch nick: bzr_man
    timestamp: Tue 2007-08-07 22:18:38 +0300
    message:
      fixes after John's review
    ------------------------------------------------------------
    revno: 2677.1.3
    merged: bialix at ukr.net-20070807153415-6eb61r4qxcqbo82n
    parent: bialix at ukr.net-20070807152902-rqn8su318xq3jkwl
    committer: Alexander Belchenko <bialix at ukr.net>
    branch nick: bzr_man
    timestamp: Tue 2007-08-07 18:34:15 +0300
    message:
      update credits
    ------------------------------------------------------------
    revno: 2677.1.2
    merged: bialix at ukr.net-20070807152902-rqn8su318xq3jkwl
    parent: bialix at ukr.net-20070807145650-jq9ss66genvith0n
    committer: Alexander Belchenko <bialix at ukr.net>
    branch nick: bzr_man
    timestamp: Tue 2007-08-07 18:29:02 +0300
    message:
      bzr_man: see also topics as cross-reference links
    ------------------------------------------------------------
    revno: 2677.1.1
    merged: bialix at ukr.net-20070807145650-jq9ss66genvith0n
    parent: pqm at pqm.ubuntu.com-20070807082835-sxq0vmfbvsebps5z
    committer: Alexander Belchenko <bialix at ukr.net>
    branch nick: bzr_man
    timestamp: Tue 2007-08-07 17:56:50 +0300
    message:
      rst2html: workaround for IE bug with id="tags"
=== modified file 'Makefile'
--- a/Makefile	2007-08-02 10:28:36 +0000
+++ b/Makefile	2007-08-07 19:33:11 +0000
@@ -101,6 +101,7 @@
 		 bzrlib/sign_my_commits.py \
 		 generate_docs.py \
 		 tools/doc_generate/__init__.py \
+		 tools/doc_generate/autodoc_man.py \
 		 tools/doc_generate/autodoc_rstx.py
 
 doc/bzr_man.txt: $(MAN_DEPENDENCIES)
@@ -123,7 +124,7 @@
 # clean produced docs
 clean-docs:
 	python tools/win32/ostools.py remove $(ALL_DOCS) \
-	$(HTMLDIR) $(PRETTYDIR) doc/bzr_man.txt doc/developers/performance.png
+	$(HTMLDIR) $(PRETTYDIR) doc/bzr_man.txt
 
 
 # build a png of our performance task list

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2007-08-07 02:12:43 +0000
+++ b/bzrlib/builtins.py	2007-08-07 15:29:02 +0000
@@ -1253,7 +1253,7 @@
         bzr commit -m 'imported project'
     """
 
-    _see_also = ['init-repo', 'branch', 'checkout']
+    _see_also = ['init-repository', 'branch', 'checkout']
     takes_args = ['location?']
     takes_options = [
         Option('create-prefix',

=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py	2007-08-07 05:24:34 +0000
+++ b/bzrlib/commands.py	2007-08-07 19:18:38 +0000
@@ -274,13 +274,16 @@
         s = s[:-1]
         return s
 
-    def get_help_text(self, additional_see_also=None, plain=True):
+    def get_help_text(self, additional_see_also=None, plain=True,
+                      see_also_as_links=False):
         """Return a text string with help for this command.
         
         :param additional_see_also: Additional help topics to be
             cross-referenced.
         :param plain: if False, raw help (reStructuredText) is
             returned instead of plain text.
+        :param see_also_as_links: if True, convert items in 'See also'
+            list to internal links (used by bzr_man rstx generator)
         """
         doc = self.help()
         if doc is None:
@@ -338,6 +341,17 @@
             result += ':From:     plugin "%s"\n' % plugin_name
         see_also = self.get_see_also(additional_see_also)
         if see_also:
+            if not plain and see_also_as_links:
+                see_also_links = []
+                for item in see_also:
+                    if item == 'topics':
+                        # topics doesn't have an independent section
+                        # so don't create a real link
+                        see_also_links.append(item)
+                    else:
+                        # Use a reST link for this entry
+                        see_also_links.append("`%s`_" % (item,))
+                see_also = see_also_links
             result += ':See also: '
             result += ', '.join(see_also) + '\n'
 
@@ -389,7 +403,7 @@
         return self.name()
 
     def get_see_also(self, additional_terms=None):
-        """Return a list of help topics that are related to this ommand.
+        """Return a list of help topics that are related to this command.
         
         The list is derived from the content of the _see_also attribute. Any
         duplicates are removed and the result is in lexical order.

=== modified file 'doc/default.css'
--- a/doc/default.css	2007-05-03 06:21:49 +0000
+++ b/doc/default.css	2007-08-07 14:56:50 +0000
@@ -144,3 +144,7 @@
   color: #b52727;
   text-decoration: none;
   }
+
+span, th.field-name {
+  white-space: nowrap;
+}

=== modified file 'tools/doc_generate/autodoc_rstx.py'
--- a/tools/doc_generate/autodoc_rstx.py	2007-08-06 08:25:46 +0000
+++ b/tools/doc_generate/autodoc_rstx.py	2007-08-07 19:18:38 +0000
@@ -17,7 +17,7 @@
 """Generate ReStructuredText source for the User Reference Manual.
 Loosely based on the manpage generator autodoc_man.py.
 
-Written by Alexander Belchenko and the Bazaar community.
+Written by the Bazaar community.
 """
 
 import os
@@ -68,6 +68,20 @@
     """Build the manual part from topics matching that section."""
     topics = sorted(registry.get_topics_for_section(section))
     lines = [title, hdg_level1 * len(title), ""]
+
+    # docutils treats section heading as implicit link target.
+    # But in some cases topic and heading are different, e.g.:
+    #
+    # `bugs' vs. `Bug Trackers'
+    # `working-tree' vs. `Working Trees'
+    #
+    # So for building proper cross-reference between topic names
+    # and corresponding sections in document, we need provide
+    # simple glue in the form:
+    #
+    # .. _topic: `heading`_
+    links_glue = []
+
     for topic in topics:
         help = registry.get_detail(topic)
         heading,text = help.split("\n", 1)
@@ -75,6 +89,14 @@
         lines.append(hdg_level2 * len(heading))
         lines.append(text)
         lines.append('')
+        # check that topic match heading
+        if topic != heading.lower():
+            links_glue.append((topic, heading))
+
+    # provide links glue for topics that don't match headings
+    lines.extend([".. _%s: `%s`_" % i for i in links_glue])
+    lines.append('')
+
     return "\n" + "\n".join(lines) + "\n"
 
 
@@ -88,7 +110,7 @@
         if cmd_object.hidden:
             continue
         heading = cmd_name
-        text = cmd_object.get_help_text(plain=False)
+        text = cmd_object.get_help_text(plain=False, see_also_as_links=True)
         lines.append(heading)
         lines.append(hdg_level2 * len(heading))
         lines.append(text)

=== modified file 'tools/rst2html.py'
--- a/tools/rst2html.py	2006-08-17 12:14:57 +0000
+++ b/tools/rst2html.py	2007-08-07 14:56:50 +0000
@@ -22,4 +22,22 @@
 description = ('Generates (X)HTML documents from standalone reStructuredText '
                'sources.  ' + default_description)
 
-publish_cmdline(writer_name='html', description=description)
+
+# workaround for bug with <xxx id="tags" name="tags"> in IE
+from docutils.writers import html4css1
+
+class IESafeHtmlTranslator(html4css1.HTMLTranslator):
+
+    def starttag(self, node, tagname, suffix='\n', empty=0, **attributes):
+        x = html4css1.HTMLTranslator.starttag(self, node, tagname, suffix,
+                                              empty, **attributes)
+        y = x.replace('id="tags"', 'id="tags_"')
+        y = y.replace('name="tags"', 'name="tags_"')
+        y = y.replace('href="#tags"', 'href="#tags_"')
+        return y
+
+mywriter = html4css1.Writer()
+mywriter.translator_class = IESafeHtmlTranslator
+
+
+publish_cmdline(writer=mywriter, description=description)




More information about the bazaar-commits mailing list