[valadoc] gtkdoc: accept %<numeric>
- From: Florian Brosch <flobrosch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [valadoc] gtkdoc: accept %<numeric>
- Date: Tue, 7 Aug 2012 12:22:48 +0000 (UTC)
commit 2daa05f2bd185e3de5c2e85afc86b2bc6194b41b
Author: Florian Brosch <flo brosch gmail com>
Date: Tue Aug 7 14:06:38 2012 +0200
gtkdoc: accept %<numeric>
.../documentation/gtkdoccommentparser.vala | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/src/libvaladoc/documentation/gtkdoccommentparser.vala b/src/libvaladoc/documentation/gtkdoccommentparser.vala
index 1fcafbc..7939216 100644
--- a/src/libvaladoc/documentation/gtkdoccommentparser.vala
+++ b/src/libvaladoc/documentation/gtkdoccommentparser.vala
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]