Robert Lehmann avatar Robert Lehmann committed 6deeb7a

Change default visibility for C++ superclasses.

Comments (0)

Files changed (2)

sphinx/domains/cpp.py

     def get_name(self):
         return self.name.get_name()
 
-    def get_modifiers(self):
+    def get_modifiers(self, visibility='public'):
         rv = []
-        if self.visibility != 'public':
+        if self.visibility != visibility:
             rv.append(self.visibility)
         if self.static:
             rv.append(u'static')
     def get_id(self):
         return self.name.get_id()
 
-    def __unicode__(self):
-        buf = self.get_modifiers()
+    def __unicode__(self, visibility='public'):
+        buf = self.get_modifiers(visibility)
         buf.append(unicode(self.name))
         if self.bases:
             buf.append(u':')
-            buf.append(u', '.join(unicode(base) for base in self.bases))
+            buf.append(u', '.join(base.__unicode__('private')
+                                  for base in self.bases))
         return u' '.join(buf)
 
 
         if self.skip_string(':'):
             self.skip_ws()
             while 1:
-                access = 'public'
+                access = 'private'
                 if self.match(_visibility_re):
                     access = self.matched_text
                 base = self._parse_type()
         pnode += nodes.Text(text)
         node += pnode
 
-    def attach_modifiers(self, node, obj):
-        if obj.visibility != 'public':
+    def attach_modifiers(self, node, obj, visibility='public'):
+        if obj.visibility != visibility:
             node += addnodes.desc_annotation(obj.visibility,
                                              obj.visibility)
             node += nodes.Text(' ')
         if cls.bases:
             signode += nodes.Text(' : ')
             for base in cls.bases:
-                self.attach_modifiers(signode, base)
+                self.attach_modifiers(signode, base, 'private')
                 signode += nodes.emphasis(unicode(base.name), unicode(base.name))
                 signode += nodes.Text(', ')
             signode.pop()  # remove the trailing comma

tests/test_cpp_domain.py

     assert unicode(parse('class', x)) == x
 
     x = 'A : private B'
-    assert unicode(parse('class', x)) == x
+    assert unicode(parse('class', x)) == 'A : B'
 
     x = 'A : public B'
-    assert unicode(parse('class', x)) == 'A : B'
+    assert unicode(parse('class', x)) == x
 
     x = 'A : B, C'
     assert unicode(parse('class', x)) == x
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.