Commits

Armin Ronacher committed d79dab0

C++ domain now supports array definitions.

Comments (0)

Files changed (2)

 * #259: HTML table rows now have even/odd CSS classes to enable
   "Zebra styling".
 
+* C++ domain now supports array definitions.
+
 
 Release 1.0.7 (in development)
 ==============================

sphinx/domains/cpp.py

 _string_re = re.compile(r"[LuU8]?('([^'\\]*(?:\\.[^'\\]*)*)'"
                         r'|"([^"\\]*(?:\\.[^"\\]*)*)")', re.S)
 _visibility_re = re.compile(r'\b(public|private|protected)\b')
+_array_def_re = re.compile(r'\[\s*(.+?)?\s*\]')
 _operator_re = re.compile(r'''(?x)
         \[\s*\]
     |   \(\s*\)
         return u'%s*' % self.typename
 
 
+class ArrayDefExpr(WrappingDefExpr):
+
+    def __init__(self, typename, size_hint=None):
+        WrappingDefExpr.__init__(self, typename)
+        self.size_hint = size_hint
+
+    def get_id(self):
+        return self.typename.get_id() + u'A'
+
+    def __unicode__(self):
+        return u'%s[%s]' % (
+            self.typename,
+            self.size_hint is not None and unicode(self.size_hint) or u''
+        )
+
+
 class RefDefExpr(WrappingDefExpr):
 
     def get_id(self):
                 expr = ConstDefExpr(expr)
             elif self.skip_string('*'):
                 expr = PtrDefExpr(expr)
+            elif self.match(_array_def_re):
+                expr = ArrayDefExpr(expr, self.last_match.group(1))
             elif self.skip_string('&'):
                 expr = RefDefExpr(expr)
             else:
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.