[Cmake-commits] CMake branch, next, updated. v3.1.0-rc1-541-g4061dcb

Brad King brad.king at kitware.com
Wed Nov 12 08:29:05 EST 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  4061dcb0e16cc49aa3c51076ed9bfb3981b0002f (commit)
       via  fb59b23ad5ef38d258fd0ae76a68791300e278b4 (commit)
      from  2c16cd78f168c6e7fdad9e3fa65b551b5fe7d2dc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4061dcb0e16cc49aa3c51076ed9bfb3981b0002f
commit 4061dcb0e16cc49aa3c51076ed9bfb3981b0002f
Merge: 2c16cd7 fb59b23
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Nov 12 08:29:04 2014 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Nov 12 08:29:04 2014 -0500

    Merge topic 'doc-index-xrefs' into next
    
    fb59b23a Utilities/Sphinx: Add index entries for cross-references


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fb59b23ad5ef38d258fd0ae76a68791300e278b4
commit fb59b23ad5ef38d258fd0ae76a68791300e278b4
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Nov 11 17:19:26 2014 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Nov 11 17:23:17 2014 -0500

    Utilities/Sphinx: Add index entries for cross-references
    
    Add a document transform to insert index and target nodes just before
    any CMake domain cross-reference node.  This will make references to
    CMake domain objects appear in the index.  Also add a comment explaining
    why it cannot be done in a result_nodes method of the CMakeXRefRole.

diff --git a/Utilities/Sphinx/cmake.py b/Utilities/Sphinx/cmake.py
index 2629bb3..ec39596 100644
--- a/Utilities/Sphinx/cmake.py
+++ b/Utilities/Sphinx/cmake.py
@@ -130,8 +130,8 @@ class _cmake_index_entry:
     def __init__(self, desc):
         self.desc = desc
 
-    def __call__(self, title, targetid):
-        return ('pair', u'%s ; %s' % (self.desc, title), targetid, 'main')
+    def __call__(self, title, targetid, main = 'main'):
+        return ('pair', u'%s ; %s' % (self.desc, title), targetid, main)
 
 _cmake_index_objs = {
     'command':    _cmake_index_entry('command'),
@@ -257,6 +257,49 @@ class CMakeXRefRole(XRefRole):
                 break
         return XRefRole.__call__(self, typ, rawtext, text, *args, **keys)
 
+    # We cannot insert index nodes using the result_nodes method
+    # because CMakeXRefRole is processed before substitution_reference
+    # nodes are evaluated so target nodes (with 'ids' fields) would be
+    # duplicated in each evaluted substitution replacement.  The
+    # docutils substitution transform does not allow this.  Instead we
+    # use our own CMakeXRefTransform below to add index entries after
+    # substitutions are completed.
+    #
+    # def result_nodes(self, document, env, node, is_ref):
+    #     pass
+
+class CMakeXRefTransform(Transform):
+
+    # Run this transform early since we insert nodes we want
+    # treated as if they were written in the documents, but
+    # after the sphinx (210) and docutils (220) substitutions.
+    default_priority = 221
+
+    def apply(self):
+        env = self.document.settings.env
+
+        # Find CMake cross-reference nodes and add index and target
+        # nodes for them.
+        for ref in self.document.traverse(addnodes.pending_xref):
+            if not ref['refdomain'] == 'cmake':
+                continue
+
+            objtype = ref['reftype']
+            make_index_entry = _cmake_index_objs.get(objtype)
+            if not make_index_entry:
+                continue
+
+            objname = ref['reftarget']
+            targetnum = env.new_serialno('index-%s:%s' % (objtype, objname))
+
+            targetid = 'index-%s-%s:%s' % (targetnum, objtype, objname)
+            targetnode = nodes.target('', '', ids=[targetid])
+            self.document.note_explicit_target(targetnode)
+
+            indexnode = addnodes.index()
+            indexnode['entries'] = [make_index_entry(objname, targetid, '')]
+            ref.replace_self([indexnode, targetnode, ref])
+
 class CMakeDomain(Domain):
     """CMake domain."""
     name = 'cmake'
@@ -336,4 +379,5 @@ class CMakeDomain(Domain):
 def setup(app):
     app.add_directive('cmake-module', CMakeModule)
     app.add_transform(CMakeTransform)
+    app.add_transform(CMakeXRefTransform)
     app.add_domain(CMakeDomain)

-----------------------------------------------------------------------

Summary of changes:
 Utilities/Sphinx/cmake.py |   48 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 46 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list