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 ("\"")) {
}
}
- var replacement = deprecated_attribute.get_argument ("replacement");
string? replacement_symbol_name = null;
Api.Node? replacement_symbol = null;
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);
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);
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);
}
// 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;
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;
}
_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");
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 (".");
{
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) {