[valadoc/wip/tintou/version-support] Add support for the Version tag that replaces the Deprecated tag
- From: Corentin Noël <corentinnoel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [valadoc/wip/tintou/version-support] Add support for the Version tag that replaces the Deprecated tag
- Date: Wed, 15 Feb 2017 22:26:07 +0000 (UTC)
commit 62371c508dca754221a8e846d12a186a232dfd69
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
src/doclets/gtkdoc/generator.vala | 19 +++++++++++++----
src/driver/0.36.x/treebuilder.vala | 19 ++++++++++++++++++
src/libvaladoc/api/symbol.vala | 13 ++++++++++-
src/libvaladoc/html/basicdoclet.vala | 27 ++++++++++++++++++++-----
src/libvaladoc/taglets/tagletdeprecated.vala | 2 +-
5 files changed, 66 insertions(+), 14 deletions(-)
---
diff --git a/src/doclets/gtkdoc/generator.vala b/src/doclets/gtkdoc/generator.vala
index 98c1d25..44fe6b5 100644
--- a/src/doclets/gtkdoc/generator.vala
+++ b/src/doclets/gtkdoc/generator.vala
@@ -1336,13 +1336,23 @@ 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");
- if (deprecated_attribute != null) {
- var _since = deprecated_attribute.get_argument ("since");
+ 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 (deprecated_attribute != null || version_attribute != null) {
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 +1363,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.36.x/treebuilder.vala b/src/driver/0.36.x/treebuilder.vala
index 46c4b25..ce49334 100644
--- a/src/driver/0.36.x/treebuilder.vala
+++ b/src/driver/0.36.x/treebuilder.vala
@@ -248,6 +248,25 @@ 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 == "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 ((tmp = att.args.get ("replacement")) != null) {
+ new_attribute.add_string ("replacement", tmp, att);
+ }
} else if (att.name == "Deprecated") {
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..e2ab932 100644
--- a/src/libvaladoc/html/basicdoclet.vala
+++ b/src/libvaladoc/html/basicdoclet.vala
@@ -459,7 +459,15 @@ 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;
+ 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;
+ }
// avoid empty divs
if (doctree == null && deprecated == null) {
@@ -471,9 +479,16 @@ 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) {
+ AttributeArgument? replacement = null;
+ AttributeArgument? since = null;
+ if (version != null) {
+ replacement = version.get_argument ("replacement");
+ since = version.get_argument ("deprecated_since");
+ } else {
+ replacement = deprecated.get_argument ("replacement");
+ since = deprecated.get_argument ("version");
+ }
writer.start_tag ("p");
writer.start_tag ("b");
@@ -481,8 +496,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]