[valadoc/wip/tintou/version-support] WIP
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [valadoc/wip/tintou/version-support] WIP
- Date: Mon, 20 Feb 2017 22:19:16 +0000 (UTC)
commit 1454a29e73209d646940b21368c0a765a7bc7c30
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Mon Feb 20 16:01:03 2017 +0100
WIP
src/doclets/gtkdoc/generator.vala | 25 ++++++++++++-------------
src/driver/0.32.x/treebuilder.vala | 12 +++++-------
src/driver/0.34.x/treebuilder.vala | 12 +++++-------
src/driver/0.36.x/treebuilder.vala | 12 +++++-------
src/libvaladoc/html/basicdoclet.vala | 19 ++++++++-----------
5 files changed, 35 insertions(+), 45 deletions(-)
---
diff --git a/src/doclets/gtkdoc/generator.vala b/src/doclets/gtkdoc/generator.vala
index 44fe6b5..ab1dbef 100644
--- a/src/doclets/gtkdoc/generator.vala
+++ b/src/doclets/gtkdoc/generator.vala
@@ -1336,20 +1336,19 @@ It is important that your <link linkend=\"GValue\"><type>GValue</type></link> ho
private void process_attributes (Symbol sym, GComment gcomment) {
// Handle the ‘Deprecated’ attribute.
- var version_attribute = sym.get_attribute ("Version");
- var deprecated_attribute = sym.get_attribute ("Deprecated");
-
- AttributeArgument? deprecated_since = null;
- AttributeArgument? replacement = null;
- if (version_attribute != null) {
- deprecated_since = deprecated_attribute.get_argument ("deprecated_since");
- replacement = deprecated_attribute.get_argument ("replacement");
- } else if (deprecated_attribute != null) {
- deprecated_since = deprecated_attribute.get_argument ("since");
- replacement = deprecated_attribute.get_argument ("replacement");
- }
+ if (sym.is_deprecated) {
+ Attribute? version_attribute = null;
+ Attribute? deprecated_attribute = null;
+ AttributeArgument? deprecated_since = null;
+ AttributeArgument? replacement = null;
+ if ((version_attribute = sym.get_attribute ("Version")) != null) {
+ deprecated_since = deprecated_attribute.get_argument ("deprecated_since");
+ replacement = deprecated_attribute.get_argument ("replacement");
+ } else if ((deprecated_attribute = sym.get_attribute ("Deprecated")) != null) {
+ deprecated_since = deprecated_attribute.get_argument ("since");
+ replacement = deprecated_attribute.get_argument ("replacement");
+ }
- if (deprecated_attribute != null || version_attribute != null) {
string? since = null;
if (deprecated_since != null) {
since = deprecated_since.value;
diff --git a/src/driver/0.32.x/treebuilder.vala b/src/driver/0.32.x/treebuilder.vala
index c945881..5b9c5ea 100644
--- a/src/driver/0.32.x/treebuilder.vala
+++ b/src/driver/0.32.x/treebuilder.vala
@@ -250,33 +250,31 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
parent.add_attribute (new_attribute);
} else if (att.name == "Version") {
Attribute new_attribute = new Attribute (parent, parent.get_source_file (),
att.name, att);
-
if ((tmp = att.args.get ("deprecated")) != null) {
new_attribute.add_boolean ("deprecated", bool.parse (tmp), att);
}
-
- parent.add_attribute (new_attribute);
if ((tmp = att.args.get ("since")) != null) {
new_attribute.add_string ("since", tmp, att);
}
-
if ((tmp = att.args.get ("deprecated_since")) != null) {
new_attribute.add_string ("deprecated_since", tmp, att);
+ if (att.args.get ("deprecated") == null) {
+ new_attribute.add_boolean ("deprecated", true, att);
+ }
}
-
if ((tmp = att.args.get ("replacement")) != null) {
new_attribute.add_string ("replacement", tmp, att);
}
+ parent.add_attribute (new_attribute);
} else if (att.name == "Deprecated") {
Attribute new_attribute = new Attribute (parent, parent.get_source_file (),
att.name, att);
- parent.add_attribute (new_attribute);
if ((tmp = att.args.get ("since")) != null) {
new_attribute.add_string ("since", tmp, att);
}
-
if ((tmp = att.args.get ("replacement")) != null) {
new_attribute.add_string ("replacement", tmp, att);
}
+ parent.add_attribute (new_attribute);
} else if (att.name in attributes) {
Attribute new_attribute = new Attribute (parent, parent.get_source_file (),
att.name, att);
parent.add_attribute (new_attribute);
diff --git a/src/driver/0.34.x/treebuilder.vala b/src/driver/0.34.x/treebuilder.vala
index 0d1bcec..9931efd 100644
--- a/src/driver/0.34.x/treebuilder.vala
+++ b/src/driver/0.34.x/treebuilder.vala
@@ -250,33 +250,31 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
parent.add_attribute (new_attribute);
} else if (att.name == "Version") {
Attribute new_attribute = new Attribute (parent, parent.get_source_file (),
att.name, att);
-
if ((tmp = att.args.get ("deprecated")) != null) {
new_attribute.add_boolean ("deprecated", bool.parse (tmp), att);
}
-
- parent.add_attribute (new_attribute);
if ((tmp = att.args.get ("since")) != null) {
new_attribute.add_string ("since", tmp, att);
}
-
if ((tmp = att.args.get ("deprecated_since")) != null) {
new_attribute.add_string ("deprecated_since", tmp, att);
+ if (att.args.get ("deprecated") == null) {
+ new_attribute.add_boolean ("deprecated", true, att);
+ }
}
-
if ((tmp = att.args.get ("replacement")) != null) {
new_attribute.add_string ("replacement", tmp, att);
}
+ parent.add_attribute (new_attribute);
} else if (att.name == "Deprecated") {
Attribute new_attribute = new Attribute (parent, parent.get_source_file (),
att.name, att);
- parent.add_attribute (new_attribute);
if ((tmp = att.args.get ("since")) != null) {
new_attribute.add_string ("since", tmp, att);
}
-
if ((tmp = att.args.get ("replacement")) != null) {
new_attribute.add_string ("replacement", tmp, att);
}
+ parent.add_attribute (new_attribute);
} else if (att.name in attributes) {
Attribute new_attribute = new Attribute (parent, parent.get_source_file (),
att.name, att);
parent.add_attribute (new_attribute);
diff --git a/src/driver/0.36.x/treebuilder.vala b/src/driver/0.36.x/treebuilder.vala
index ce49334..aebf272 100644
--- a/src/driver/0.36.x/treebuilder.vala
+++ b/src/driver/0.36.x/treebuilder.vala
@@ -250,33 +250,31 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
parent.add_attribute (new_attribute);
} else if (att.name == "Version") {
Attribute new_attribute = new Attribute (parent, parent.get_source_file (),
att.name, att);
-
if ((tmp = att.args.get ("deprecated")) != null) {
new_attribute.add_boolean ("deprecated", bool.parse (tmp), att);
}
-
- parent.add_attribute (new_attribute);
if ((tmp = att.args.get ("since")) != null) {
new_attribute.add_string ("since", tmp, att);
}
-
if ((tmp = att.args.get ("deprecated_since")) != null) {
new_attribute.add_string ("deprecated_since", tmp, att);
+ if (att.args.get ("deprecated") == null) {
+ new_attribute.add_boolean ("deprecated", true, att);
+ }
}
-
if ((tmp = att.args.get ("replacement")) != null) {
new_attribute.add_string ("replacement", tmp, att);
}
+ parent.add_attribute (new_attribute);
} else if (att.name == "Deprecated") {
Attribute new_attribute = new Attribute (parent, parent.get_source_file (),
att.name, att);
- parent.add_attribute (new_attribute);
if ((tmp = att.args.get ("since")) != null) {
new_attribute.add_string ("since", tmp, att);
}
-
if ((tmp = att.args.get ("replacement")) != null) {
new_attribute.add_string ("replacement", tmp, att);
}
+ parent.add_attribute (new_attribute);
} else if (att.name in attributes) {
Attribute new_attribute = new Attribute (parent, parent.get_source_file (),
att.name, att);
parent.add_attribute (new_attribute);
diff --git a/src/libvaladoc/html/basicdoclet.vala b/src/libvaladoc/html/basicdoclet.vala
index e2ab932..dd993d6 100644
--- a/src/libvaladoc/html/basicdoclet.vala
+++ b/src/libvaladoc/html/basicdoclet.vala
@@ -459,18 +459,10 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet {
private void write_documentation (Api.Node element , Api.Node? pos) {
Content.Comment? doctree = element.documentation;
- Attribute? version = (element is Symbol) ? ((Symbol) element).get_attribute ("Version") :
null;
- Attribute? deprecated = (element is Symbol) ? ((Symbol) element).get_attribute ("Deprecated")
: null;
- bool is_deprecated = false;
- if (version != null) {
- AttributeArgument? deprecated_arg = version.get_argument ("deprecated");
- is_deprecated = (deprecated_arg != null) ? deprecated_arg.get_value_as_boolean () :
is_deprecated;
- } else {
- is_deprecated = deprecated != null;
- }
+ bool is_deprecated = (element is Symbol) ? ((Symbol) element).is_deprecated : false;
// avoid empty divs
- if (doctree == null && deprecated == null) {
+ if (doctree == null && !is_deprecated) {
return;
}
@@ -480,14 +472,19 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet {
// deprecation warning:
if (is_deprecated) {
+ Symbol symbol = (Symbol) element;
+ Attribute? version = symbol.get_attribute ("Version");
+ Attribute? deprecated = symbol.get_attribute ("Deprecated");
AttributeArgument? replacement = null;
AttributeArgument? since = null;
if (version != null) {
replacement = version.get_argument ("replacement");
since = version.get_argument ("deprecated_since");
- } else {
+ } else if (deprecated != null) {
replacement = deprecated.get_argument ("replacement");
since = deprecated.get_argument ("version");
+ } else {
+ assert_not_reached ();
}
writer.start_tag ("p");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]