[valadoc] Add support for the Version tag that replaces the Deprecated tag
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [valadoc] Add support for the Version tag that replaces the Deprecated tag
- Date: Tue, 21 Feb 2017 08:20:44 +0000 (UTC)
commit 2a115a80282d1b4a3c7664f18038acd70366fb86
Author: Corentin Noël <corentin elementary io>
Date: Wed Feb 15 01:39:38 2017 +0100
Add support for the Version tag that replaces the Deprecated tag
https://bugzilla.gnome.org/show_bug.cgi?id=778640
src/doclets/gtkdoc/generator.vala | 22 ++++++++++++++++------
src/driver/0.32.x/treebuilder.vala | 21 +++++++++++++++++++--
src/driver/0.34.x/treebuilder.vala | 21 +++++++++++++++++++--
src/driver/0.36.x/treebuilder.vala | 21 +++++++++++++++++++--
src/libvaladoc/api/symbol.vala | 13 +++++++++++--
src/libvaladoc/html/basicdoclet.vala | 26 +++++++++++++++++++-------
src/libvaladoc/taglets/tagletdeprecated.vala | 2 +-
7 files changed, 104 insertions(+), 22 deletions(-)
---
diff --git a/src/doclets/gtkdoc/generator.vala b/src/doclets/gtkdoc/generator.vala
index 98c1d25..6aba0a6 100644
--- a/src/doclets/gtkdoc/generator.vala
+++ b/src/doclets/gtkdoc/generator.vala
@@ -1336,13 +1336,24 @@ 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 deprecated_attribute = sym.get_attribute ("Deprecated");
+ if (sym.is_deprecated) {
+ Attribute? version;
+ Attribute? deprecated;
+ AttributeArgument? deprecated_since;
+ AttributeArgument? replacement;
+ if ((version = sym.get_attribute ("Version")) != null) {
+ deprecated_since = version.get_argument ("deprecated_since");
+ replacement = version.get_argument ("replacement");
+ } else if ((deprecated = sym.get_attribute ("Deprecated")) != null) {
+ deprecated_since = deprecated.get_argument ("since");
+ replacement = deprecated.get_argument ("replacement");
+ } else {
+ assert_not_reached ();
+ }
- if (deprecated_attribute != null) {
- var _since = deprecated_attribute.get_argument ("since");
string? since = null;
- if (_since != null) {
- since = _since.value;
+ if (deprecated_since != null) {
+ since = deprecated_since.value;
// Strip surrounding quotation marks.
if (since.has_prefix ("\"")) {
@@ -1353,7 +1364,6 @@ It is important that your <link linkend=\"GValue\"><type>GValue</type></link> ho
}
}
- var replacement = deprecated_attribute.get_argument ("replacement");
string? replacement_symbol_name = null;
Api.Node? replacement_symbol = null;
diff --git a/src/driver/0.32.x/treebuilder.vala b/src/driver/0.32.x/treebuilder.vala
index 59e019a..5b9c5ea 100644
--- a/src/driver/0.32.x/treebuilder.vala
+++ b/src/driver/0.32.x/treebuilder.vala
@@ -248,16 +248,33 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
Attribute new_attribute = new Attribute (parent, parent.get_source_file (),
att.name, att);
new_attribute.add_boolean ("has_target", false, att);
parent.add_attribute (new_attribute);
- } else if (att.name == "Deprecated") {
+ } 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);
+ }
+ 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);
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 cbdadae..9931efd 100644
--- a/src/driver/0.34.x/treebuilder.vala
+++ b/src/driver/0.34.x/treebuilder.vala
@@ -248,16 +248,33 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
Attribute new_attribute = new Attribute (parent, parent.get_source_file (),
att.name, att);
new_attribute.add_boolean ("has_target", false, att);
parent.add_attribute (new_attribute);
- } else if (att.name == "Deprecated") {
+ } 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);
+ }
+ 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);
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 46c4b25..aebf272 100644
--- a/src/driver/0.36.x/treebuilder.vala
+++ b/src/driver/0.36.x/treebuilder.vala
@@ -248,16 +248,33 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
Attribute new_attribute = new Attribute (parent, parent.get_source_file (),
att.name, att);
new_attribute.add_boolean ("has_target", false, att);
parent.add_attribute (new_attribute);
- } else if (att.name == "Deprecated") {
+ } 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);
+ }
+ 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);
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/api/symbol.vala b/src/libvaladoc/api/symbol.vala
index e4520b3..aec2bdd 100644
--- a/src/libvaladoc/api/symbol.vala
+++ b/src/libvaladoc/api/symbol.vala
@@ -49,9 +49,18 @@ public abstract class Valadoc.Api.Symbol : Node {
}
// register deprecated symbols:
- if (att.name == "Deprecated") {
+ if (att.name == "Version") {
+ AttributeArgument? deprecated = att.get_argument ("deprecated");
+ AttributeArgument? version = att.get_argument ("deprecated_since");
+ if ((deprecated != null && deprecated.get_value_as_boolean ()) || version != null) {
+ string? version_str = (version != null) ? version.get_value_as_string () :
null;
+
+ package.register_deprecated_symbol (this, version_str);
+ is_deprecated = true;
+ }
+ } else if (att.name == "Deprecated") {
AttributeArgument? version = att.get_argument ("version");
- string? version_str = (version == null)? null : version.get_value_as_string ();
+ string? version_str = (version != null) ? version.get_value_as_string () : null;
package.register_deprecated_symbol (this, version_str);
is_deprecated = true;
diff --git a/src/libvaladoc/html/basicdoclet.vala b/src/libvaladoc/html/basicdoclet.vala
index 66ab3e0..f770bc2 100644
--- a/src/libvaladoc/html/basicdoclet.vala
+++ b/src/libvaladoc/html/basicdoclet.vala
@@ -459,10 +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? deprecated = (element is Symbol)? ((Symbol) element).get_attribute ("Deprecated")
: null;
+ bool is_deprecated = (element is Symbol && ((Symbol) element).is_deprecated);
// avoid empty divs
- if (doctree == null && deprecated == null) {
+ if (doctree == null && !is_deprecated) {
return;
}
@@ -471,9 +471,21 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet {
_renderer.set_owner (element);
// deprecation warning:
- if (deprecated != null) {
- AttributeArgument? replacement = deprecated.get_argument ("replacement");
- AttributeArgument? version = deprecated.get_argument ("version");
+ if (is_deprecated) {
+ Symbol symbol = (Symbol) element;
+ Attribute? version;
+ Attribute? deprecated;
+ AttributeArgument? replacement;
+ AttributeArgument? since;
+ if ((version = symbol.get_attribute ("Version")) != null) {
+ replacement = version.get_argument ("replacement");
+ since = version.get_argument ("deprecated_since");
+ } else if ((deprecated = symbol.get_attribute ("Deprecated")) != null) {
+ replacement = deprecated.get_argument ("replacement");
+ since = deprecated.get_argument ("version");
+ } else {
+ assert_not_reached ();
+ }
writer.start_tag ("p");
writer.start_tag ("b");
@@ -481,8 +493,8 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet {
writer.end_tag ("b");
writer.text (" %s is deprecated".printf (element.name));
- if (version != null) {
- writer.text (" since %s".printf (version.get_value_as_string ()));
+ if (since != null) {
+ writer.text (" since %s".printf (since.get_value_as_string ()));
}
writer.text (".");
diff --git a/src/libvaladoc/taglets/tagletdeprecated.vala b/src/libvaladoc/taglets/tagletdeprecated.vala
index 82c01f8..c774579 100644
--- a/src/libvaladoc/taglets/tagletdeprecated.vala
+++ b/src/libvaladoc/taglets/tagletdeprecated.vala
@@ -35,7 +35,7 @@ public class Valadoc.Taglets.Deprecated : BlockContent, Taglet, Block {
{
base.check (api_root, container, file_path, reporter, settings);
reporter.simple_warning ("%s: %s: @deprecated".printf (file_path, container.get_full_name ()),
- "@deprecated is deprecated. Use
[Deprecated]");
+ "@deprecated is deprecated. Use [Version
(deprecated = true)]");
}
public override void accept (ContentVisitor visitor) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]