]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
gtkdoc: accept %<numeric>
authorFlorian Brosch <flo.brosch@gmail.com>
Tue, 7 Aug 2012 12:06:38 +0000 (14:06 +0200)
committerFlorian Brosch <flo.brosch@gmail.com>
Tue, 7 Aug 2012 12:06:38 +0000 (14:06 +0200)
src/libvaladoc/documentation/gtkdoccommentparser.vala

index 1fcafbc7531871c75c90af681c4d2990f5ed334e..79392168a5a2655fa705220b2b9a69a90bd696db 100644 (file)
@@ -44,6 +44,7 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator {
 
        private string[]? comment_lines;
 
+       private Regex? is_numeric_regex = null;
        private Regex? normalize_regex = null;
 
        private HashMap<Api.SourceFile, GirMetaData> metadata = new HashMap<Api.SourceFile, GirMetaData> ();
@@ -76,15 +77,16 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator {
 
        private string normalize (string text) {
                try {
-                       if (normalize_regex == null) {
-                               normalize_regex = new Regex ("( |\n|\t)+");
-                       }
                        return normalize_regex.replace (text, -1, 0, " ");
                } catch (RegexError e) {
                        assert_not_reached ();
                }
        }
 
+       private bool is_numeric (string str) {
+               return is_numeric_regex.match (str);
+       }
+
        private inline Text? split_text (Text text) {
                int offset = 0;
                while ((offset = text.content.index_of_char ('.', offset)) >= 0) {
@@ -230,6 +232,13 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator {
                this.reporter = reporter;
                this.settings = settings;
                this.tree = tree;
+
+               try {
+                       is_numeric_regex = new Regex ("^[+-]?([0-9]*\\.?[0-9]+|[0-9]+\\.?[0-9]*)([eE][+-]?[0-9]+)?$", RegexCompileFlags.OPTIMIZE);
+                       normalize_regex = new Regex ("( |\n|\t)+", RegexCompileFlags.OPTIMIZE);
+               } catch (RegexError e) {
+                       assert_not_reached ();
+               }
        }
 
        private Api.Node? element;
@@ -1493,7 +1502,7 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator {
        }
 
        private Inline create_type_link (string name) {
-               if (name == "TRUE" || name == "FALSE" || name == "NULL") {
+               if (name == "TRUE" || name == "FALSE" || name == "NULL" || is_numeric (name)) {
                        var monospaced = factory.create_run (Run.Style.MONOSPACED);
                        monospaced.content.add (factory.create_text (name.down ()));
                        return monospaced;